diff options
author | Greg Kroah-Hartman <gregkh@suse.de> | 2006-06-27 03:06:09 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2006-09-26 00:08:38 -0400 |
commit | de0ff00d723fd821d372496e2c084805644aa5e1 (patch) | |
tree | d8d8f46f17d84b7b7b40e49e9dd54dcb8f1a2684 /drivers/base/core.c | |
parent | 386415d88b1ae50304f9c61aa3e0db082fa90428 (diff) |
Driver core: add groups support to struct device
This is needed for the network class devices in order to be able to
convert over to use struct device.
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/base/core.c')
-rw-r--r-- | drivers/base/core.c | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/drivers/base/core.c b/drivers/base/core.c index 5d4b7e04471e..641c0c42bb48 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c | |||
@@ -197,6 +197,35 @@ static ssize_t store_uevent(struct device *dev, struct device_attribute *attr, | |||
197 | return count; | 197 | return count; |
198 | } | 198 | } |
199 | 199 | ||
200 | static int device_add_groups(struct device *dev) | ||
201 | { | ||
202 | int i; | ||
203 | int error = 0; | ||
204 | |||
205 | if (dev->groups) { | ||
206 | for (i = 0; dev->groups[i]; i++) { | ||
207 | error = sysfs_create_group(&dev->kobj, dev->groups[i]); | ||
208 | if (error) { | ||
209 | while (--i >= 0) | ||
210 | sysfs_remove_group(&dev->kobj, dev->groups[i]); | ||
211 | goto out; | ||
212 | } | ||
213 | } | ||
214 | } | ||
215 | out: | ||
216 | return error; | ||
217 | } | ||
218 | |||
219 | static void device_remove_groups(struct device *dev) | ||
220 | { | ||
221 | int i; | ||
222 | if (dev->groups) { | ||
223 | for (i = 0; dev->groups[i]; i++) { | ||
224 | sysfs_remove_group(&dev->kobj, dev->groups[i]); | ||
225 | } | ||
226 | } | ||
227 | } | ||
228 | |||
200 | static ssize_t show_dev(struct device *dev, struct device_attribute *attr, | 229 | static ssize_t show_dev(struct device *dev, struct device_attribute *attr, |
201 | char *buf) | 230 | char *buf) |
202 | { | 231 | { |
@@ -350,6 +379,8 @@ int device_add(struct device *dev) | |||
350 | sysfs_create_link(&dev->parent->kobj, &dev->kobj, class_name); | 379 | sysfs_create_link(&dev->parent->kobj, &dev->kobj, class_name); |
351 | } | 380 | } |
352 | 381 | ||
382 | if ((error = device_add_groups(dev))) | ||
383 | goto GroupError; | ||
353 | if ((error = device_pm_add(dev))) | 384 | if ((error = device_pm_add(dev))) |
354 | goto PMError; | 385 | goto PMError; |
355 | if ((error = bus_add_device(dev))) | 386 | if ((error = bus_add_device(dev))) |
@@ -376,6 +407,8 @@ int device_add(struct device *dev) | |||
376 | BusError: | 407 | BusError: |
377 | device_pm_remove(dev); | 408 | device_pm_remove(dev); |
378 | PMError: | 409 | PMError: |
410 | device_remove_groups(dev); | ||
411 | GroupError: | ||
379 | if (dev->devt_attr) { | 412 | if (dev->devt_attr) { |
380 | device_remove_file(dev, dev->devt_attr); | 413 | device_remove_file(dev, dev->devt_attr); |
381 | kfree(dev->devt_attr); | 414 | kfree(dev->devt_attr); |
@@ -470,6 +503,7 @@ void device_del(struct device * dev) | |||
470 | up(&dev->class->sem); | 503 | up(&dev->class->sem); |
471 | } | 504 | } |
472 | device_remove_file(dev, &dev->uevent_attr); | 505 | device_remove_file(dev, &dev->uevent_attr); |
506 | device_remove_groups(dev); | ||
473 | 507 | ||
474 | /* Notify the platform of the removal, in case they | 508 | /* Notify the platform of the removal, in case they |
475 | * need to do anything... | 509 | * need to do anything... |