Re: [PATCH 72/79] sysdev: Pass the attribute to the low levelsysdev show/store function

From: Andrew Morton
Date: Tue Jul 22 2008 - 16:41:20 EST


On Mon, 21 Jul 2008 22:19:36 -0700
Greg Kroah-Hartman <gregkh@xxxxxxx> wrote:

> From: Andi Kleen <andi@xxxxxxxxxxxxxx>
>
> This allow to dynamically generate attributes and share show/store
> functions between attributes. Right now most attributes are generated
> by special macros and lots of duplicated code. With the attribute
> passed it's instead possible to attach some data to the attribute
> and then use that in shared low level functions to do different things.
>
> I need this for the dynamically generated bank attributes in the x86
> machine check code, but it'll allow some further cleanups.
>
> I converted all users in tree to the new show/store prototype. It's a single
> huge patch to avoid unbisectable sections.
>
> Runtime tested: x86-32, x86-64
> Compiled only: ia64, powerpc
> Not compile tested/only grep converted: sh, arm, avr32
>
> Signed-off-by: Andi Kleen <ak@xxxxxxxxxxxxxxx>
> Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxx>
>
> ...
>
> kernel/sched.c | 8 ++++-

This wrecks use-sysdev_class-in-schedc.patch (below), which I merged a
week ago and will now drop.

Why did this patch from Andi just turn up in linux-next now, halfway
through the merge window? It has a commit date of July 1 yet it has
never before been sighted in linux-next.




From: Takashi Iwai <tiwai@xxxxxxx>

The power_saving* attributes are really sysdev_class stuff, so we must
create them via sysdev_class_create_file(). The parameters of callback
functions must be also fixed.

Signed-off-by: Takashi Iwai <tiwai@xxxxxxx>
Cc: <Valdis.Kletnieks@xxxxxx>
Cc: Ingo Molnar <mingo@xxxxxxx>
Cc: Stephen Rothwell <sfr@xxxxxxxxxxxxxxxx>
Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>
---

kernel/sched.c | 28 ++++++++++++++++------------
1 file changed, 16 insertions(+), 12 deletions(-)

diff -puN kernel/sched.c~use-sysdev_class-in-schedc kernel/sched.c
--- a/kernel/sched.c~use-sysdev_class-in-schedc
+++ a/kernel/sched.c
@@ -7732,31 +7732,35 @@ static ssize_t sched_power_savings_store
}

#ifdef CONFIG_SCHED_MC
-static ssize_t sched_mc_power_savings_show(struct sys_device *dev, char *page)
+static ssize_t sched_mc_power_savings_show(struct sysdev_class *cls,
+ char *page)
{
return sprintf(page, "%u\n", sched_mc_power_savings);
}
-static ssize_t sched_mc_power_savings_store(struct sys_device *dev,
+static ssize_t sched_mc_power_savings_store(struct sysdev_class *cls,
const char *buf, size_t count)
{
return sched_power_savings_store(buf, count, 0);
}
-static SYSDEV_ATTR(sched_mc_power_savings, 0644, sched_mc_power_savings_show,
- sched_mc_power_savings_store);
+static SYSDEV_CLASS_ATTR(sched_mc_power_savings, 0644,
+ sched_mc_power_savings_show,
+ sched_mc_power_savings_store);
#endif

#ifdef CONFIG_SCHED_SMT
-static ssize_t sched_smt_power_savings_show(struct sys_device *dev, char *page)
+static ssize_t sched_smt_power_savings_show(struct sysdev_class *cls,
+ char *page)
{
return sprintf(page, "%u\n", sched_smt_power_savings);
}
-static ssize_t sched_smt_power_savings_store(struct sys_device *dev,
+static ssize_t sched_smt_power_savings_store(struct sysdv_class *cls,
const char *buf, size_t count)
{
return sched_power_savings_store(buf, count, 1);
}
-static SYSDEV_ATTR(sched_smt_power_savings, 0644, sched_smt_power_savings_show,
- sched_smt_power_savings_store);
+static SYSDEV_CLASS_ATTR(sched_smt_power_savings, 0644,
+ sched_smt_power_savings_show,
+ sched_smt_power_savings_store);
#endif

int sched_create_sysfs_power_savings_entries(struct sysdev_class *cls)
@@ -7765,13 +7769,13 @@ int sched_create_sysfs_power_savings_ent

#ifdef CONFIG_SCHED_SMT
if (smt_capable())
- err = sysfs_create_file(&cls->kset.kobj,
- &attr_sched_smt_power_savings.attr);
+ err = sysdev_class_create_file(cls,
+ &attr_sched_smt_power_savings);
#endif
#ifdef CONFIG_SCHED_MC
if (!err && mc_capable())
- err = sysfs_create_file(&cls->kset.kobj,
- &attr_sched_mc_power_savings.attr);
+ err = sysdev_class_create_file(cls,
+ &attr_sched_mc_power_savings);
#endif
return err;
}
_

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/