diff options
author | David Vrabel <david.vrabel@csr.com> | 2008-09-17 11:34:40 -0400 |
---|---|---|
committer | David Vrabel <dv02@dv02pc01.europe.root.pri> | 2008-09-17 11:54:35 -0400 |
commit | b60066c141997ac2e4ef08459b75638ae86ae781 (patch) | |
tree | e7c89b8652a0f0416d0da338c31337991bf57c93 | |
parent | b63795fa3a41151040b86119750a7df508d40cda (diff) |
uwb: add symlinks in sysfs between radio controllers and PALs
Add a facility for PALs to have symlinks to their radio controller
(and vice-versa) and make WUSB host controllers use this.
Signed-off-by: David Vrabel <david.vrabel@csr.com>
-rw-r--r-- | drivers/usb/wusbcore/pal.c | 3 | ||||
-rw-r--r-- | drivers/usb/wusbcore/wusbhc.c | 16 | ||||
-rw-r--r-- | drivers/uwb/pal.c | 20 | ||||
-rw-r--r-- | include/linux/uwb.h | 6 |
4 files changed, 37 insertions, 8 deletions
diff --git a/drivers/usb/wusbcore/pal.c b/drivers/usb/wusbcore/pal.c index cc126b444734..7cc51e9905cf 100644 --- a/drivers/usb/wusbcore/pal.c +++ b/drivers/usb/wusbcore/pal.c | |||
@@ -26,6 +26,9 @@ int wusbhc_pal_register(struct wusbhc *wusbhc) | |||
26 | { | 26 | { |
27 | uwb_pal_init(&wusbhc->pal); | 27 | uwb_pal_init(&wusbhc->pal); |
28 | 28 | ||
29 | wusbhc->pal.name = "wusbhc"; | ||
30 | wusbhc->pal.device = wusbhc->usb_hcd.self.controller; | ||
31 | |||
29 | return uwb_pal_register(wusbhc->uwb_rc, &wusbhc->pal); | 32 | return uwb_pal_register(wusbhc->uwb_rc, &wusbhc->pal); |
30 | } | 33 | } |
31 | 34 | ||
diff --git a/drivers/usb/wusbcore/wusbhc.c b/drivers/usb/wusbcore/wusbhc.c index 1149b1e59c86..07c63a31c799 100644 --- a/drivers/usb/wusbcore/wusbhc.c +++ b/drivers/usb/wusbcore/wusbhc.c | |||
@@ -192,13 +192,8 @@ int wusbhc_create(struct wusbhc *wusbhc) | |||
192 | result = wusbhc_sec_create(wusbhc); | 192 | result = wusbhc_sec_create(wusbhc); |
193 | if (result < 0) | 193 | if (result < 0) |
194 | goto error_sec_create; | 194 | goto error_sec_create; |
195 | result = wusbhc_pal_register(wusbhc); | ||
196 | if (result < 0) | ||
197 | goto error_pal_register; | ||
198 | return 0; | 195 | return 0; |
199 | 196 | ||
200 | error_pal_register: | ||
201 | wusbhc_sec_destroy(wusbhc); | ||
202 | error_sec_create: | 197 | error_sec_create: |
203 | wusbhc_rh_destroy(wusbhc); | 198 | wusbhc_rh_destroy(wusbhc); |
204 | error_rh_create: | 199 | error_rh_create: |
@@ -235,7 +230,14 @@ int wusbhc_b_create(struct wusbhc *wusbhc) | |||
235 | dev_err(dev, "Cannot register WUSBHC attributes: %d\n", result); | 230 | dev_err(dev, "Cannot register WUSBHC attributes: %d\n", result); |
236 | goto error_create_attr_group; | 231 | goto error_create_attr_group; |
237 | } | 232 | } |
238 | /* Yep, I plan to add stuff here... */ | 233 | |
234 | result = wusbhc_pal_register(wusbhc); | ||
235 | if (result < 0) | ||
236 | goto error_pal_register; | ||
237 | return 0; | ||
238 | |||
239 | error_pal_register: | ||
240 | sysfs_remove_group(wusbhc_kobj(wusbhc), &wusbhc_attr_group); | ||
239 | error_create_attr_group: | 241 | error_create_attr_group: |
240 | return result; | 242 | return result; |
241 | } | 243 | } |
@@ -243,13 +245,13 @@ EXPORT_SYMBOL_GPL(wusbhc_b_create); | |||
243 | 245 | ||
244 | void wusbhc_b_destroy(struct wusbhc *wusbhc) | 246 | void wusbhc_b_destroy(struct wusbhc *wusbhc) |
245 | { | 247 | { |
248 | wusbhc_pal_unregister(wusbhc); | ||
246 | sysfs_remove_group(wusbhc_kobj(wusbhc), &wusbhc_attr_group); | 249 | sysfs_remove_group(wusbhc_kobj(wusbhc), &wusbhc_attr_group); |
247 | } | 250 | } |
248 | EXPORT_SYMBOL_GPL(wusbhc_b_destroy); | 251 | EXPORT_SYMBOL_GPL(wusbhc_b_destroy); |
249 | 252 | ||
250 | void wusbhc_destroy(struct wusbhc *wusbhc) | 253 | void wusbhc_destroy(struct wusbhc *wusbhc) |
251 | { | 254 | { |
252 | wusbhc_pal_unregister(wusbhc); | ||
253 | wusbhc_sec_destroy(wusbhc); | 255 | wusbhc_sec_destroy(wusbhc); |
254 | wusbhc_rh_destroy(wusbhc); | 256 | wusbhc_rh_destroy(wusbhc); |
255 | wusbhc_devconnect_destroy(wusbhc); | 257 | wusbhc_devconnect_destroy(wusbhc); |
diff --git a/drivers/uwb/pal.c b/drivers/uwb/pal.c index 5508993a820e..1afb38eacb9a 100644 --- a/drivers/uwb/pal.c +++ b/drivers/uwb/pal.c | |||
@@ -39,6 +39,21 @@ EXPORT_SYMBOL_GPL(uwb_pal_init); | |||
39 | */ | 39 | */ |
40 | int uwb_pal_register(struct uwb_rc *rc, struct uwb_pal *pal) | 40 | int uwb_pal_register(struct uwb_rc *rc, struct uwb_pal *pal) |
41 | { | 41 | { |
42 | int ret; | ||
43 | |||
44 | if (pal->device) { | ||
45 | ret = sysfs_create_link(&pal->device->kobj, | ||
46 | &rc->uwb_dev.dev.kobj, "uwb_rc"); | ||
47 | if (ret < 0) | ||
48 | return ret; | ||
49 | ret = sysfs_create_link(&rc->uwb_dev.dev.kobj, | ||
50 | &pal->device->kobj, pal->name); | ||
51 | if (ret < 0) { | ||
52 | sysfs_remove_link(&pal->device->kobj, "uwb_rc"); | ||
53 | return ret; | ||
54 | } | ||
55 | } | ||
56 | |||
42 | spin_lock(&rc->pal_lock); | 57 | spin_lock(&rc->pal_lock); |
43 | list_add(&pal->node, &rc->pals); | 58 | list_add(&pal->node, &rc->pals); |
44 | spin_unlock(&rc->pal_lock); | 59 | spin_unlock(&rc->pal_lock); |
@@ -57,6 +72,11 @@ void uwb_pal_unregister(struct uwb_rc *rc, struct uwb_pal *pal) | |||
57 | spin_lock(&rc->pal_lock); | 72 | spin_lock(&rc->pal_lock); |
58 | list_del(&pal->node); | 73 | list_del(&pal->node); |
59 | spin_unlock(&rc->pal_lock); | 74 | spin_unlock(&rc->pal_lock); |
75 | |||
76 | if (pal->device) { | ||
77 | sysfs_remove_link(&rc->uwb_dev.dev.kobj, pal->name); | ||
78 | sysfs_remove_link(&pal->device->kobj, "uwb_rc"); | ||
79 | } | ||
60 | } | 80 | } |
61 | EXPORT_SYMBOL_GPL(uwb_pal_unregister); | 81 | EXPORT_SYMBOL_GPL(uwb_pal_unregister); |
62 | 82 | ||
diff --git a/include/linux/uwb.h b/include/linux/uwb.h index 0cd35937e120..f9ccbd9a2ced 100644 --- a/include/linux/uwb.h +++ b/include/linux/uwb.h | |||
@@ -361,6 +361,9 @@ struct uwb_rc { | |||
361 | 361 | ||
362 | /** | 362 | /** |
363 | * struct uwb_pal - a UWB PAL | 363 | * struct uwb_pal - a UWB PAL |
364 | * @name: descriptive name for this PAL (wushc, wlp, etc.). | ||
365 | * @device: a device for the PAL. Used to link the PAL and the radio | ||
366 | * controller in sysfs. | ||
364 | * @new_rsv: called when a peer requests a reservation (may be NULL if | 367 | * @new_rsv: called when a peer requests a reservation (may be NULL if |
365 | * the PAL cannot accept reservation requests). | 368 | * the PAL cannot accept reservation requests). |
366 | * | 369 | * |
@@ -379,7 +382,8 @@ struct uwb_rc { | |||
379 | */ | 382 | */ |
380 | struct uwb_pal { | 383 | struct uwb_pal { |
381 | struct list_head node; | 384 | struct list_head node; |
382 | 385 | const char *name; | |
386 | struct device *device; | ||
383 | void (*new_rsv)(struct uwb_rsv *rsv); | 387 | void (*new_rsv)(struct uwb_rsv *rsv); |
384 | }; | 388 | }; |
385 | 389 | ||