From 848879340a7d220fd9801396eba82ecac2f2a739 Mon Sep 17 00:00:00 2001 From: Thomas Pugliese Date: Tue, 16 Sep 2014 15:53:08 -0500 Subject: [PATCH] uwb: create a uwb bus type and add in-range peer devices to it Documentation/usb/WUSB-Design-overview.txt states that UWB devices seen by a UWB radio controller are added to /sys/bus/uwb/devices, but this was not actually being done. This functionality is needed in order for UWB peer devices to be enumerated by user mode tools. This patch creates a uwb bus type and adds UWB peer devices to it as they are discovered by the radio controller. Signed-off-by: Thomas Pugliese Signed-off-by: Greg Kroah-Hartman --- drivers/uwb/driver.c | 11 +++++++++++ drivers/uwb/lc-dev.c | 11 +++++++---- drivers/uwb/uwb-internal.h | 1 + 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/drivers/uwb/driver.c b/drivers/uwb/driver.c index 3e5454aba5d4..776bcb3c2140 100644 --- a/drivers/uwb/driver.c +++ b/drivers/uwb/driver.c @@ -121,9 +121,19 @@ static int __init uwb_subsys_init(void) result = class_register(&uwb_rc_class); if (result < 0) goto error_uwb_rc_class_register; + + /* Register the UWB bus */ + result = bus_register(&uwb_bus_type); + if (result) { + pr_err("%s - registering bus driver failed\n", __func__); + goto exit_bus; + } + uwb_dbg_init(); return 0; +exit_bus: + class_unregister(&uwb_rc_class); error_uwb_rc_class_register: uwb_est_destroy(); error_est_init: @@ -134,6 +144,7 @@ module_init(uwb_subsys_init); static void __exit uwb_subsys_exit(void) { uwb_dbg_exit(); + bus_unregister(&uwb_bus_type); class_unregister(&uwb_rc_class); uwb_est_destroy(); return; diff --git a/drivers/uwb/lc-dev.c b/drivers/uwb/lc-dev.c index ba76810eea10..8c7cfab5cee3 100644 --- a/drivers/uwb/lc-dev.c +++ b/drivers/uwb/lc-dev.c @@ -255,6 +255,12 @@ static struct attribute *uwb_dev_attrs[] = { }; ATTRIBUTE_GROUPS(uwb_dev); +/* UWB bus type. */ +struct bus_type uwb_bus_type = { + .name = "uwb", + .dev_groups = uwb_dev_groups, +}; + /** * Device SYSFS registration */ @@ -263,10 +269,6 @@ static int __uwb_dev_sys_add(struct uwb_dev *uwb_dev, struct device *parent_dev) struct device *dev; dev = &uwb_dev->dev; - /* Device sysfs files are only useful for neighbor devices not - local radio controllers. */ - if (&uwb_dev->rc->uwb_dev != uwb_dev) - dev->groups = uwb_dev_groups; dev->parent = parent_dev; dev_set_drvdata(dev, uwb_dev); @@ -428,6 +430,7 @@ void uwbd_dev_onair(struct uwb_rc *rc, struct uwb_beca_e *bce) return; } uwb_dev_init(uwb_dev); /* This sets refcnt to one, we own it */ + uwb_dev->dev.bus = &uwb_bus_type; uwb_dev->mac_addr = *bce->mac_addr; uwb_dev->dev_addr = bce->dev_addr; dev_set_name(&uwb_dev->dev, "%s", macbuf); diff --git a/drivers/uwb/uwb-internal.h b/drivers/uwb/uwb-internal.h index 6d1bed1f3460..353c0555a1f5 100644 --- a/drivers/uwb/uwb-internal.h +++ b/drivers/uwb/uwb-internal.h @@ -314,6 +314,7 @@ int uwb_radio_force_channel(struct uwb_rc *rc, int channel); /* -- UWB Sysfs representation */ extern struct class uwb_rc_class; +extern struct bus_type uwb_bus_type; extern struct device_attribute dev_attr_mac_address; extern struct device_attribute dev_attr_beacon; extern struct device_attribute dev_attr_scan;