Re: [PATCH] init dynamic bin_attribute structures

From: Jiri Kosina
Date: Mon Mar 15 2010 - 06:00:27 EST


On Mon, 15 Mar 2010, Wolfram Sang wrote:

> Commit 6992f5334995af474c2b58d010d08bc597f0f2fe introduced this requirement.
> First, at25 was fixed manually. Then, other occurences were found with
> coccinelle and the following semantic patch. Results were reviewed and fixed
> up:
>
> @ init @
> identifier struct_name, bin;
> @@
>
> struct struct_name {
> ...
> struct bin_attribute bin;
> ...
> };
>
> @ main extends init @
> expression E;
> statement S;
> identifier name, err;
> @@
>
> (
> struct struct_name *name;
> |
> - struct struct_name *name = NULL;
> + struct struct_name *name;
> )
> ...
> (
> sysfs_bin_attr_init(&name->bin);
> |
> + sysfs_bin_attr_init(&name->bin);
> if (sysfs_create_bin_file(E, &name->bin))
> S
> |
> + sysfs_bin_attr_init(&name->bin);
> err = sysfs_create_bin_file(E, &name->bin);
> )
>
> Signed-off-by: Wolfram Sang <w.sang@xxxxxxxxxxxxxx>
> Cc: Eric W. Biederman <ebiederm@xxxxxxxxxxxx>
> Cc: Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx>
> ---
> arch/mips/txx9/generic/setup.c | 1 +
> drivers/misc/eeprom/at25.c | 1 +
> drivers/rtc/rtc-ds1742.c | 1 +
> 3 files changed, 3 insertions(+), 0 deletions(-)

I don't understand how cocinelle works, but the resulting patch seems to
be incomplete.

The fix is needed at least in firmware loader (for which Greg has already
queued patch), in ACPI thermal driver [1], etc).

[1] http://lkml.indiana.edu/hypermail/linux/kernel/1003.1/02680.html

--
Jiri Kosina
SUSE Labs, Novell Inc.

--
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/