diff options
author | Andi Kleen <andi@firstfloor.org> | 2010-01-05 06:48:09 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2010-03-07 20:04:48 -0500 |
commit | 0933e2d98d1b170ef62d48e18157f5dc43b58217 (patch) | |
tree | ecbd589b7607cda35743faf65c8f4326fc8373dd /drivers | |
parent | 869dfc875e32fd832385fd52ce54525a10401ed6 (diff) |
driver core: Convert some drivers to CLASS_ATTR_STRING
Convert some drivers who export a single string as class attribute
to the new class_attr_string functions. This removes redundant
code all over.
Signed-off-by: Andi Kleen <ak@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/gpu/drm/drm_sysfs.c | 19 | ||||
-rw-r--r-- | drivers/infiniband/core/ucm.c | 15 | ||||
-rw-r--r-- | drivers/infiniband/core/user_mad.c | 11 | ||||
-rw-r--r-- | drivers/infiniband/core/uverbs_main.c | 11 | ||||
-rw-r--r-- | drivers/misc/phantom.c | 13 | ||||
-rw-r--r-- | drivers/staging/asus_oled/asus_oled.c | 15 |
6 files changed, 27 insertions, 57 deletions
diff --git a/drivers/gpu/drm/drm_sysfs.c b/drivers/gpu/drm/drm_sysfs.c index b95aaf23596e..014ce24761b9 100644 --- a/drivers/gpu/drm/drm_sysfs.c +++ b/drivers/gpu/drm/drm_sysfs.c | |||
@@ -70,20 +70,17 @@ static int drm_class_resume(struct device *dev) | |||
70 | return 0; | 70 | return 0; |
71 | } | 71 | } |
72 | 72 | ||
73 | /* Display the version of drm_core. This doesn't work right in current design */ | ||
74 | static ssize_t version_show(struct class *dev, struct class_attribute *attr, | ||
75 | char *buf) | ||
76 | { | ||
77 | return sprintf(buf, "%s %d.%d.%d %s\n", CORE_NAME, CORE_MAJOR, | ||
78 | CORE_MINOR, CORE_PATCHLEVEL, CORE_DATE); | ||
79 | } | ||
80 | |||
81 | static char *drm_devnode(struct device *dev, mode_t *mode) | 73 | static char *drm_devnode(struct device *dev, mode_t *mode) |
82 | { | 74 | { |
83 | return kasprintf(GFP_KERNEL, "dri/%s", dev_name(dev)); | 75 | return kasprintf(GFP_KERNEL, "dri/%s", dev_name(dev)); |
84 | } | 76 | } |
85 | 77 | ||
86 | static CLASS_ATTR(version, S_IRUGO, version_show, NULL); | 78 | static CLASS_ATTR_STRING(version, S_IRUGO, |
79 | CORE_NAME " " | ||
80 | __stringify(CORE_MAJOR) "." | ||
81 | __stringify(CORE_MINOR) "." | ||
82 | __stringify(CORE_PATCHLEVEL) " " | ||
83 | CORE_DATE); | ||
87 | 84 | ||
88 | /** | 85 | /** |
89 | * drm_sysfs_create - create a struct drm_sysfs_class structure | 86 | * drm_sysfs_create - create a struct drm_sysfs_class structure |
@@ -110,7 +107,7 @@ struct class *drm_sysfs_create(struct module *owner, char *name) | |||
110 | class->suspend = drm_class_suspend; | 107 | class->suspend = drm_class_suspend; |
111 | class->resume = drm_class_resume; | 108 | class->resume = drm_class_resume; |
112 | 109 | ||
113 | err = class_create_file(class, &class_attr_version); | 110 | err = class_create_file(class, &class_attr_version.attr); |
114 | if (err) | 111 | if (err) |
115 | goto err_out_class; | 112 | goto err_out_class; |
116 | 113 | ||
@@ -133,7 +130,7 @@ void drm_sysfs_destroy(void) | |||
133 | { | 130 | { |
134 | if ((drm_class == NULL) || (IS_ERR(drm_class))) | 131 | if ((drm_class == NULL) || (IS_ERR(drm_class))) |
135 | return; | 132 | return; |
136 | class_remove_file(drm_class, &class_attr_version); | 133 | class_remove_file(drm_class, &class_attr_version.attr); |
137 | class_destroy(drm_class); | 134 | class_destroy(drm_class); |
138 | } | 135 | } |
139 | 136 | ||
diff --git a/drivers/infiniband/core/ucm.c b/drivers/infiniband/core/ucm.c index 02e209ff33fd..017d6e24448f 100644 --- a/drivers/infiniband/core/ucm.c +++ b/drivers/infiniband/core/ucm.c | |||
@@ -1336,13 +1336,8 @@ static void ib_ucm_remove_one(struct ib_device *device) | |||
1336 | device_unregister(&ucm_dev->dev); | 1336 | device_unregister(&ucm_dev->dev); |
1337 | } | 1337 | } |
1338 | 1338 | ||
1339 | static ssize_t show_abi_version(struct class *class, | 1339 | static CLASS_ATTR_STRING(abi_version, S_IRUGO, |
1340 | struct class_attribute *attr, | 1340 | __stringify(IB_USER_CM_ABI_VERSION)); |
1341 | char *buf) | ||
1342 | { | ||
1343 | return sprintf(buf, "%d\n", IB_USER_CM_ABI_VERSION); | ||
1344 | } | ||
1345 | static CLASS_ATTR(abi_version, S_IRUGO, show_abi_version, NULL); | ||
1346 | 1341 | ||
1347 | static int __init ib_ucm_init(void) | 1342 | static int __init ib_ucm_init(void) |
1348 | { | 1343 | { |
@@ -1355,7 +1350,7 @@ static int __init ib_ucm_init(void) | |||
1355 | goto error1; | 1350 | goto error1; |
1356 | } | 1351 | } |
1357 | 1352 | ||
1358 | ret = class_create_file(&cm_class, &class_attr_abi_version); | 1353 | ret = class_create_file(&cm_class, &class_attr_abi_version.attr); |
1359 | if (ret) { | 1354 | if (ret) { |
1360 | printk(KERN_ERR "ucm: couldn't create abi_version attribute\n"); | 1355 | printk(KERN_ERR "ucm: couldn't create abi_version attribute\n"); |
1361 | goto error2; | 1356 | goto error2; |
@@ -1369,7 +1364,7 @@ static int __init ib_ucm_init(void) | |||
1369 | return 0; | 1364 | return 0; |
1370 | 1365 | ||
1371 | error3: | 1366 | error3: |
1372 | class_remove_file(&cm_class, &class_attr_abi_version); | 1367 | class_remove_file(&cm_class, &class_attr_abi_version.attr); |
1373 | error2: | 1368 | error2: |
1374 | unregister_chrdev_region(IB_UCM_BASE_DEV, IB_UCM_MAX_DEVICES); | 1369 | unregister_chrdev_region(IB_UCM_BASE_DEV, IB_UCM_MAX_DEVICES); |
1375 | error1: | 1370 | error1: |
@@ -1379,7 +1374,7 @@ error1: | |||
1379 | static void __exit ib_ucm_cleanup(void) | 1374 | static void __exit ib_ucm_cleanup(void) |
1380 | { | 1375 | { |
1381 | ib_unregister_client(&ucm_client); | 1376 | ib_unregister_client(&ucm_client); |
1382 | class_remove_file(&cm_class, &class_attr_abi_version); | 1377 | class_remove_file(&cm_class, &class_attr_abi_version.attr); |
1383 | unregister_chrdev_region(IB_UCM_BASE_DEV, IB_UCM_MAX_DEVICES); | 1378 | unregister_chrdev_region(IB_UCM_BASE_DEV, IB_UCM_MAX_DEVICES); |
1384 | if (overflow_maj) | 1379 | if (overflow_maj) |
1385 | unregister_chrdev_region(overflow_maj, IB_UCM_MAX_DEVICES); | 1380 | unregister_chrdev_region(overflow_maj, IB_UCM_MAX_DEVICES); |
diff --git a/drivers/infiniband/core/user_mad.c b/drivers/infiniband/core/user_mad.c index d0de8f265f45..04b585e86cb2 100644 --- a/drivers/infiniband/core/user_mad.c +++ b/drivers/infiniband/core/user_mad.c | |||
@@ -965,13 +965,8 @@ static ssize_t show_port(struct device *dev, struct device_attribute *attr, | |||
965 | } | 965 | } |
966 | static DEVICE_ATTR(port, S_IRUGO, show_port, NULL); | 966 | static DEVICE_ATTR(port, S_IRUGO, show_port, NULL); |
967 | 967 | ||
968 | static ssize_t show_abi_version(struct class *class, | 968 | static CLASS_ATTR_STRING(abi_version, S_IRUGO, |
969 | struct class_attribute *attr, | 969 | __stringify(IB_USER_MAD_ABI_VERSION)); |
970 | char *buf) | ||
971 | { | ||
972 | return sprintf(buf, "%d\n", IB_USER_MAD_ABI_VERSION); | ||
973 | } | ||
974 | static CLASS_ATTR(abi_version, S_IRUGO, show_abi_version, NULL); | ||
975 | 970 | ||
976 | static dev_t overflow_maj; | 971 | static dev_t overflow_maj; |
977 | static DECLARE_BITMAP(overflow_map, IB_UMAD_MAX_PORTS); | 972 | static DECLARE_BITMAP(overflow_map, IB_UMAD_MAX_PORTS); |
@@ -1196,7 +1191,7 @@ static int __init ib_umad_init(void) | |||
1196 | goto out_chrdev; | 1191 | goto out_chrdev; |
1197 | } | 1192 | } |
1198 | 1193 | ||
1199 | ret = class_create_file(umad_class, &class_attr_abi_version); | 1194 | ret = class_create_file(umad_class, &class_attr_abi_version.attr); |
1200 | if (ret) { | 1195 | if (ret) { |
1201 | printk(KERN_ERR "user_mad: couldn't create abi_version attribute\n"); | 1196 | printk(KERN_ERR "user_mad: couldn't create abi_version attribute\n"); |
1202 | goto out_class; | 1197 | goto out_class; |
diff --git a/drivers/infiniband/core/uverbs_main.c b/drivers/infiniband/core/uverbs_main.c index 60879399207a..d805cf365c8d 100644 --- a/drivers/infiniband/core/uverbs_main.c +++ b/drivers/infiniband/core/uverbs_main.c | |||
@@ -691,13 +691,8 @@ static ssize_t show_dev_abi_version(struct device *device, | |||
691 | } | 691 | } |
692 | static DEVICE_ATTR(abi_version, S_IRUGO, show_dev_abi_version, NULL); | 692 | static DEVICE_ATTR(abi_version, S_IRUGO, show_dev_abi_version, NULL); |
693 | 693 | ||
694 | static ssize_t show_abi_version(struct class *class, | 694 | static CLASS_ATTR_STRING(abi_version, S_IRUGO, |
695 | struct class_attribute *attr, | 695 | __stringify(IB_USER_VERBS_ABI_VERSION)); |
696 | char *buf) | ||
697 | { | ||
698 | return sprintf(buf, "%d\n", IB_USER_VERBS_ABI_VERSION); | ||
699 | } | ||
700 | static CLASS_ATTR(abi_version, S_IRUGO, show_abi_version, NULL); | ||
701 | 696 | ||
702 | static dev_t overflow_maj; | 697 | static dev_t overflow_maj; |
703 | static DECLARE_BITMAP(overflow_map, IB_UVERBS_MAX_DEVICES); | 698 | static DECLARE_BITMAP(overflow_map, IB_UVERBS_MAX_DEVICES); |
@@ -843,7 +838,7 @@ static int __init ib_uverbs_init(void) | |||
843 | goto out_chrdev; | 838 | goto out_chrdev; |
844 | } | 839 | } |
845 | 840 | ||
846 | ret = class_create_file(uverbs_class, &class_attr_abi_version); | 841 | ret = class_create_file(uverbs_class, &class_attr_abi_version.attr); |
847 | if (ret) { | 842 | if (ret) { |
848 | printk(KERN_ERR "user_verbs: couldn't create abi_version attribute\n"); | 843 | printk(KERN_ERR "user_verbs: couldn't create abi_version attribute\n"); |
849 | goto out_class; | 844 | goto out_class; |
diff --git a/drivers/misc/phantom.c b/drivers/misc/phantom.c index d30ae9560309..779aa8ebe4cf 100644 --- a/drivers/misc/phantom.c +++ b/drivers/misc/phantom.c | |||
@@ -497,12 +497,7 @@ static struct pci_driver phantom_pci_driver = { | |||
497 | .resume = phantom_resume | 497 | .resume = phantom_resume |
498 | }; | 498 | }; |
499 | 499 | ||
500 | static ssize_t phantom_show_version(struct class *cls, struct class_attribute *attr, char *buf) | 500 | static CLASS_ATTR_STRING(version, 0444, PHANTOM_VERSION); |
501 | { | ||
502 | return sprintf(buf, PHANTOM_VERSION "\n"); | ||
503 | } | ||
504 | |||
505 | static CLASS_ATTR(version, 0444, phantom_show_version, NULL); | ||
506 | 501 | ||
507 | static int __init phantom_init(void) | 502 | static int __init phantom_init(void) |
508 | { | 503 | { |
@@ -515,7 +510,7 @@ static int __init phantom_init(void) | |||
515 | printk(KERN_ERR "phantom: can't register phantom class\n"); | 510 | printk(KERN_ERR "phantom: can't register phantom class\n"); |
516 | goto err; | 511 | goto err; |
517 | } | 512 | } |
518 | retval = class_create_file(phantom_class, &class_attr_version); | 513 | retval = class_create_file(phantom_class, &class_attr_version.attr); |
519 | if (retval) { | 514 | if (retval) { |
520 | printk(KERN_ERR "phantom: can't create sysfs version file\n"); | 515 | printk(KERN_ERR "phantom: can't create sysfs version file\n"); |
521 | goto err_class; | 516 | goto err_class; |
@@ -541,7 +536,7 @@ static int __init phantom_init(void) | |||
541 | err_unchr: | 536 | err_unchr: |
542 | unregister_chrdev_region(dev, PHANTOM_MAX_MINORS); | 537 | unregister_chrdev_region(dev, PHANTOM_MAX_MINORS); |
543 | err_attr: | 538 | err_attr: |
544 | class_remove_file(phantom_class, &class_attr_version); | 539 | class_remove_file(phantom_class, &class_attr_version.attr); |
545 | err_class: | 540 | err_class: |
546 | class_destroy(phantom_class); | 541 | class_destroy(phantom_class); |
547 | err: | 542 | err: |
@@ -554,7 +549,7 @@ static void __exit phantom_exit(void) | |||
554 | 549 | ||
555 | unregister_chrdev_region(MKDEV(phantom_major, 0), PHANTOM_MAX_MINORS); | 550 | unregister_chrdev_region(MKDEV(phantom_major, 0), PHANTOM_MAX_MINORS); |
556 | 551 | ||
557 | class_remove_file(phantom_class, &class_attr_version); | 552 | class_remove_file(phantom_class, &class_attr_version.attr); |
558 | class_destroy(phantom_class); | 553 | class_destroy(phantom_class); |
559 | 554 | ||
560 | pr_debug("phantom: module successfully removed\n"); | 555 | pr_debug("phantom: module successfully removed\n"); |
diff --git a/drivers/staging/asus_oled/asus_oled.c b/drivers/staging/asus_oled/asus_oled.c index 7d93f50a0a64..7ebecc92c61b 100644 --- a/drivers/staging/asus_oled/asus_oled.c +++ b/drivers/staging/asus_oled/asus_oled.c | |||
@@ -770,15 +770,8 @@ static struct usb_driver oled_driver = { | |||
770 | .id_table = id_table, | 770 | .id_table = id_table, |
771 | }; | 771 | }; |
772 | 772 | ||
773 | static ssize_t version_show(struct class *dev, | 773 | static CLASS_ATTR_STRING(version, S_IRUGO, |
774 | struct class_attribute *attr, | 774 | ASUS_OLED_UNDERSCORE_NAME " " ASUS_OLED_VERSION); |
775 | char *buf) | ||
776 | { | ||
777 | return sprintf(buf, ASUS_OLED_UNDERSCORE_NAME " %s\n", | ||
778 | ASUS_OLED_VERSION); | ||
779 | } | ||
780 | |||
781 | static CLASS_ATTR(version, S_IRUGO, version_show, NULL); | ||
782 | 775 | ||
783 | static int __init asus_oled_init(void) | 776 | static int __init asus_oled_init(void) |
784 | { | 777 | { |
@@ -790,7 +783,7 @@ static int __init asus_oled_init(void) | |||
790 | return PTR_ERR(oled_class); | 783 | return PTR_ERR(oled_class); |
791 | } | 784 | } |
792 | 785 | ||
793 | retval = class_create_file(oled_class, &class_attr_version); | 786 | retval = class_create_file(oled_class, &class_attr_version.attr); |
794 | if (retval) { | 787 | if (retval) { |
795 | err("Error creating class version file"); | 788 | err("Error creating class version file"); |
796 | goto error; | 789 | goto error; |
@@ -812,7 +805,7 @@ error: | |||
812 | 805 | ||
813 | static void __exit asus_oled_exit(void) | 806 | static void __exit asus_oled_exit(void) |
814 | { | 807 | { |
815 | class_remove_file(oled_class, &class_attr_version); | 808 | class_remove_file(oled_class, &class_attr_version.attr); |
816 | class_destroy(oled_class); | 809 | class_destroy(oled_class); |
817 | 810 | ||
818 | usb_deregister(&oled_driver); | 811 | usb_deregister(&oled_driver); |