Skip to content

Commit

Permalink
net: usb: qmi_wwan: add qmap id sysfs file for qmimux interfaces
Browse files Browse the repository at this point in the history
Add qmimux interface sysfs file qmap/mux_id to show qmap id set
during the interface creation, in order to provide a method for
userspace to associate QMI control channels to network interfaces.

Signed-off-by: Daniele Palmas <[email protected]>
Acked-by: Bjørn Mork <[email protected]>
Acked-by: Aleksander Morgado <[email protected]>
Signed-off-by: Jakub Kicinski <[email protected]>
  • Loading branch information
dnlplm authored and kuba-moo committed Jan 29, 2021
1 parent d7a177e commit e594ad9
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions drivers/net/usb/qmi_wwan.c
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,28 @@ static int qmimux_rx_fixup(struct usbnet *dev, struct sk_buff *skb)
return 1;
}

static ssize_t mux_id_show(struct device *d, struct device_attribute *attr, char *buf)
{
struct net_device *dev = to_net_dev(d);
struct qmimux_priv *priv;

priv = netdev_priv(dev);

return sysfs_emit(buf, "0x%02x\n", priv->mux_id);
}

static DEVICE_ATTR_RO(mux_id);

static struct attribute *qmi_wwan_sysfs_qmimux_attrs[] = {
&dev_attr_mux_id.attr,
NULL,
};

static struct attribute_group qmi_wwan_sysfs_qmimux_attr_group = {
.name = "qmap",
.attrs = qmi_wwan_sysfs_qmimux_attrs,
};

static int qmimux_register_device(struct net_device *real_dev, u8 mux_id)
{
struct net_device *new_dev;
Expand All @@ -240,6 +262,8 @@ static int qmimux_register_device(struct net_device *real_dev, u8 mux_id)
goto out_free_newdev;
}

new_dev->sysfs_groups[0] = &qmi_wwan_sysfs_qmimux_attr_group;

err = register_netdevice(new_dev);
if (err < 0)
goto out_free_newdev;
Expand Down

0 comments on commit e594ad9

Please sign in to comment.