| From jejb@kernel.org Tue Nov 4 11:33:37 2008 |
| From: Heiko Carstens <heiko.carstens@de.ibm.com> |
| Date: Tue, 28 Oct 2008 17:15:07 GMT |
| Subject: S390: Fix sysdev class file creation. |
| To: jejb@kernel.org, stable@kernel.org |
| Message-ID: <200810281715.m9SHF7lf001667@hera.kernel.org> |
| |
| From: Heiko Carstens <heiko.carstens@de.ibm.com> |
| |
| commit da5aae7036692fa8d03da1b705c76fd750ed9e38 upstream |
| |
| Use sysdev_class_create_file() to create create sysdev class attributes |
| instead of sysfs_create_file(). Using sysfs_create_file() wasn't a very |
| good idea since the show and store functions have a different amount of |
| parameters for sysfs files and sysdev class files. |
| In particular the pointer to the buffer is the last argument and |
| therefore accesses to random memory regions happened. |
| Still worked surprisingly well until we got a kernel panic. |
| |
| Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com> |
| Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com> |
| Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de> |
| |
| --- |
| arch/s390/kernel/smp.c | 24 +++++++++--------------- |
| 1 file changed, 9 insertions(+), 15 deletions(-) |
| |
| --- a/arch/s390/kernel/smp.c |
| +++ b/arch/s390/kernel/smp.c |
| @@ -1117,9 +1117,7 @@ out: |
| return rc; |
| } |
| |
| -static ssize_t __ref rescan_store(struct sys_device *dev, |
| - struct sysdev_attribute *attr, |
| - const char *buf, |
| +static ssize_t __ref rescan_store(struct sysdev_class *class, const char *buf, |
| size_t count) |
| { |
| int rc; |
| @@ -1127,12 +1125,10 @@ static ssize_t __ref rescan_store(struct |
| rc = smp_rescan_cpus(); |
| return rc ? rc : count; |
| } |
| -static SYSDEV_ATTR(rescan, 0200, NULL, rescan_store); |
| +static SYSDEV_CLASS_ATTR(rescan, 0200, NULL, rescan_store); |
| #endif /* CONFIG_HOTPLUG_CPU */ |
| |
| -static ssize_t dispatching_show(struct sys_device *dev, |
| - struct sysdev_attribute *attr, |
| - char *buf) |
| +static ssize_t dispatching_show(struct sysdev_class *class, char *buf) |
| { |
| ssize_t count; |
| |
| @@ -1142,9 +1138,8 @@ static ssize_t dispatching_show(struct s |
| return count; |
| } |
| |
| -static ssize_t dispatching_store(struct sys_device *dev, |
| - struct sysdev_attribute *attr, |
| - const char *buf, size_t count) |
| +static ssize_t dispatching_store(struct sysdev_class *dev, const char *buf, |
| + size_t count) |
| { |
| int val, rc; |
| char delim; |
| @@ -1166,7 +1161,8 @@ out: |
| put_online_cpus(); |
| return rc ? rc : count; |
| } |
| -static SYSDEV_ATTR(dispatching, 0644, dispatching_show, dispatching_store); |
| +static SYSDEV_CLASS_ATTR(dispatching, 0644, dispatching_show, |
| + dispatching_store); |
| |
| static int __init topology_init(void) |
| { |
| @@ -1176,13 +1172,11 @@ static int __init topology_init(void) |
| register_cpu_notifier(&smp_cpu_nb); |
| |
| #ifdef CONFIG_HOTPLUG_CPU |
| - rc = sysfs_create_file(&cpu_sysdev_class.kset.kobj, |
| - &attr_rescan.attr); |
| + rc = sysdev_class_create_file(&cpu_sysdev_class, &attr_rescan); |
| if (rc) |
| return rc; |
| #endif |
| - rc = sysfs_create_file(&cpu_sysdev_class.kset.kobj, |
| - &attr_dispatching.attr); |
| + rc = sysdev_class_create_file(&cpu_sysdev_class, &attr_dispatching); |
| if (rc) |
| return rc; |
| for_each_present_cpu(cpu) { |