diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2013-09-03 14:37:15 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2013-09-03 14:37:15 -0400 |
commit | 542a086ac72fb193cbc1b996963a572269e57743 (patch) | |
tree | b137c08037cca4ffc8a156a891a01113b3b8edce /drivers/misc | |
parent | 1d1fdd95df681f0c065d90ffaafa215a0e8825e2 (diff) | |
parent | 1eeeef153c02f5856ec109fa532eb5f31c39f85c (diff) |
Merge tag 'driver-core-3.12-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core
Pull driver core patches from Greg KH:
"Here's the big driver core pull request for 3.12-rc1.
Lots of tiny changes here fixing up the way sysfs attributes are
created, to try to make drivers simpler, and fix a whole class race
conditions with creations of device attributes after the device was
announced to userspace.
All the various pieces are acked by the different subsystem
maintainers"
* tag 'driver-core-3.12-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core: (119 commits)
firmware loader: fix pending_fw_head list corruption
drivers/base/memory.c: introduce help macro to_memory_block
dynamic debug: line queries failing due to uninitialized local variable
sysfs: sysfs_create_groups returns a value.
debugfs: provide debugfs_create_x64() when disabled
rbd: convert bus code to use bus_groups
firmware: dcdbas: use binary attribute groups
sysfs: add sysfs_create/remove_groups for when SYSFS is not enabled
driver core: add #include <linux/sysfs.h> to core files.
HID: convert bus code to use dev_groups
Input: serio: convert bus code to use drv_groups
Input: gameport: convert bus code to use drv_groups
driver core: firmware: use __ATTR_RW()
driver core: core: use DEVICE_ATTR_RO
driver core: bus: use DRIVER_ATTR_WO()
driver core: create write-only attribute macros for devices and drivers
sysfs: create __ATTR_WO()
driver-core: platform: convert bus code to use dev_groups
workqueue: convert bus code to use dev_groups
MEI: convert bus code to use dev_groups
...
Diffstat (limited to 'drivers/misc')
-rw-r--r-- | drivers/misc/c2port/core.c | 83 | ||||
-rw-r--r-- | drivers/misc/enclosure.c | 29 | ||||
-rw-r--r-- | drivers/misc/mei/bus.c | 10 |
3 files changed, 62 insertions, 60 deletions
diff --git a/drivers/misc/c2port/core.c b/drivers/misc/c2port/core.c index f32550a74bdd..464419b36440 100644 --- a/drivers/misc/c2port/core.c +++ b/drivers/misc/c2port/core.c | |||
@@ -311,6 +311,7 @@ static ssize_t c2port_show_name(struct device *dev, | |||
311 | 311 | ||
312 | return sprintf(buf, "%s\n", c2dev->name); | 312 | return sprintf(buf, "%s\n", c2dev->name); |
313 | } | 313 | } |
314 | static DEVICE_ATTR(name, 0444, c2port_show_name, NULL); | ||
314 | 315 | ||
315 | static ssize_t c2port_show_flash_blocks_num(struct device *dev, | 316 | static ssize_t c2port_show_flash_blocks_num(struct device *dev, |
316 | struct device_attribute *attr, char *buf) | 317 | struct device_attribute *attr, char *buf) |
@@ -320,6 +321,7 @@ static ssize_t c2port_show_flash_blocks_num(struct device *dev, | |||
320 | 321 | ||
321 | return sprintf(buf, "%d\n", ops->blocks_num); | 322 | return sprintf(buf, "%d\n", ops->blocks_num); |
322 | } | 323 | } |
324 | static DEVICE_ATTR(flash_blocks_num, 0444, c2port_show_flash_blocks_num, NULL); | ||
323 | 325 | ||
324 | static ssize_t c2port_show_flash_block_size(struct device *dev, | 326 | static ssize_t c2port_show_flash_block_size(struct device *dev, |
325 | struct device_attribute *attr, char *buf) | 327 | struct device_attribute *attr, char *buf) |
@@ -329,6 +331,7 @@ static ssize_t c2port_show_flash_block_size(struct device *dev, | |||
329 | 331 | ||
330 | return sprintf(buf, "%d\n", ops->block_size); | 332 | return sprintf(buf, "%d\n", ops->block_size); |
331 | } | 333 | } |
334 | static DEVICE_ATTR(flash_block_size, 0444, c2port_show_flash_block_size, NULL); | ||
332 | 335 | ||
333 | static ssize_t c2port_show_flash_size(struct device *dev, | 336 | static ssize_t c2port_show_flash_size(struct device *dev, |
334 | struct device_attribute *attr, char *buf) | 337 | struct device_attribute *attr, char *buf) |
@@ -338,18 +341,18 @@ static ssize_t c2port_show_flash_size(struct device *dev, | |||
338 | 341 | ||
339 | return sprintf(buf, "%d\n", ops->blocks_num * ops->block_size); | 342 | return sprintf(buf, "%d\n", ops->blocks_num * ops->block_size); |
340 | } | 343 | } |
344 | static DEVICE_ATTR(flash_size, 0444, c2port_show_flash_size, NULL); | ||
341 | 345 | ||
342 | static ssize_t c2port_show_access(struct device *dev, | 346 | static ssize_t access_show(struct device *dev, struct device_attribute *attr, |
343 | struct device_attribute *attr, char *buf) | 347 | char *buf) |
344 | { | 348 | { |
345 | struct c2port_device *c2dev = dev_get_drvdata(dev); | 349 | struct c2port_device *c2dev = dev_get_drvdata(dev); |
346 | 350 | ||
347 | return sprintf(buf, "%d\n", c2dev->access); | 351 | return sprintf(buf, "%d\n", c2dev->access); |
348 | } | 352 | } |
349 | 353 | ||
350 | static ssize_t c2port_store_access(struct device *dev, | 354 | static ssize_t access_store(struct device *dev, struct device_attribute *attr, |
351 | struct device_attribute *attr, | 355 | const char *buf, size_t count) |
352 | const char *buf, size_t count) | ||
353 | { | 356 | { |
354 | struct c2port_device *c2dev = dev_get_drvdata(dev); | 357 | struct c2port_device *c2dev = dev_get_drvdata(dev); |
355 | struct c2port_ops *ops = c2dev->ops; | 358 | struct c2port_ops *ops = c2dev->ops; |
@@ -375,6 +378,7 @@ static ssize_t c2port_store_access(struct device *dev, | |||
375 | 378 | ||
376 | return count; | 379 | return count; |
377 | } | 380 | } |
381 | static DEVICE_ATTR_RW(access); | ||
378 | 382 | ||
379 | static ssize_t c2port_store_reset(struct device *dev, | 383 | static ssize_t c2port_store_reset(struct device *dev, |
380 | struct device_attribute *attr, | 384 | struct device_attribute *attr, |
@@ -395,6 +399,7 @@ static ssize_t c2port_store_reset(struct device *dev, | |||
395 | 399 | ||
396 | return count; | 400 | return count; |
397 | } | 401 | } |
402 | static DEVICE_ATTR(reset, 0200, NULL, c2port_store_reset); | ||
398 | 403 | ||
399 | static ssize_t __c2port_show_dev_id(struct c2port_device *dev, char *buf) | 404 | static ssize_t __c2port_show_dev_id(struct c2port_device *dev, char *buf) |
400 | { | 405 | { |
@@ -431,6 +436,7 @@ static ssize_t c2port_show_dev_id(struct device *dev, | |||
431 | 436 | ||
432 | return ret; | 437 | return ret; |
433 | } | 438 | } |
439 | static DEVICE_ATTR(dev_id, 0444, c2port_show_dev_id, NULL); | ||
434 | 440 | ||
435 | static ssize_t __c2port_show_rev_id(struct c2port_device *dev, char *buf) | 441 | static ssize_t __c2port_show_rev_id(struct c2port_device *dev, char *buf) |
436 | { | 442 | { |
@@ -467,6 +473,7 @@ static ssize_t c2port_show_rev_id(struct device *dev, | |||
467 | 473 | ||
468 | return ret; | 474 | return ret; |
469 | } | 475 | } |
476 | static DEVICE_ATTR(rev_id, 0444, c2port_show_rev_id, NULL); | ||
470 | 477 | ||
471 | static ssize_t c2port_show_flash_access(struct device *dev, | 478 | static ssize_t c2port_show_flash_access(struct device *dev, |
472 | struct device_attribute *attr, char *buf) | 479 | struct device_attribute *attr, char *buf) |
@@ -536,6 +543,8 @@ static ssize_t c2port_store_flash_access(struct device *dev, | |||
536 | 543 | ||
537 | return count; | 544 | return count; |
538 | } | 545 | } |
546 | static DEVICE_ATTR(flash_access, 0644, c2port_show_flash_access, | ||
547 | c2port_store_flash_access); | ||
539 | 548 | ||
540 | static ssize_t __c2port_write_flash_erase(struct c2port_device *dev) | 549 | static ssize_t __c2port_write_flash_erase(struct c2port_device *dev) |
541 | { | 550 | { |
@@ -616,6 +625,7 @@ static ssize_t c2port_store_flash_erase(struct device *dev, | |||
616 | 625 | ||
617 | return count; | 626 | return count; |
618 | } | 627 | } |
628 | static DEVICE_ATTR(flash_erase, 0200, NULL, c2port_store_flash_erase); | ||
619 | 629 | ||
620 | static ssize_t __c2port_read_flash_data(struct c2port_device *dev, | 630 | static ssize_t __c2port_read_flash_data(struct c2port_device *dev, |
621 | char *buffer, loff_t offset, size_t count) | 631 | char *buffer, loff_t offset, size_t count) |
@@ -846,35 +856,40 @@ static ssize_t c2port_write_flash_data(struct file *filp, struct kobject *kobj, | |||
846 | 856 | ||
847 | return ret; | 857 | return ret; |
848 | } | 858 | } |
859 | /* size is computed at run-time */ | ||
860 | static BIN_ATTR(flash_data, 0644, c2port_read_flash_data, | ||
861 | c2port_write_flash_data, 0); | ||
849 | 862 | ||
850 | /* | 863 | /* |
851 | * Class attributes | 864 | * Class attributes |
852 | */ | 865 | */ |
866 | static struct attribute *c2port_attrs[] = { | ||
867 | &dev_attr_name.attr, | ||
868 | &dev_attr_flash_blocks_num.attr, | ||
869 | &dev_attr_flash_block_size.attr, | ||
870 | &dev_attr_flash_size.attr, | ||
871 | &dev_attr_access.attr, | ||
872 | &dev_attr_reset.attr, | ||
873 | &dev_attr_dev_id.attr, | ||
874 | &dev_attr_rev_id.attr, | ||
875 | &dev_attr_flash_access.attr, | ||
876 | &dev_attr_flash_erase.attr, | ||
877 | NULL, | ||
878 | }; | ||
853 | 879 | ||
854 | static struct device_attribute c2port_attrs[] = { | 880 | static struct bin_attribute *c2port_bin_attrs[] = { |
855 | __ATTR(name, 0444, c2port_show_name, NULL), | 881 | &bin_attr_flash_data, |
856 | __ATTR(flash_blocks_num, 0444, c2port_show_flash_blocks_num, NULL), | 882 | NULL, |
857 | __ATTR(flash_block_size, 0444, c2port_show_flash_block_size, NULL), | ||
858 | __ATTR(flash_size, 0444, c2port_show_flash_size, NULL), | ||
859 | __ATTR(access, 0644, c2port_show_access, c2port_store_access), | ||
860 | __ATTR(reset, 0200, NULL, c2port_store_reset), | ||
861 | __ATTR(dev_id, 0444, c2port_show_dev_id, NULL), | ||
862 | __ATTR(rev_id, 0444, c2port_show_rev_id, NULL), | ||
863 | |||
864 | __ATTR(flash_access, 0644, c2port_show_flash_access, | ||
865 | c2port_store_flash_access), | ||
866 | __ATTR(flash_erase, 0200, NULL, c2port_store_flash_erase), | ||
867 | __ATTR_NULL, | ||
868 | }; | 883 | }; |
869 | 884 | ||
870 | static struct bin_attribute c2port_bin_attrs = { | 885 | static const struct attribute_group c2port_group = { |
871 | .attr = { | 886 | .attrs = c2port_attrs, |
872 | .name = "flash_data", | 887 | .bin_attrs = c2port_bin_attrs, |
873 | .mode = 0644 | 888 | }; |
874 | }, | 889 | |
875 | .read = c2port_read_flash_data, | 890 | static const struct attribute_group *c2port_groups[] = { |
876 | .write = c2port_write_flash_data, | 891 | &c2port_group, |
877 | /* .size is computed at run-time */ | 892 | NULL, |
878 | }; | 893 | }; |
879 | 894 | ||
880 | /* | 895 | /* |
@@ -907,6 +922,8 @@ struct c2port_device *c2port_device_register(char *name, | |||
907 | goto error_idr_alloc; | 922 | goto error_idr_alloc; |
908 | c2dev->id = ret; | 923 | c2dev->id = ret; |
909 | 924 | ||
925 | bin_attr_flash_data.size = ops->blocks_num * ops->block_size; | ||
926 | |||
910 | c2dev->dev = device_create(c2port_class, NULL, 0, c2dev, | 927 | c2dev->dev = device_create(c2port_class, NULL, 0, c2dev, |
911 | "c2port%d", c2dev->id); | 928 | "c2port%d", c2dev->id); |
912 | if (unlikely(IS_ERR(c2dev->dev))) { | 929 | if (unlikely(IS_ERR(c2dev->dev))) { |
@@ -919,12 +936,6 @@ struct c2port_device *c2port_device_register(char *name, | |||
919 | c2dev->ops = ops; | 936 | c2dev->ops = ops; |
920 | mutex_init(&c2dev->mutex); | 937 | mutex_init(&c2dev->mutex); |
921 | 938 | ||
922 | /* Create binary file */ | ||
923 | c2port_bin_attrs.size = ops->blocks_num * ops->block_size; | ||
924 | ret = device_create_bin_file(c2dev->dev, &c2port_bin_attrs); | ||
925 | if (unlikely(ret)) | ||
926 | goto error_device_create_bin_file; | ||
927 | |||
928 | /* By default C2 port access is off */ | 939 | /* By default C2 port access is off */ |
929 | c2dev->access = c2dev->flash_access = 0; | 940 | c2dev->access = c2dev->flash_access = 0; |
930 | ops->access(c2dev, 0); | 941 | ops->access(c2dev, 0); |
@@ -937,9 +948,6 @@ struct c2port_device *c2port_device_register(char *name, | |||
937 | 948 | ||
938 | return c2dev; | 949 | return c2dev; |
939 | 950 | ||
940 | error_device_create_bin_file: | ||
941 | device_destroy(c2port_class, 0); | ||
942 | |||
943 | error_device_create: | 951 | error_device_create: |
944 | spin_lock_irq(&c2port_idr_lock); | 952 | spin_lock_irq(&c2port_idr_lock); |
945 | idr_remove(&c2port_idr, c2dev->id); | 953 | idr_remove(&c2port_idr, c2dev->id); |
@@ -959,7 +967,6 @@ void c2port_device_unregister(struct c2port_device *c2dev) | |||
959 | 967 | ||
960 | dev_info(c2dev->dev, "C2 port %s removed\n", c2dev->name); | 968 | dev_info(c2dev->dev, "C2 port %s removed\n", c2dev->name); |
961 | 969 | ||
962 | device_remove_bin_file(c2dev->dev, &c2port_bin_attrs); | ||
963 | spin_lock_irq(&c2port_idr_lock); | 970 | spin_lock_irq(&c2port_idr_lock); |
964 | idr_remove(&c2port_idr, c2dev->id); | 971 | idr_remove(&c2port_idr, c2dev->id); |
965 | spin_unlock_irq(&c2port_idr_lock); | 972 | spin_unlock_irq(&c2port_idr_lock); |
@@ -984,7 +991,7 @@ static int __init c2port_init(void) | |||
984 | printk(KERN_ERR "c2port: failed to allocate class\n"); | 991 | printk(KERN_ERR "c2port: failed to allocate class\n"); |
985 | return PTR_ERR(c2port_class); | 992 | return PTR_ERR(c2port_class); |
986 | } | 993 | } |
987 | c2port_class->dev_attrs = c2port_attrs; | 994 | c2port_class->dev_groups = c2port_groups; |
988 | 995 | ||
989 | return 0; | 996 | return 0; |
990 | } | 997 | } |
diff --git a/drivers/misc/enclosure.c b/drivers/misc/enclosure.c index 00e5fcac8fdf..0e8df41aaf14 100644 --- a/drivers/misc/enclosure.c +++ b/drivers/misc/enclosure.c | |||
@@ -239,7 +239,7 @@ static void enclosure_component_release(struct device *dev) | |||
239 | put_device(dev->parent); | 239 | put_device(dev->parent); |
240 | } | 240 | } |
241 | 241 | ||
242 | static const struct attribute_group *enclosure_groups[]; | 242 | static const struct attribute_group *enclosure_component_groups[]; |
243 | 243 | ||
244 | /** | 244 | /** |
245 | * enclosure_component_register - add a particular component to an enclosure | 245 | * enclosure_component_register - add a particular component to an enclosure |
@@ -282,7 +282,7 @@ enclosure_component_register(struct enclosure_device *edev, | |||
282 | dev_set_name(cdev, "%u", number); | 282 | dev_set_name(cdev, "%u", number); |
283 | 283 | ||
284 | cdev->release = enclosure_component_release; | 284 | cdev->release = enclosure_component_release; |
285 | cdev->groups = enclosure_groups; | 285 | cdev->groups = enclosure_component_groups; |
286 | 286 | ||
287 | err = device_register(cdev); | 287 | err = device_register(cdev); |
288 | if (err) { | 288 | if (err) { |
@@ -365,25 +365,26 @@ EXPORT_SYMBOL_GPL(enclosure_remove_device); | |||
365 | * sysfs pieces below | 365 | * sysfs pieces below |
366 | */ | 366 | */ |
367 | 367 | ||
368 | static ssize_t enclosure_show_components(struct device *cdev, | 368 | static ssize_t components_show(struct device *cdev, |
369 | struct device_attribute *attr, | 369 | struct device_attribute *attr, char *buf) |
370 | char *buf) | ||
371 | { | 370 | { |
372 | struct enclosure_device *edev = to_enclosure_device(cdev); | 371 | struct enclosure_device *edev = to_enclosure_device(cdev); |
373 | 372 | ||
374 | return snprintf(buf, 40, "%d\n", edev->components); | 373 | return snprintf(buf, 40, "%d\n", edev->components); |
375 | } | 374 | } |
375 | static DEVICE_ATTR_RO(components); | ||
376 | 376 | ||
377 | static struct device_attribute enclosure_attrs[] = { | 377 | static struct attribute *enclosure_class_attrs[] = { |
378 | __ATTR(components, S_IRUGO, enclosure_show_components, NULL), | 378 | &dev_attr_components.attr, |
379 | __ATTR_NULL | 379 | NULL, |
380 | }; | 380 | }; |
381 | ATTRIBUTE_GROUPS(enclosure_class); | ||
381 | 382 | ||
382 | static struct class enclosure_class = { | 383 | static struct class enclosure_class = { |
383 | .name = "enclosure", | 384 | .name = "enclosure", |
384 | .owner = THIS_MODULE, | 385 | .owner = THIS_MODULE, |
385 | .dev_release = enclosure_release, | 386 | .dev_release = enclosure_release, |
386 | .dev_attrs = enclosure_attrs, | 387 | .dev_groups = enclosure_class_groups, |
387 | }; | 388 | }; |
388 | 389 | ||
389 | static const char *const enclosure_status [] = { | 390 | static const char *const enclosure_status [] = { |
@@ -536,15 +537,7 @@ static struct attribute *enclosure_component_attrs[] = { | |||
536 | &dev_attr_type.attr, | 537 | &dev_attr_type.attr, |
537 | NULL | 538 | NULL |
538 | }; | 539 | }; |
539 | 540 | ATTRIBUTE_GROUPS(enclosure_component); | |
540 | static struct attribute_group enclosure_group = { | ||
541 | .attrs = enclosure_component_attrs, | ||
542 | }; | ||
543 | |||
544 | static const struct attribute_group *enclosure_groups[] = { | ||
545 | &enclosure_group, | ||
546 | NULL | ||
547 | }; | ||
548 | 541 | ||
549 | static int __init enclosure_init(void) | 542 | static int __init enclosure_init(void) |
550 | { | 543 | { |
diff --git a/drivers/misc/mei/bus.c b/drivers/misc/mei/bus.c index a150a42ed4af..6d0282c08a06 100644 --- a/drivers/misc/mei/bus.c +++ b/drivers/misc/mei/bus.c | |||
@@ -108,11 +108,13 @@ static ssize_t modalias_show(struct device *dev, struct device_attribute *a, | |||
108 | 108 | ||
109 | return (len >= PAGE_SIZE) ? (PAGE_SIZE - 1) : len; | 109 | return (len >= PAGE_SIZE) ? (PAGE_SIZE - 1) : len; |
110 | } | 110 | } |
111 | static DEVICE_ATTR_RO(modalias); | ||
111 | 112 | ||
112 | static struct device_attribute mei_cl_dev_attrs[] = { | 113 | static struct attribute *mei_cl_dev_attrs[] = { |
113 | __ATTR_RO(modalias), | 114 | &dev_attr_modalias.attr, |
114 | __ATTR_NULL, | 115 | NULL, |
115 | }; | 116 | }; |
117 | ATTRIBUTE_GROUPS(mei_cl_dev); | ||
116 | 118 | ||
117 | static int mei_cl_uevent(struct device *dev, struct kobj_uevent_env *env) | 119 | static int mei_cl_uevent(struct device *dev, struct kobj_uevent_env *env) |
118 | { | 120 | { |
@@ -124,7 +126,7 @@ static int mei_cl_uevent(struct device *dev, struct kobj_uevent_env *env) | |||
124 | 126 | ||
125 | static struct bus_type mei_cl_bus_type = { | 127 | static struct bus_type mei_cl_bus_type = { |
126 | .name = "mei", | 128 | .name = "mei", |
127 | .dev_attrs = mei_cl_dev_attrs, | 129 | .dev_groups = mei_cl_dev_groups, |
128 | .match = mei_cl_device_match, | 130 | .match = mei_cl_device_match, |
129 | .probe = mei_cl_device_probe, | 131 | .probe = mei_cl_device_probe, |
130 | .remove = mei_cl_device_remove, | 132 | .remove = mei_cl_device_remove, |