Driver: add driver_add_kobj for looney iseries_veth driver
authorGreg Kroah-Hartman <gregkh@suse.de>
Wed, 19 Dec 2007 19:54:39 +0000 (15:54 -0400)
committerGreg Kroah-Hartman <gregkh@suse.de>
Fri, 25 Jan 2008 04:40:34 +0000 (20:40 -0800)
The iseries driver wants to hang kobjects off of its driver, so, to
preserve backwards compatibility, we need to add a call to the driver
core to allow future changes to work properly.

Hopefully no one uses this function in the future and the iseries_veth
driver authors come to their senses so I can remove this hack...

Cc: Dave Larson <larson1@us.ibm.com>
Cc: Santiago Leon <santil@us.ibm.com>
Cc: Kay Sievers <kay.sievers@vrfy.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/base/driver.c
drivers/net/iseries_veth.c
include/linux/device.h

index e3b58407fedc3a14f7201aec56048929a74ddf71..633ae1d70e141875b8f94c5a7ed99c6198b6b3ca 100644 (file)
@@ -123,6 +123,30 @@ void driver_remove_file(struct device_driver * drv, struct driver_attribute * at
 }
 
 
+/**
+ * driver_add_kobj - add a kobject below the specified driver
+ *
+ * You really don't want to do this, this is only here due to one looney
+ * iseries driver, go poke those developers if you are annoyed about
+ * this...
+ */
+int driver_add_kobj(struct device_driver *drv, struct kobject *kobj,
+                   const char *fmt, ...)
+{
+       va_list args;
+       char *name;
+
+       va_start(args, fmt);
+       name = kvasprintf(GFP_KERNEL, fmt, args);
+       va_end(args);
+
+       if (!name)
+               return -ENOMEM;
+
+       return kobject_add_ng(kobj, &drv->kobj, "%s", name);
+}
+EXPORT_SYMBOL_GPL(driver_add_kobj);
+
 /**
  *     get_driver - increment driver reference count.
  *     @drv:   driver.
index 90ff4ec5f6fc66bf6044899919f24970411cad8d..1a8299acd3f1db8bda8b47678fa6e002c3e5ab09 100644 (file)
@@ -1705,7 +1705,7 @@ static int __init veth_module_init(void)
 
                kobj = &veth_cnx[i]->kobject;
                /* If the add failes, complain but otherwise continue */
-               if (0 != kobject_add_ng(kobj, &veth_driver.driver.kobj,
+               if (0 != driver_add_kobj(&veth_driver.driver, kobj,
                                        "cnx%.2d", veth_cnx[i]->remote_lp))
                        veth_error("cnx %d: Failed adding to sysfs.\n", i);
        }
index d974dda4aa512005fcb9dbf421a580ab08c5c3ce..721ee318d57bce29a0c2c97ff6112377ea5e009e 100644 (file)
@@ -156,6 +156,10 @@ extern int __must_check driver_create_file(struct device_driver *,
                                        struct driver_attribute *);
 extern void driver_remove_file(struct device_driver *, struct driver_attribute *);
 
+extern int __must_check driver_add_kobj(struct device_driver *drv,
+                                       struct kobject *kobj,
+                                       const char *fmt, ...);
+
 extern int __must_check driver_for_each_device(struct device_driver * drv,
                struct device *start, void *data,
                int (*fn)(struct device *, void *));