diff options
-rw-r--r-- | drivers/base/attribute_container.c | 14 | ||||
-rw-r--r-- | include/linux/attribute_container.h | 1 |
2 files changed, 13 insertions, 2 deletions
diff --git a/drivers/base/attribute_container.c b/drivers/base/attribute_container.c index 7370d7cf5988..5bf25c6f966c 100644 --- a/drivers/base/attribute_container.c +++ b/drivers/base/attribute_container.c | |||
@@ -320,9 +320,14 @@ attribute_container_add_attrs(struct class_device *classdev) | |||
320 | struct class_device_attribute **attrs = cont->attrs; | 320 | struct class_device_attribute **attrs = cont->attrs; |
321 | int i, error; | 321 | int i, error; |
322 | 322 | ||
323 | if (!attrs) | 323 | BUG_ON(attrs && cont->grp); |
324 | |||
325 | if (!attrs && !cont->grp) | ||
324 | return 0; | 326 | return 0; |
325 | 327 | ||
328 | if (cont->grp) | ||
329 | return sysfs_create_group(&classdev->kobj, cont->grp); | ||
330 | |||
326 | for (i = 0; attrs[i]; i++) { | 331 | for (i = 0; attrs[i]; i++) { |
327 | error = class_device_create_file(classdev, attrs[i]); | 332 | error = class_device_create_file(classdev, attrs[i]); |
328 | if (error) | 333 | if (error) |
@@ -378,9 +383,14 @@ attribute_container_remove_attrs(struct class_device *classdev) | |||
378 | struct class_device_attribute **attrs = cont->attrs; | 383 | struct class_device_attribute **attrs = cont->attrs; |
379 | int i; | 384 | int i; |
380 | 385 | ||
381 | if (!attrs) | 386 | if (!attrs && !cont->grp) |
382 | return; | 387 | return; |
383 | 388 | ||
389 | if (cont->grp) { | ||
390 | sysfs_remove_group(&classdev->kobj, cont->grp); | ||
391 | return ; | ||
392 | } | ||
393 | |||
384 | for (i = 0; attrs[i]; i++) | 394 | for (i = 0; attrs[i]; i++) |
385 | class_device_remove_file(classdev, attrs[i]); | 395 | class_device_remove_file(classdev, attrs[i]); |
386 | } | 396 | } |
diff --git a/include/linux/attribute_container.h b/include/linux/attribute_container.h index 8ff274933948..f5582332af04 100644 --- a/include/linux/attribute_container.h +++ b/include/linux/attribute_container.h | |||
@@ -17,6 +17,7 @@ struct attribute_container { | |||
17 | struct list_head node; | 17 | struct list_head node; |
18 | struct klist containers; | 18 | struct klist containers; |
19 | struct class *class; | 19 | struct class *class; |
20 | struct attribute_group *grp; | ||
20 | struct class_device_attribute **attrs; | 21 | struct class_device_attribute **attrs; |
21 | int (*match)(struct attribute_container *, struct device *); | 22 | int (*match)(struct attribute_container *, struct device *); |
22 | #define ATTRIBUTE_CONTAINER_NO_CLASSDEVS 0x01 | 23 | #define ATTRIBUTE_CONTAINER_NO_CLASSDEVS 0x01 |