Thread (5 messages) read the whole thread 5 messages, 3 authors, 1d ago

Re: [PATCH net-next v3 2/2] net: wwan: add exclusive open mode capability to AT and QCDM ports

From: Loic Poulain <loic.poulain@oss.qualcomm.com>
Date: 2026-07-24 18:22:36

On Fri, Jul 24, 2026 at 4:32 PM Daniele Palmas [off-list ref] wrote:
Add exclusive open mode capability to AT and QCDM ports to improve
compatibility with user-space tools using the Qualcomm diagnostic
device (e.g. libqcdm).

Signed-off-by: Daniele Palmas <redacted>
This looks somewhat fragile in scenarios where a process does not
properly release the bit, such as on a crash. That said, it appears to
be consistent with the mechanism used by tty, so:

Reviewed-by: Loic Poulain <loic.poulain@oss.qualcomm.com>

quoted hunk ↗ jump to hunk
---
 drivers/net/wwan/wwan_core.c | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)
diff --git a/drivers/net/wwan/wwan_core.c b/drivers/net/wwan/wwan_core.c
index 8168239e52c3..ffbcf11e4e68 100644
--- a/drivers/net/wwan/wwan_core.c
+++ b/drivers/net/wwan/wwan_core.c
@@ -42,6 +42,7 @@ static struct dentry *wwan_debugfs_dir;

 /* WWAN port flags */
 #define WWAN_PORT_TX_OFF       0
+#define WWAN_PORT_EXCLUSIVE    1

 /**
  * struct wwan_device - The structure that defines a WWAN device
@@ -748,6 +749,12 @@ static int wwan_port_op_start(struct wwan_port *port)
                goto out_unlock;
        }

+       if (test_bit(WWAN_PORT_EXCLUSIVE, &port->flags) &&
+           !capable(CAP_SYS_ADMIN)) {
+               ret = -EBUSY;
+               goto out_unlock;
+       }
+
        /* If port is already started, don't start again */
        if (!port->start_count)
                ret = port->ops->start(port);
@@ -769,6 +776,7 @@ static void wwan_port_op_stop(struct wwan_port *port)
                if (port->ops)
                        port->ops->stop(port);
                skb_queue_purge(&port->rxq);
+               clear_bit(WWAN_PORT_EXCLUSIVE, &port->flags);
        }
        mutex_unlock(&port->ops_lock);
 }
@@ -1031,6 +1039,22 @@ static long wwan_port_fops_at_ioctl(struct wwan_port *port, unsigned int cmd,
                break;
        }

+       case TIOCEXCL:
+               set_bit(WWAN_PORT_EXCLUSIVE, &port->flags);
+               break;
+
+       case TIOCNXCL:
+               clear_bit(WWAN_PORT_EXCLUSIVE, &port->flags);
+               break;
+
+       case TIOCGEXCL:
+       {
+               int excl = test_bit(WWAN_PORT_EXCLUSIVE, &port->flags);
+
+               ret = put_user(excl, (int __user *)arg);
+               break;
+       }
+
        default:
                ret = -ENOIOCTLCMD;
        }
--
2.43.0
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help