Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

David Vrabel and committed by
David Vrabel
b60066c1 b63795fa

+37 -8
+3
drivers/usb/wusbcore/pal.c
··· 26 26 { 27 27 uwb_pal_init(&wusbhc->pal); 28 28 29 + wusbhc->pal.name = "wusbhc"; 30 + wusbhc->pal.device = wusbhc->usb_hcd.self.controller; 31 + 29 32 return uwb_pal_register(wusbhc->uwb_rc, &wusbhc->pal); 30 33 } 31 34
+9 -7
drivers/usb/wusbcore/wusbhc.c
··· 192 192 result = wusbhc_sec_create(wusbhc); 193 193 if (result < 0) 194 194 goto error_sec_create; 195 - result = wusbhc_pal_register(wusbhc); 196 - if (result < 0) 197 - goto error_pal_register; 198 195 return 0; 199 196 200 - error_pal_register: 201 - wusbhc_sec_destroy(wusbhc); 202 197 error_sec_create: 203 198 wusbhc_rh_destroy(wusbhc); 204 199 error_rh_create: ··· 230 235 dev_err(dev, "Cannot register WUSBHC attributes: %d\n", result); 231 236 goto error_create_attr_group; 232 237 } 233 - /* Yep, I plan to add stuff here... */ 238 + 239 + result = wusbhc_pal_register(wusbhc); 240 + if (result < 0) 241 + goto error_pal_register; 242 + return 0; 243 + 244 + error_pal_register: 245 + sysfs_remove_group(wusbhc_kobj(wusbhc), &wusbhc_attr_group); 234 246 error_create_attr_group: 235 247 return result; 236 248 } ··· 245 243 246 244 void wusbhc_b_destroy(struct wusbhc *wusbhc) 247 245 { 246 + wusbhc_pal_unregister(wusbhc); 248 247 sysfs_remove_group(wusbhc_kobj(wusbhc), &wusbhc_attr_group); 249 248 } 250 249 EXPORT_SYMBOL_GPL(wusbhc_b_destroy); 251 250 252 251 void wusbhc_destroy(struct wusbhc *wusbhc) 253 252 { 254 - wusbhc_pal_unregister(wusbhc); 255 253 wusbhc_sec_destroy(wusbhc); 256 254 wusbhc_rh_destroy(wusbhc); 257 255 wusbhc_devconnect_destroy(wusbhc);
+20
drivers/uwb/pal.c
··· 39 39 */ 40 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 57 spin_lock(&rc->pal_lock); 43 58 list_add(&pal->node, &rc->pals); 44 59 spin_unlock(&rc->pal_lock); ··· 72 57 spin_lock(&rc->pal_lock); 73 58 list_del(&pal->node); 74 59 spin_unlock(&rc->pal_lock); 60 + 61 + if (pal->device) { 62 + sysfs_remove_link(&rc->uwb_dev.dev.kobj, pal->name); 63 + sysfs_remove_link(&pal->device->kobj, "uwb_rc"); 64 + } 75 65 } 76 66 EXPORT_SYMBOL_GPL(uwb_pal_unregister); 77 67
+5 -1
include/linux/uwb.h
··· 361 361 362 362 /** 363 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 367 * @new_rsv: called when a peer requests a reservation (may be NULL if 365 368 * the PAL cannot accept reservation requests). 366 369 * ··· 382 379 */ 383 380 struct uwb_pal { 384 381 struct list_head node; 385 - 382 + const char *name; 383 + struct device *device; 386 384 void (*new_rsv)(struct uwb_rsv *rsv); 387 385 }; 388 386