]> bbs.cooldavid.org Git - net-next-2.6.git/commitdiff
uwb: add symlinks in sysfs between radio controllers and PALs
authorDavid Vrabel <david.vrabel@csr.com>
Wed, 17 Sep 2008 15:34:40 +0000 (16:34 +0100)
committerDavid Vrabel <dv02@dv02pc01.europe.root.pri>
Wed, 17 Sep 2008 15:54:35 +0000 (16:54 +0100)
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>
drivers/usb/wusbcore/pal.c
drivers/usb/wusbcore/wusbhc.c
drivers/uwb/pal.c
include/linux/uwb.h

index cc126b444734810855f37ba4a19d8086f336e019..7cc51e9905cf81e2234c0435d88630e9b1f558be 100644 (file)
@@ -26,6 +26,9 @@ int wusbhc_pal_register(struct wusbhc *wusbhc)
 {
        uwb_pal_init(&wusbhc->pal);
 
+       wusbhc->pal.name   = "wusbhc";
+       wusbhc->pal.device = wusbhc->usb_hcd.self.controller;
+
        return uwb_pal_register(wusbhc->uwb_rc, &wusbhc->pal);
 }
 
index 1149b1e59c865c4bc9ec3d3e49c485207944ed3c..07c63a31c799d50dda16eb7af74ed8daca033b12 100644 (file)
@@ -192,13 +192,8 @@ int wusbhc_create(struct wusbhc *wusbhc)
        result = wusbhc_sec_create(wusbhc);
        if (result < 0)
                goto error_sec_create;
-       result = wusbhc_pal_register(wusbhc);
-       if (result < 0)
-               goto error_pal_register;
        return 0;
 
-error_pal_register:
-       wusbhc_sec_destroy(wusbhc);
 error_sec_create:
        wusbhc_rh_destroy(wusbhc);
 error_rh_create:
@@ -235,7 +230,14 @@ int wusbhc_b_create(struct wusbhc *wusbhc)
                dev_err(dev, "Cannot register WUSBHC attributes: %d\n", result);
                goto error_create_attr_group;
        }
-       /* Yep, I plan to add stuff here... */
+
+       result = wusbhc_pal_register(wusbhc);
+       if (result < 0)
+               goto error_pal_register;
+       return 0;
+
+error_pal_register:
+       sysfs_remove_group(wusbhc_kobj(wusbhc), &wusbhc_attr_group);
 error_create_attr_group:
        return result;
 }
@@ -243,13 +245,13 @@ EXPORT_SYMBOL_GPL(wusbhc_b_create);
 
 void wusbhc_b_destroy(struct wusbhc *wusbhc)
 {
+       wusbhc_pal_unregister(wusbhc);
        sysfs_remove_group(wusbhc_kobj(wusbhc), &wusbhc_attr_group);
 }
 EXPORT_SYMBOL_GPL(wusbhc_b_destroy);
 
 void wusbhc_destroy(struct wusbhc *wusbhc)
 {
-       wusbhc_pal_unregister(wusbhc);
        wusbhc_sec_destroy(wusbhc);
        wusbhc_rh_destroy(wusbhc);
        wusbhc_devconnect_destroy(wusbhc);
index 5508993a820e5db5e8e7c41f1a3b08b6bb63e409..1afb38eacb9a295d55e6356b0ab3b3f8692ce28a 100644 (file)
@@ -39,6 +39,21 @@ EXPORT_SYMBOL_GPL(uwb_pal_init);
  */
 int uwb_pal_register(struct uwb_rc *rc, struct uwb_pal *pal)
 {
+       int ret;
+
+       if (pal->device) {
+               ret = sysfs_create_link(&pal->device->kobj,
+                                       &rc->uwb_dev.dev.kobj, "uwb_rc");
+               if (ret < 0)
+                       return ret;
+               ret = sysfs_create_link(&rc->uwb_dev.dev.kobj,
+                                       &pal->device->kobj, pal->name);
+               if (ret < 0) {
+                       sysfs_remove_link(&pal->device->kobj, "uwb_rc");
+                       return ret;
+               }
+       }
+
        spin_lock(&rc->pal_lock);
        list_add(&pal->node, &rc->pals);
        spin_unlock(&rc->pal_lock);
@@ -57,6 +72,11 @@ void uwb_pal_unregister(struct uwb_rc *rc, struct uwb_pal *pal)
        spin_lock(&rc->pal_lock);
        list_del(&pal->node);
        spin_unlock(&rc->pal_lock);
+
+       if (pal->device) {
+               sysfs_remove_link(&rc->uwb_dev.dev.kobj, pal->name);
+               sysfs_remove_link(&pal->device->kobj, "uwb_rc");
+       }
 }
 EXPORT_SYMBOL_GPL(uwb_pal_unregister);
 
index 0cd35937e1203c3f146dd3f86ce6f8c7628e5a27..f9ccbd9a2ced4fd832d6b7c12e7d687c7bcba545 100644 (file)
@@ -361,6 +361,9 @@ struct uwb_rc {
 
 /**
  * struct uwb_pal - a UWB PAL
+ * @name:    descriptive name for this PAL (wushc, wlp, etc.).
+ * @device:  a device for the PAL.  Used to link the PAL and the radio
+ *           controller in sysfs.
  * @new_rsv: called when a peer requests a reservation (may be NULL if
  *           the PAL cannot accept reservation requests).
  *
@@ -379,7 +382,8 @@ struct uwb_rc {
  */
 struct uwb_pal {
        struct list_head node;
-
+       const char *name;
+       struct device *device;
        void (*new_rsv)(struct uwb_rsv *rsv);
 };