mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-29 19:21:31 -04:00
device_attributes: add sysfs_attr_init() for dynamic attributes
Made necessary by 6992f53349 ("sysfs: Use
one lockdep class per sysfs attribute").
Prevents further "key xxx not in .data" bug-reports. Although some
attributes could probably be converted to static ones, this is left for
people having hardware to test.
Found by this semantic patch:
@ init @
type T;
identifier A;
@@
T {
...
struct device_attribute A;
...
};
@ main extends init @
expression E;
statement S;
identifier err;
T *name;
@@
... when != sysfs_attr_init(&name->A.attr);
(
+ sysfs_attr_init(&name->A.attr);
if (device_create_file(E, &name->A))
S
|
+ sysfs_attr_init(&name->A.attr);
err = device_create_file(E, &name->A);
)
While reviewing, I put the initialization to apropriate places.
Signed-off-by: Wolfram Sang <[email protected]>
Cc: Eric W. Biederman <[email protected]>
Cc: Greg KH <[email protected]>
Cc: Benjamin Herrenschmidt <[email protected]>
Cc: Grant Likely <[email protected]>
Cc: Mike Isely <[email protected]>
Cc: Mauro Carvalho Chehab <[email protected]>
Cc: Sujith Thomas <[email protected]>
Cc: Matthew Garrett <[email protected]>
Cc: Len Brown <[email protected]>
Cc: Krzysztof Helt <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
This commit is contained in:
parent
975f8c5653
commit
12765517d9
4 changed files with 11 additions and 0 deletions
|
|
@ -423,10 +423,12 @@ static void pvr2_sysfs_add_debugifc(struct pvr2_sysfs *sfp)
|
|||
|
||||
dip = kzalloc(sizeof(*dip),GFP_KERNEL);
|
||||
if (!dip) return;
|
||||
sysfs_attr_init(&dip->attr_debugcmd.attr);
|
||||
dip->attr_debugcmd.attr.name = "debugcmd";
|
||||
dip->attr_debugcmd.attr.mode = S_IRUGO|S_IWUSR|S_IWGRP;
|
||||
dip->attr_debugcmd.show = debugcmd_show;
|
||||
dip->attr_debugcmd.store = debugcmd_store;
|
||||
sysfs_attr_init(&dip->attr_debuginfo.attr);
|
||||
dip->attr_debuginfo.attr.name = "debuginfo";
|
||||
dip->attr_debuginfo.attr.mode = S_IRUGO;
|
||||
dip->attr_debuginfo.show = debuginfo_show;
|
||||
|
|
@ -644,6 +646,7 @@ static void class_dev_create(struct pvr2_sysfs *sfp,
|
|||
return;
|
||||
}
|
||||
|
||||
sysfs_attr_init(&sfp->attr_v4l_minor_number.attr);
|
||||
sfp->attr_v4l_minor_number.attr.name = "v4l_minor_number";
|
||||
sfp->attr_v4l_minor_number.attr.mode = S_IRUGO;
|
||||
sfp->attr_v4l_minor_number.show = v4l_minor_number_show;
|
||||
|
|
@ -658,6 +661,7 @@ static void class_dev_create(struct pvr2_sysfs *sfp,
|
|||
sfp->v4l_minor_number_created_ok = !0;
|
||||
}
|
||||
|
||||
sysfs_attr_init(&sfp->attr_v4l_radio_minor_number.attr);
|
||||
sfp->attr_v4l_radio_minor_number.attr.name = "v4l_radio_minor_number";
|
||||
sfp->attr_v4l_radio_minor_number.attr.mode = S_IRUGO;
|
||||
sfp->attr_v4l_radio_minor_number.show = v4l_radio_minor_number_show;
|
||||
|
|
@ -672,6 +676,7 @@ static void class_dev_create(struct pvr2_sysfs *sfp,
|
|||
sfp->v4l_radio_minor_number_created_ok = !0;
|
||||
}
|
||||
|
||||
sysfs_attr_init(&sfp->attr_unit_number.attr);
|
||||
sfp->attr_unit_number.attr.name = "unit_number";
|
||||
sfp->attr_unit_number.attr.mode = S_IRUGO;
|
||||
sfp->attr_unit_number.show = unit_number_show;
|
||||
|
|
@ -685,6 +690,7 @@ static void class_dev_create(struct pvr2_sysfs *sfp,
|
|||
sfp->unit_number_created_ok = !0;
|
||||
}
|
||||
|
||||
sysfs_attr_init(&sfp->attr_bus_info.attr);
|
||||
sfp->attr_bus_info.attr.name = "bus_info_str";
|
||||
sfp->attr_bus_info.attr.mode = S_IRUGO;
|
||||
sfp->attr_bus_info.show = bus_info_show;
|
||||
|
|
@ -699,6 +705,7 @@ static void class_dev_create(struct pvr2_sysfs *sfp,
|
|||
sfp->bus_info_created_ok = !0;
|
||||
}
|
||||
|
||||
sysfs_attr_init(&sfp->attr_hdw_name.attr);
|
||||
sfp->attr_hdw_name.attr.name = "device_hardware_type";
|
||||
sfp->attr_hdw_name.attr.mode = S_IRUGO;
|
||||
sfp->attr_hdw_name.show = hdw_name_show;
|
||||
|
|
@ -713,6 +720,7 @@ static void class_dev_create(struct pvr2_sysfs *sfp,
|
|||
sfp->hdw_name_created_ok = !0;
|
||||
}
|
||||
|
||||
sysfs_attr_init(&sfp->attr_hdw_desc.attr);
|
||||
sfp->attr_hdw_desc.attr.name = "device_hardware_description";
|
||||
sfp->attr_hdw_desc.attr.mode = S_IRUGO;
|
||||
sfp->attr_hdw_desc.show = hdw_desc_show;
|
||||
|
|
|
|||
Loading…
Reference in a new issue