aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorAndi Kleen <andi@firstfloor.org>2010-01-05 06:48:07 -0500
committerGreg Kroah-Hartman <gregkh@suse.de>2010-03-07 20:04:48 -0500
commit28812fe11a21826ba4c97c6c7971a619987cd912 (patch)
treec78daefd595989bbc660ea48d8bc2dc5750321d3 /drivers
parent5fbcae57db69128c14080a7a5a42d0626bfe155c (diff)
driver-core: Add attribute argument to class_attribute show/store
Passing the attribute to the low level IO functions allows all kinds of cleanups, by sharing low level IO code without requiring an own function for every piece of data. Also drivers can extend the attributes with own data fields and use that in the low level function. This makes the class attributes the same as sysdev_class attributes and plain attributes. This will allow further cleanups in drivers. Full tree sweep converting all users. 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/base/class.c4
-rw-r--r--drivers/base/cpu.c8
-rw-r--r--drivers/base/firmware_class.c8
-rw-r--r--drivers/base/memory.c11
-rw-r--r--drivers/block/osdblk.c12
-rw-r--r--drivers/block/pktcdvd.c12
-rw-r--r--drivers/gpio/gpiolib.c8
-rw-r--r--drivers/gpu/drm/drm_sysfs.c3
-rw-r--r--drivers/infiniband/core/ucm.c4
-rw-r--r--drivers/infiniband/core/user_mad.c4
-rw-r--r--drivers/infiniband/core/uverbs_main.c4
-rw-r--r--drivers/misc/phantom.c2
-rw-r--r--drivers/mtd/ubi/build.c3
-rw-r--r--drivers/net/bonding/bond_sysfs.c5
-rw-r--r--drivers/staging/asus_oled/asus_oled.c4
-rw-r--r--drivers/uwb/driver.c5
16 files changed, 71 insertions, 26 deletions
diff --git a/drivers/base/class.c b/drivers/base/class.c
index 6e2c3b064f53..34a2de9c5385 100644
--- a/drivers/base/class.c
+++ b/drivers/base/class.c
@@ -31,7 +31,7 @@ static ssize_t class_attr_show(struct kobject *kobj, struct attribute *attr,
31 ssize_t ret = -EIO; 31 ssize_t ret = -EIO;
32 32
33 if (class_attr->show) 33 if (class_attr->show)
34 ret = class_attr->show(cp->class, buf); 34 ret = class_attr->show(cp->class, class_attr, buf);
35 return ret; 35 return ret;
36} 36}
37 37
@@ -43,7 +43,7 @@ static ssize_t class_attr_store(struct kobject *kobj, struct attribute *attr,
43 ssize_t ret = -EIO; 43 ssize_t ret = -EIO;
44 44
45 if (class_attr->store) 45 if (class_attr->store)
46 ret = class_attr->store(cp->class, buf, count); 46 ret = class_attr->store(cp->class, class_attr, buf, count);
47 return ret; 47 return ret;
48} 48}
49 49
diff --git a/drivers/base/cpu.c b/drivers/base/cpu.c
index fb456b729803..9121c77b77fa 100644
--- a/drivers/base/cpu.c
+++ b/drivers/base/cpu.c
@@ -79,13 +79,17 @@ void unregister_cpu(struct cpu *cpu)
79} 79}
80 80
81#ifdef CONFIG_ARCH_CPU_PROBE_RELEASE 81#ifdef CONFIG_ARCH_CPU_PROBE_RELEASE
82static ssize_t cpu_probe_store(struct class *class, const char *buf, 82static ssize_t cpu_probe_store(struct class *class,
83 struct class_attribute *attr,
84 const char *buf,
83 size_t count) 85 size_t count)
84{ 86{
85 return arch_cpu_probe(buf, count); 87 return arch_cpu_probe(buf, count);
86} 88}
87 89
88static ssize_t cpu_release_store(struct class *class, const char *buf, 90static ssize_t cpu_release_store(struct class *class,
91 struct class_attribute *attr,
92 const char *buf,
89 size_t count) 93 size_t count)
90{ 94{
91 return arch_cpu_release(buf, count); 95 return arch_cpu_release(buf, count);
diff --git a/drivers/base/firmware_class.c b/drivers/base/firmware_class.c
index a95024166b66..6604fb33d072 100644
--- a/drivers/base/firmware_class.c
+++ b/drivers/base/firmware_class.c
@@ -69,7 +69,9 @@ fw_load_abort(struct firmware_priv *fw_priv)
69} 69}
70 70
71static ssize_t 71static ssize_t
72firmware_timeout_show(struct class *class, char *buf) 72firmware_timeout_show(struct class *class,
73 struct class_attribute *attr,
74 char *buf)
73{ 75{
74 return sprintf(buf, "%d\n", loading_timeout); 76 return sprintf(buf, "%d\n", loading_timeout);
75} 77}
@@ -87,7 +89,9 @@ firmware_timeout_show(struct class *class, char *buf)
87 * Note: zero means 'wait forever'. 89 * Note: zero means 'wait forever'.
88 **/ 90 **/
89static ssize_t 91static ssize_t
90firmware_timeout_store(struct class *class, const char *buf, size_t count) 92firmware_timeout_store(struct class *class,
93 struct class_attribute *attr,
94 const char *buf, size_t count)
91{ 95{
92 loading_timeout = simple_strtol(buf, NULL, 10); 96 loading_timeout = simple_strtol(buf, NULL, 10);
93 if (loading_timeout < 0) 97 if (loading_timeout < 0)
diff --git a/drivers/base/memory.c b/drivers/base/memory.c
index 563656ad75a1..495f15e92d4c 100644
--- a/drivers/base/memory.c
+++ b/drivers/base/memory.c
@@ -331,7 +331,8 @@ static int block_size_init(void)
331 */ 331 */
332#ifdef CONFIG_ARCH_MEMORY_PROBE 332#ifdef CONFIG_ARCH_MEMORY_PROBE
333static ssize_t 333static ssize_t
334memory_probe_store(struct class *class, const char *buf, size_t count) 334memory_probe_store(struct class *class, struct class_attribute *attr,
335 const char *buf, size_t count)
335{ 336{
336 u64 phys_addr; 337 u64 phys_addr;
337 int nid; 338 int nid;
@@ -368,7 +369,9 @@ static inline int memory_probe_init(void)
368 369
369/* Soft offline a page */ 370/* Soft offline a page */
370static ssize_t 371static ssize_t
371store_soft_offline_page(struct class *class, const char *buf, size_t count) 372store_soft_offline_page(struct class *class,
373 struct class_attribute *attr,
374 const char *buf, size_t count)
372{ 375{
373 int ret; 376 int ret;
374 u64 pfn; 377 u64 pfn;
@@ -385,7 +388,9 @@ store_soft_offline_page(struct class *class, const char *buf, size_t count)
385 388
386/* Forcibly offline a page, including killing processes. */ 389/* Forcibly offline a page, including killing processes. */
387static ssize_t 390static ssize_t
388store_hard_offline_page(struct class *class, const char *buf, size_t count) 391store_hard_offline_page(struct class *class,
392 struct class_attribute *attr,
393 const char *buf, size_t count)
389{ 394{
390 int ret; 395 int ret;
391 u64 pfn; 396 u64 pfn;
diff --git a/drivers/block/osdblk.c b/drivers/block/osdblk.c
index a808b1530b3b..eb2091aa1c19 100644
--- a/drivers/block/osdblk.c
+++ b/drivers/block/osdblk.c
@@ -476,7 +476,9 @@ static void class_osdblk_release(struct class *cls)
476 kfree(cls); 476 kfree(cls);
477} 477}
478 478
479static ssize_t class_osdblk_list(struct class *c, char *data) 479static ssize_t class_osdblk_list(struct class *c,
480 struct class_attribute *attr,
481 char *data)
480{ 482{
481 int n = 0; 483 int n = 0;
482 struct list_head *tmp; 484 struct list_head *tmp;
@@ -500,7 +502,9 @@ static ssize_t class_osdblk_list(struct class *c, char *data)
500 return n; 502 return n;
501} 503}
502 504
503static ssize_t class_osdblk_add(struct class *c, const char *buf, size_t count) 505static ssize_t class_osdblk_add(struct class *c,
506 struct class_attribute *attr,
507 const char *buf, size_t count)
504{ 508{
505 struct osdblk_device *osdev; 509 struct osdblk_device *osdev;
506 ssize_t rc; 510 ssize_t rc;
@@ -592,7 +596,9 @@ err_out_mod:
592 return rc; 596 return rc;
593} 597}
594 598
595static ssize_t class_osdblk_remove(struct class *c, const char *buf, 599static ssize_t class_osdblk_remove(struct class *c,
600 struct class_attribute *attr,
601 const char *buf,
596 size_t count) 602 size_t count)
597{ 603{
598 struct osdblk_device *osdev = NULL; 604 struct osdblk_device *osdev = NULL;
diff --git a/drivers/block/pktcdvd.c b/drivers/block/pktcdvd.c
index b72935b8f203..73d815d3f1b2 100644
--- a/drivers/block/pktcdvd.c
+++ b/drivers/block/pktcdvd.c
@@ -337,7 +337,9 @@ static void class_pktcdvd_release(struct class *cls)
337{ 337{
338 kfree(cls); 338 kfree(cls);
339} 339}
340static ssize_t class_pktcdvd_show_map(struct class *c, char *data) 340static ssize_t class_pktcdvd_show_map(struct class *c,
341 struct class_attribute *attr,
342 char *data)
341{ 343{
342 int n = 0; 344 int n = 0;
343 int idx; 345 int idx;
@@ -356,7 +358,9 @@ static ssize_t class_pktcdvd_show_map(struct class *c, char *data)
356 return n; 358 return n;
357} 359}
358 360
359static ssize_t class_pktcdvd_store_add(struct class *c, const char *buf, 361static ssize_t class_pktcdvd_store_add(struct class *c,
362 struct class_attribute *attr,
363 const char *buf,
360 size_t count) 364 size_t count)
361{ 365{
362 unsigned int major, minor; 366 unsigned int major, minor;
@@ -376,7 +380,9 @@ static ssize_t class_pktcdvd_store_add(struct class *c, const char *buf,
376 return -EINVAL; 380 return -EINVAL;
377} 381}
378 382
379static ssize_t class_pktcdvd_store_remove(struct class *c, const char *buf, 383static ssize_t class_pktcdvd_store_remove(struct class *c,
384 struct class_attribute *attr,
385 const char *buf,
380 size_t count) 386 size_t count)
381{ 387{
382 unsigned int major, minor; 388 unsigned int major, minor;
diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index 9006fdb26fea..6d1b86661e63 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -623,7 +623,9 @@ static const struct attribute_group gpiochip_attr_group = {
623 * /sys/class/gpio/unexport ... write-only 623 * /sys/class/gpio/unexport ... write-only
624 * integer N ... number of GPIO to unexport 624 * integer N ... number of GPIO to unexport
625 */ 625 */
626static ssize_t export_store(struct class *class, const char *buf, size_t len) 626static ssize_t export_store(struct class *class,
627 struct class_attribute *attr,
628 const char *buf, size_t len)
627{ 629{
628 long gpio; 630 long gpio;
629 int status; 631 int status;
@@ -653,7 +655,9 @@ done:
653 return status ? : len; 655 return status ? : len;
654} 656}
655 657
656static ssize_t unexport_store(struct class *class, const char *buf, size_t len) 658static ssize_t unexport_store(struct class *class,
659 struct class_attribute *attr,
660 const char *buf, size_t len)
657{ 661{
658 long gpio; 662 long gpio;
659 int status; 663 int status;
diff --git a/drivers/gpu/drm/drm_sysfs.c b/drivers/gpu/drm/drm_sysfs.c
index 7e42b7e9d43a..b95aaf23596e 100644
--- a/drivers/gpu/drm/drm_sysfs.c
+++ b/drivers/gpu/drm/drm_sysfs.c
@@ -71,7 +71,8 @@ static int drm_class_resume(struct device *dev)
71} 71}
72 72
73/* Display the version of drm_core. This doesn't work right in current design */ 73/* Display the version of drm_core. This doesn't work right in current design */
74static ssize_t version_show(struct class *dev, char *buf) 74static ssize_t version_show(struct class *dev, struct class_attribute *attr,
75 char *buf)
75{ 76{
76 return sprintf(buf, "%s %d.%d.%d %s\n", CORE_NAME, CORE_MAJOR, 77 return sprintf(buf, "%s %d.%d.%d %s\n", CORE_NAME, CORE_MAJOR,
77 CORE_MINOR, CORE_PATCHLEVEL, CORE_DATE); 78 CORE_MINOR, CORE_PATCHLEVEL, CORE_DATE);
diff --git a/drivers/infiniband/core/ucm.c b/drivers/infiniband/core/ucm.c
index 1b09b735c5a8..02e209ff33fd 100644
--- a/drivers/infiniband/core/ucm.c
+++ b/drivers/infiniband/core/ucm.c
@@ -1336,7 +1336,9 @@ 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
1339static ssize_t show_abi_version(struct class *class, char *buf) 1339static ssize_t show_abi_version(struct class *class,
1340 struct class_attribute *attr,
1341 char *buf)
1340{ 1342{
1341 return sprintf(buf, "%d\n", IB_USER_CM_ABI_VERSION); 1343 return sprintf(buf, "%d\n", IB_USER_CM_ABI_VERSION);
1342} 1344}
diff --git a/drivers/infiniband/core/user_mad.c b/drivers/infiniband/core/user_mad.c
index 02d360cfc2f7..d0de8f265f45 100644
--- a/drivers/infiniband/core/user_mad.c
+++ b/drivers/infiniband/core/user_mad.c
@@ -965,7 +965,9 @@ static ssize_t show_port(struct device *dev, struct device_attribute *attr,
965} 965}
966static DEVICE_ATTR(port, S_IRUGO, show_port, NULL); 966static DEVICE_ATTR(port, S_IRUGO, show_port, NULL);
967 967
968static ssize_t show_abi_version(struct class *class, char *buf) 968static ssize_t show_abi_version(struct class *class,
969 struct class_attribute *attr,
970 char *buf)
969{ 971{
970 return sprintf(buf, "%d\n", IB_USER_MAD_ABI_VERSION); 972 return sprintf(buf, "%d\n", IB_USER_MAD_ABI_VERSION);
971} 973}
diff --git a/drivers/infiniband/core/uverbs_main.c b/drivers/infiniband/core/uverbs_main.c
index 4fa2e6516441..60879399207a 100644
--- a/drivers/infiniband/core/uverbs_main.c
+++ b/drivers/infiniband/core/uverbs_main.c
@@ -691,7 +691,9 @@ static ssize_t show_dev_abi_version(struct device *device,
691} 691}
692static DEVICE_ATTR(abi_version, S_IRUGO, show_dev_abi_version, NULL); 692static DEVICE_ATTR(abi_version, S_IRUGO, show_dev_abi_version, NULL);
693 693
694static ssize_t show_abi_version(struct class *class, char *buf) 694static ssize_t show_abi_version(struct class *class,
695 struct class_attribute *attr,
696 char *buf)
695{ 697{
696 return sprintf(buf, "%d\n", IB_USER_VERBS_ABI_VERSION); 698 return sprintf(buf, "%d\n", IB_USER_VERBS_ABI_VERSION);
697} 699}
diff --git a/drivers/misc/phantom.c b/drivers/misc/phantom.c
index 04c27266f567..d30ae9560309 100644
--- a/drivers/misc/phantom.c
+++ b/drivers/misc/phantom.c
@@ -497,7 +497,7 @@ static struct pci_driver phantom_pci_driver = {
497 .resume = phantom_resume 497 .resume = phantom_resume
498}; 498};
499 499
500static ssize_t phantom_show_version(struct class *cls, char *buf) 500static ssize_t phantom_show_version(struct class *cls, struct class_attribute *attr, char *buf)
501{ 501{
502 return sprintf(buf, PHANTOM_VERSION "\n"); 502 return sprintf(buf, PHANTOM_VERSION "\n");
503} 503}
diff --git a/drivers/mtd/ubi/build.c b/drivers/mtd/ubi/build.c
index bc45ef9af17d..fad40aa6f099 100644
--- a/drivers/mtd/ubi/build.c
+++ b/drivers/mtd/ubi/build.c
@@ -89,7 +89,8 @@ DEFINE_MUTEX(ubi_devices_mutex);
89static DEFINE_SPINLOCK(ubi_devices_lock); 89static DEFINE_SPINLOCK(ubi_devices_lock);
90 90
91/* "Show" method for files in '/<sysfs>/class/ubi/' */ 91/* "Show" method for files in '/<sysfs>/class/ubi/' */
92static ssize_t ubi_version_show(struct class *class, char *buf) 92static ssize_t ubi_version_show(struct class *class, struct class_attribute *attr,
93 char *buf)
93{ 94{
94 return sprintf(buf, "%d\n", UBI_VERSION); 95 return sprintf(buf, "%d\n", UBI_VERSION);
95} 96}
diff --git a/drivers/net/bonding/bond_sysfs.c b/drivers/net/bonding/bond_sysfs.c
index 5acd557cea9b..b8bec086daa1 100644
--- a/drivers/net/bonding/bond_sysfs.c
+++ b/drivers/net/bonding/bond_sysfs.c
@@ -51,7 +51,9 @@
51 * "show" function for the bond_masters attribute. 51 * "show" function for the bond_masters attribute.
52 * The class parameter is ignored. 52 * The class parameter is ignored.
53 */ 53 */
54static ssize_t bonding_show_bonds(struct class *cls, char *buf) 54static ssize_t bonding_show_bonds(struct class *cls,
55 struct class_attribute *attr,
56 char *buf)
55{ 57{
56 struct net *net = current->nsproxy->net_ns; 58 struct net *net = current->nsproxy->net_ns;
57 struct bond_net *bn = net_generic(net, bond_net_id); 59 struct bond_net *bn = net_generic(net, bond_net_id);
@@ -98,6 +100,7 @@ static struct net_device *bond_get_by_name(struct net *net, const char *ifname)
98 */ 100 */
99 101
100static ssize_t bonding_store_bonds(struct class *cls, 102static ssize_t bonding_store_bonds(struct class *cls,
103 struct class_attribute *attr,
101 const char *buffer, size_t count) 104 const char *buffer, size_t count)
102{ 105{
103 struct net *net = current->nsproxy->net_ns; 106 struct net *net = current->nsproxy->net_ns;
diff --git a/drivers/staging/asus_oled/asus_oled.c b/drivers/staging/asus_oled/asus_oled.c
index cadb6f7321ad..7d93f50a0a64 100644
--- a/drivers/staging/asus_oled/asus_oled.c
+++ b/drivers/staging/asus_oled/asus_oled.c
@@ -770,7 +770,9 @@ static struct usb_driver oled_driver = {
770 .id_table = id_table, 770 .id_table = id_table,
771}; 771};
772 772
773static ssize_t version_show(struct class *dev, char *buf) 773static ssize_t version_show(struct class *dev,
774 struct class_attribute *attr,
775 char *buf)
774{ 776{
775 return sprintf(buf, ASUS_OLED_UNDERSCORE_NAME " %s\n", 777 return sprintf(buf, ASUS_OLED_UNDERSCORE_NAME " %s\n",
776 ASUS_OLED_VERSION); 778 ASUS_OLED_VERSION);
diff --git a/drivers/uwb/driver.c b/drivers/uwb/driver.c
index da77e41de990..08bd6dbfd4a6 100644
--- a/drivers/uwb/driver.c
+++ b/drivers/uwb/driver.c
@@ -74,13 +74,16 @@
74unsigned long beacon_timeout_ms = 500; 74unsigned long beacon_timeout_ms = 500;
75 75
76static 76static
77ssize_t beacon_timeout_ms_show(struct class *class, char *buf) 77ssize_t beacon_timeout_ms_show(struct class *class,
78 struct class_attribute *attr,
79 char *buf)
78{ 80{
79 return scnprintf(buf, PAGE_SIZE, "%lu\n", beacon_timeout_ms); 81 return scnprintf(buf, PAGE_SIZE, "%lu\n", beacon_timeout_ms);
80} 82}
81 83
82static 84static
83ssize_t beacon_timeout_ms_store(struct class *class, 85ssize_t beacon_timeout_ms_store(struct class *class,
86 struct class_attribute *attr,
84 const char *buf, size_t size) 87 const char *buf, size_t size)
85{ 88{
86 unsigned long bt; 89 unsigned long bt;