Skip to content

Commit cbe9c59

Browse files
committed
Driver: add driver_add_kobj for looney iseries_veth driver
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>
1 parent 23b9c1a commit cbe9c59

3 files changed

Lines changed: 29 additions & 1 deletion

File tree

‎drivers/base/driver.c‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,30 @@ void driver_remove_file(struct device_driver * drv, struct driver_attribute * at
123123
}
124124

125125

126+
/**
127+
* driver_add_kobj - add a kobject below the specified driver
128+
*
129+
* You really don't want to do this, this is only here due to one looney
130+
* iseries driver, go poke those developers if you are annoyed about
131+
* this...
132+
*/
133+
int driver_add_kobj(struct device_driver *drv, struct kobject *kobj,
134+
const char *fmt, ...)
135+
{
136+
va_list args;
137+
char *name;
138+
139+
va_start(args, fmt);
140+
name = kvasprintf(GFP_KERNEL, fmt, args);
141+
va_end(args);
142+
143+
if (!name)
144+
return -ENOMEM;
145+
146+
return kobject_add_ng(kobj, &drv->kobj, "%s", name);
147+
}
148+
EXPORT_SYMBOL_GPL(driver_add_kobj);
149+
126150
/**
127151
* get_driver - increment driver reference count.
128152
* @drv: driver.

‎drivers/net/iseries_veth.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1705,7 +1705,7 @@ static int __init veth_module_init(void)
17051705

17061706
kobj = &veth_cnx[i]->kobject;
17071707
/* If the add failes, complain but otherwise continue */
1708-
if (0 != kobject_add_ng(kobj, &veth_driver.driver.kobj,
1708+
if (0 != driver_add_kobj(&veth_driver.driver, kobj,
17091709
"cnx%.2d", veth_cnx[i]->remote_lp))
17101710
veth_error("cnx %d: Failed adding to sysfs.\n", i);
17111711
}

‎include/linux/device.h‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,10 @@ extern int __must_check driver_create_file(struct device_driver *,
156156
struct driver_attribute *);
157157
extern void driver_remove_file(struct device_driver *, struct driver_attribute *);
158158

159+
extern int __must_check driver_add_kobj(struct device_driver *drv,
160+
struct kobject *kobj,
161+
const char *fmt, ...);
162+
159163
extern int __must_check driver_for_each_device(struct device_driver * drv,
160164
struct device *start, void *data,
161165
int (*fn)(struct device *, void *));

0 commit comments

Comments
 (0)