diff options
author | Loic Poulain <loic.poulain@linaro.org> | 2021-05-25 19:31:18 +0300 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2021-05-26 01:51:37 +0300 |
commit | e4e92ee78702b13ad55118d8b66f06e1aef62586 (patch) | |
tree | 006cc907936f000acba36e18e43efe9f15faf8e3 /drivers/net/wwan/wwan_core.c | |
parent | 1b19b3f79063b202af3c8e1597320dee2f216756 (diff) | |
download | linux-e4e92ee78702b13ad55118d8b66f06e1aef62586.tar.xz |
net: wwan: core: Add WWAN device index sysfs attribute
Add index sysfs attribute for WWAN devices. This index is used to
uniquely indentify and reference a WWAN device. 'index' is the
attribute name that other device classes use (wireless, v4l2-dev,
rfkill, etc...).
Signed-off-by: Loic Poulain <loic.poulain@linaro.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/wwan/wwan_core.c')
-rw-r--r-- | drivers/net/wwan/wwan_core.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/drivers/net/wwan/wwan_core.c b/drivers/net/wwan/wwan_core.c index 92a8a6ffc567..6e8f19c71a9e 100644 --- a/drivers/net/wwan/wwan_core.c +++ b/drivers/net/wwan/wwan_core.c @@ -63,6 +63,20 @@ struct wwan_port { wait_queue_head_t waitqueue; }; +static ssize_t index_show(struct device *dev, struct device_attribute *attr, char *buf) +{ + struct wwan_device *wwan = to_wwan_dev(dev); + + return sprintf(buf, "%d\n", wwan->id); +} +static DEVICE_ATTR_RO(index); + +static struct attribute *wwan_dev_attrs[] = { + &dev_attr_index.attr, + NULL, +}; +ATTRIBUTE_GROUPS(wwan_dev); + static void wwan_dev_destroy(struct device *dev) { struct wwan_device *wwandev = to_wwan_dev(dev); @@ -74,6 +88,7 @@ static void wwan_dev_destroy(struct device *dev) static const struct device_type wwan_dev_type = { .name = "wwan_dev", .release = wwan_dev_destroy, + .groups = wwan_dev_groups, }; static int wwan_dev_parent_match(struct device *dev, const void *parent) |