uwb: add symlinks in sysfs between radio controllers and PALs
[linux-2.6.git] / drivers / uwb / pal.c
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);