]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
sysdev: Pass attribute in sysdev_class attributes show/store
authorAndi Kleen <andi@firstfloor.org>
Tue, 5 Jan 2010 11:47:58 +0000 (12:47 +0100)
committerGreg Kroah-Hartman <gregkh@suse.de>
Mon, 8 Mar 2010 01:04:47 +0000 (17:04 -0800)
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.

Similar to sysdev_attributes and normal attributes.

This is a tree-wide sweep, converting everything in one go.

No functional changes in this patch other than passing the new
argument everywhere.

Tested on x86, the non x86 parts are uncompiled.

Signed-off-by: Andi Kleen <ak@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
arch/mips/txx9/generic/7segled.c
arch/s390/kernel/smp.c
arch/s390/kernel/time.c
drivers/base/cpu.c
drivers/base/node.c
drivers/base/sys.c
drivers/cpuidle/sysfs.c
include/linux/sysdev.h
kernel/perf_event.c
kernel/sched.c

index 727ab21b6618bdafaae6e6dfeed839b3ee6b355a..7f8416f862222fd90147b5729f8d2841978fb63d 100644 (file)
@@ -58,13 +58,16 @@ static ssize_t raw_store(struct sys_device *dev,
 static SYSDEV_ATTR(ascii, 0200, NULL, ascii_store);
 static SYSDEV_ATTR(raw, 0200, NULL, raw_store);
 
-static ssize_t map_seg7_show(struct sysdev_class *class, char *buf)
+static ssize_t map_seg7_show(struct sysdev_class *class,
+                            struct sysdev_class_attribute *attr,
+                            char *buf)
 {
        memcpy(buf, &txx9_seg7map, sizeof(txx9_seg7map));
        return sizeof(txx9_seg7map);
 }
 
 static ssize_t map_seg7_store(struct sysdev_class *class,
+                             struct sysdev_class_attribute *attr,
                              const char *buf, size_t size)
 {
        if (size != sizeof(txx9_seg7map))
index 8b10127c00ada4e69e85ac9e8617a5380c853e32..e2121099f03b581bc8145e1986d268ea0fb7c8c6 100644 (file)
@@ -1020,7 +1020,9 @@ out:
        return rc;
 }
 
-static ssize_t __ref rescan_store(struct sysdev_class *class, const char *buf,
+static ssize_t __ref rescan_store(struct sysdev_class *class,
+                                 struct sysdev_class_attribute *attr,
+                                 const char *buf,
                                  size_t count)
 {
        int rc;
@@ -1041,7 +1043,9 @@ static ssize_t dispatching_show(struct sysdev_class *class, char *buf)
        return count;
 }
 
-static ssize_t dispatching_store(struct sysdev_class *dev, const char *buf,
+static ssize_t dispatching_store(struct sysdev_class *dev,
+                                struct sysdev_class_attribute *attr,
+                                const char *buf,
                                 size_t count)
 {
        int val, rc;
index a8f93f1705aded37002e654bcf85c485335d1995..75894c28171043be8b3002cf0a88e350a5268a0e 100644 (file)
@@ -1116,14 +1116,18 @@ static struct sys_device etr_port1_dev = {
 /*
  * ETR class attributes
  */
-static ssize_t etr_stepping_port_show(struct sysdev_class *class, char *buf)
+static ssize_t etr_stepping_port_show(struct sysdev_class *class,
+                                       struct sysdev_class_attribute *attr,
+                                       char *buf)
 {
        return sprintf(buf, "%i\n", etr_port0.esw.p);
 }
 
 static SYSDEV_CLASS_ATTR(stepping_port, 0400, etr_stepping_port_show, NULL);
 
-static ssize_t etr_stepping_mode_show(struct sysdev_class *class, char *buf)
+static ssize_t etr_stepping_mode_show(struct sysdev_class *class,
+                                       struct sysdev_class_attribute *attr,
+                                       char *buf)
 {
        char *mode_str;
 
@@ -1584,7 +1588,9 @@ static struct sysdev_class stp_sysclass = {
        .name   = "stp",
 };
 
-static ssize_t stp_ctn_id_show(struct sysdev_class *class, char *buf)
+static ssize_t stp_ctn_id_show(struct sysdev_class *class,
+                               struct sysdev_class_attribute *attr,
+                               char *buf)
 {
        if (!stp_online)
                return -ENODATA;
@@ -1594,7 +1600,9 @@ static ssize_t stp_ctn_id_show(struct sysdev_class *class, char *buf)
 
 static SYSDEV_CLASS_ATTR(ctn_id, 0400, stp_ctn_id_show, NULL);
 
-static ssize_t stp_ctn_type_show(struct sysdev_class *class, char *buf)
+static ssize_t stp_ctn_type_show(struct sysdev_class *class,
+                               struct sysdev_class_attribute *attr,
+                               char *buf)
 {
        if (!stp_online)
                return -ENODATA;
@@ -1603,7 +1611,9 @@ static ssize_t stp_ctn_type_show(struct sysdev_class *class, char *buf)
 
 static SYSDEV_CLASS_ATTR(ctn_type, 0400, stp_ctn_type_show, NULL);
 
-static ssize_t stp_dst_offset_show(struct sysdev_class *class, char *buf)
+static ssize_t stp_dst_offset_show(struct sysdev_class *class,
+                                  struct sysdev_class_attribute *attr,
+                                  char *buf)
 {
        if (!stp_online || !(stp_info.vbits & 0x2000))
                return -ENODATA;
@@ -1612,7 +1622,9 @@ static ssize_t stp_dst_offset_show(struct sysdev_class *class, char *buf)
 
 static SYSDEV_CLASS_ATTR(dst_offset, 0400, stp_dst_offset_show, NULL);
 
-static ssize_t stp_leap_seconds_show(struct sysdev_class *class, char *buf)
+static ssize_t stp_leap_seconds_show(struct sysdev_class *class,
+                                       struct sysdev_class_attribute *attr,
+                                       char *buf)
 {
        if (!stp_online || !(stp_info.vbits & 0x8000))
                return -ENODATA;
@@ -1621,7 +1633,9 @@ static ssize_t stp_leap_seconds_show(struct sysdev_class *class, char *buf)
 
 static SYSDEV_CLASS_ATTR(leap_seconds, 0400, stp_leap_seconds_show, NULL);
 
-static ssize_t stp_stratum_show(struct sysdev_class *class, char *buf)
+static ssize_t stp_stratum_show(struct sysdev_class *class,
+                               struct sysdev_class_attribute *attr,
+                               char *buf)
 {
        if (!stp_online)
                return -ENODATA;
@@ -1630,7 +1644,9 @@ static ssize_t stp_stratum_show(struct sysdev_class *class, char *buf)
 
 static SYSDEV_CLASS_ATTR(stratum, 0400, stp_stratum_show, NULL);
 
-static ssize_t stp_time_offset_show(struct sysdev_class *class, char *buf)
+static ssize_t stp_time_offset_show(struct sysdev_class *class,
+                               struct sysdev_class_attribute *attr,
+                               char *buf)
 {
        if (!stp_online || !(stp_info.vbits & 0x0800))
                return -ENODATA;
@@ -1639,7 +1655,9 @@ static ssize_t stp_time_offset_show(struct sysdev_class *class, char *buf)
 
 static SYSDEV_CLASS_ATTR(time_offset, 0400, stp_time_offset_show, NULL);
 
-static ssize_t stp_time_zone_offset_show(struct sysdev_class *class, char *buf)
+static ssize_t stp_time_zone_offset_show(struct sysdev_class *class,
+                               struct sysdev_class_attribute *attr,
+                               char *buf)
 {
        if (!stp_online || !(stp_info.vbits & 0x4000))
                return -ENODATA;
@@ -1649,7 +1667,9 @@ static ssize_t stp_time_zone_offset_show(struct sysdev_class *class, char *buf)
 static SYSDEV_CLASS_ATTR(time_zone_offset, 0400,
                         stp_time_zone_offset_show, NULL);
 
-static ssize_t stp_timing_mode_show(struct sysdev_class *class, char *buf)
+static ssize_t stp_timing_mode_show(struct sysdev_class *class,
+                               struct sysdev_class_attribute *attr,
+                               char *buf)
 {
        if (!stp_online)
                return -ENODATA;
@@ -1658,7 +1678,9 @@ static ssize_t stp_timing_mode_show(struct sysdev_class *class, char *buf)
 
 static SYSDEV_CLASS_ATTR(timing_mode, 0400, stp_timing_mode_show, NULL);
 
-static ssize_t stp_timing_state_show(struct sysdev_class *class, char *buf)
+static ssize_t stp_timing_state_show(struct sysdev_class *class,
+                               struct sysdev_class_attribute *attr,
+                               char *buf)
 {
        if (!stp_online)
                return -ENODATA;
@@ -1667,12 +1689,15 @@ static ssize_t stp_timing_state_show(struct sysdev_class *class, char *buf)
 
 static SYSDEV_CLASS_ATTR(timing_state, 0400, stp_timing_state_show, NULL);
 
-static ssize_t stp_online_show(struct sysdev_class *class, char *buf)
+static ssize_t stp_online_show(struct sysdev_class *class,
+                               struct sysdev_class_attribute *attr,
+                               char *buf)
 {
        return sprintf(buf, "%i\n", stp_online);
 }
 
 static ssize_t stp_online_store(struct sysdev_class *class,
+                               struct sysdev_class_attribute *attr,
                                const char *buf, size_t count)
 {
        unsigned int value;
index 958bd1540c303d92f84cbcea016c7da4c0ce925c..fd1b2f9b7b8f1c91c7ddf28d7949a287a793a5bd 100644 (file)
@@ -151,7 +151,8 @@ static ssize_t print_cpus_map(char *buf, const struct cpumask *map)
 }
 
 #define        print_cpus_func(type) \
-static ssize_t print_cpus_##type(struct sysdev_class *class, char *buf)        \
+static ssize_t print_cpus_##type(struct sysdev_class *class,           \
+                       struct sysdev_class_attribute *attr, char *buf) \
 {                                                                      \
        return print_cpus_map(buf, cpu_##type##_mask);                  \
 }                                                                      \
@@ -165,7 +166,8 @@ print_cpus_func(present);
 /*
  * Print values for NR_CPUS and offlined cpus
  */
-static ssize_t print_cpus_kernel_max(struct sysdev_class *class, char *buf)
+static ssize_t print_cpus_kernel_max(struct sysdev_class *class,
+                                    struct sysdev_class_attribute *attr, char *buf)
 {
        int n = snprintf(buf, PAGE_SIZE-2, "%d\n", NR_CPUS - 1);
        return n;
@@ -175,7 +177,8 @@ static SYSDEV_CLASS_ATTR(kernel_max, 0444, print_cpus_kernel_max, NULL);
 /* arch-optional setting to enable display of offline cpus >= nr_cpu_ids */
 unsigned int total_cpus;
 
-static ssize_t print_cpus_offline(struct sysdev_class *class, char *buf)
+static ssize_t print_cpus_offline(struct sysdev_class *class,
+                                 struct sysdev_class_attribute *attr, char *buf)
 {
        int n = 0, len = PAGE_SIZE-2;
        cpumask_var_t offline;
index 70122791683d5259ed4afbcc145aaad73aa59cd3..85c9d30d70040fdb3487a88f0211d8a497630a8b 100644 (file)
@@ -544,23 +544,29 @@ static ssize_t print_nodes_state(enum node_states state, char *buf)
        return n;
 }
 
-static ssize_t print_nodes_possible(struct sysdev_class *class, char *buf)
+static ssize_t print_nodes_possible(struct sysdev_class *class,
+                                   struct sysdev_class_attribute *attr, char *buf)
 {
        return print_nodes_state(N_POSSIBLE, buf);
 }
 
-static ssize_t print_nodes_online(struct sysdev_class *class, char *buf)
+static ssize_t print_nodes_online(struct sysdev_class *class,
+                                 struct sysdev_class_attribute *attr,
+                                 char *buf)
 {
        return print_nodes_state(N_ONLINE, buf);
 }
 
 static ssize_t print_nodes_has_normal_memory(struct sysdev_class *class,
-                                               char *buf)
+                                            struct sysdev_class_attribute *attr,
+                                            char *buf)
 {
        return print_nodes_state(N_NORMAL_MEMORY, buf);
 }
 
-static ssize_t print_nodes_has_cpu(struct sysdev_class *class, char *buf)
+static ssize_t print_nodes_has_cpu(struct sysdev_class *class,
+                                  struct sysdev_class_attribute *attr,
+                                  char *buf)
 {
        return print_nodes_state(N_CPU, buf);
 }
@@ -573,7 +579,8 @@ static SYSDEV_CLASS_ATTR(has_cpu, 0444, print_nodes_has_cpu, NULL);
 
 #ifdef CONFIG_HIGHMEM
 static ssize_t print_nodes_has_high_memory(struct sysdev_class *class,
-                                                char *buf)
+                                          struct sysdev_class_attribute *attr,
+                                          char *buf)
 {
        return print_nodes_state(N_HIGH_MEMORY, buf);
 }
index 0d903909af7e5366126baaa049d35c5ea26fe6b5..a38445c0f8c592a9e96e54bba51f3b8cb70ca8f3 100644 (file)
@@ -89,7 +89,7 @@ static ssize_t sysdev_class_show(struct kobject *kobj, struct attribute *attr,
        struct sysdev_class_attribute *class_attr = to_sysdev_class_attr(attr);
 
        if (class_attr->show)
-               return class_attr->show(class, buffer);
+               return class_attr->show(class, class_attr, buffer);
        return -EIO;
 }
 
@@ -100,7 +100,7 @@ static ssize_t sysdev_class_store(struct kobject *kobj, struct attribute *attr,
        struct sysdev_class_attribute *class_attr = to_sysdev_class_attr(attr);
 
        if (class_attr->store)
-               return class_attr->store(class, buffer, count);
+               return class_attr->store(class, class_attr, buffer, count);
        return -EIO;
 }
 
index 97b003839fb6ab0df4249fd29424f4ba05f0ec3b..c9cefacabf37fe2126bbe0de12fe76c2bd80f7d7 100644 (file)
@@ -22,6 +22,7 @@ static int __init cpuidle_sysfs_setup(char *unused)
 __setup("cpuidle_sysfs_switch", cpuidle_sysfs_setup);
 
 static ssize_t show_available_governors(struct sysdev_class *class,
+                                       struct sysdev_class_attribute *attr,
                                        char *buf)
 {
        ssize_t i = 0;
@@ -41,6 +42,7 @@ out:
 }
 
 static ssize_t show_current_driver(struct sysdev_class *class,
+                                  struct sysdev_class_attribute *attr,
                                   char *buf)
 {
        ssize_t ret;
@@ -56,6 +58,7 @@ static ssize_t show_current_driver(struct sysdev_class *class,
 }
 
 static ssize_t show_current_governor(struct sysdev_class *class,
+                                    struct sysdev_class_attribute *attr,
                                     char *buf)
 {
        ssize_t ret;
@@ -71,6 +74,7 @@ static ssize_t show_current_governor(struct sysdev_class *class,
 }
 
 static ssize_t store_current_governor(struct sysdev_class *class,
+                                     struct sysdev_class_attribute *attr,
                                      const char *buf, size_t count)
 {
        char gov_name[CPUIDLE_NAME_LEN];
index f395bb3fa2f2065375f25c51ea8221d27a4d3dc6..c2458fa8376c3353a390142e7cc0b40840a3a970 100644 (file)
@@ -41,8 +41,10 @@ struct sysdev_class {
 
 struct sysdev_class_attribute {
        struct attribute attr;
-       ssize_t (*show)(struct sysdev_class *, char *);
-       ssize_t (*store)(struct sysdev_class *, const char *, size_t);
+       ssize_t (*show)(struct sysdev_class *, struct sysdev_class_attribute *,
+                       char *);
+       ssize_t (*store)(struct sysdev_class *, struct sysdev_class_attribute *,
+                        const char *, size_t);
 };
 
 #define _SYSDEV_CLASS_ATTR(_name,_mode,_show,_store)           \
index 8e352c756ba742cda4dfa22bdb9954ed675d305e..f40560b86544e8b999164c7cd17b5cb1f84d6510 100644 (file)
@@ -5481,13 +5481,16 @@ void __init perf_event_init(void)
        register_cpu_notifier(&perf_cpu_nb);
 }
 
-static ssize_t perf_show_reserve_percpu(struct sysdev_class *class, char *buf)
+static ssize_t perf_show_reserve_percpu(struct sysdev_class *class,
+                                       struct sysdev_class_attribute *attr,
+                                       char *buf)
 {
        return sprintf(buf, "%d\n", perf_reserved_percpu);
 }
 
 static ssize_t
 perf_set_reserve_percpu(struct sysdev_class *class,
+                       struct sysdev_class_attribute *attr,
                        const char *buf,
                        size_t count)
 {
@@ -5516,13 +5519,17 @@ perf_set_reserve_percpu(struct sysdev_class *class,
        return count;
 }
 
-static ssize_t perf_show_overcommit(struct sysdev_class *class, char *buf)
+static ssize_t perf_show_overcommit(struct sysdev_class *class,
+                                   struct sysdev_class_attribute *attr,
+                                   char *buf)
 {
        return sprintf(buf, "%d\n", perf_overcommit);
 }
 
 static ssize_t
-perf_set_overcommit(struct sysdev_class *class, const char *buf, size_t count)
+perf_set_overcommit(struct sysdev_class *class,
+                   struct sysdev_class_attribute *attr,
+                   const char *buf, size_t count)
 {
        unsigned long val;
        int err;
index b47ceeec1a912054e63e947f8a334f0152cdcceb..150b6988de49f4b63dd7226479cec6846205e9b2 100644 (file)
@@ -7406,11 +7406,13 @@ static ssize_t sched_power_savings_store(const char *buf, size_t count, int smt)
 
 #ifdef CONFIG_SCHED_MC
 static ssize_t sched_mc_power_savings_show(struct sysdev_class *class,
+                                          struct sysdev_class_attribute *attr,
                                           char *page)
 {
        return sprintf(page, "%u\n", sched_mc_power_savings);
 }
 static ssize_t sched_mc_power_savings_store(struct sysdev_class *class,
+                                           struct sysdev_class_attribute *attr,
                                            const char *buf, size_t count)
 {
        return sched_power_savings_store(buf, count, 0);
@@ -7422,11 +7424,13 @@ static SYSDEV_CLASS_ATTR(sched_mc_power_savings, 0644,
 
 #ifdef CONFIG_SCHED_SMT
 static ssize_t sched_smt_power_savings_show(struct sysdev_class *dev,
+                                           struct sysdev_class_attribute *attr,
                                            char *page)
 {
        return sprintf(page, "%u\n", sched_smt_power_savings);
 }
 static ssize_t sched_smt_power_savings_store(struct sysdev_class *dev,
+                                            struct sysdev_class_attribute *attr,
                                             const char *buf, size_t count)
 {
        return sched_power_savings_store(buf, count, 1);