aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/base
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/base
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/base')
-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
4 files changed, 22 insertions, 9 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;