drivers: make device_attribute const
Subsystems (11)
cover drivers: make device_attribute const
Make these const. Done using Coccinelle.
@match disable optional_qualifier@
identifier s;
@@
static struct device_attribute s = {...};
@ref@
position p;
identifier match.s;
@@
s@p
@good1@
identifier match.s;
expression e1;
position ref.p;
@@device_remove_file(e1,&s@p,...)
@good2@
identifier match.s;
expression e1;
position ref.p;
@@device_create_file(e1,&s@p,...)
@bad depends on !good1 && !good2@
position ref.p;
identifier match.s;
@@
s@p
@depends on forall !bad disable optional_qualifier@ identifier match.s;
@@
static
+ const
struct device_attribute s;
Bhumika Goyal (6):
ACPI: make device_attribute const
nbd: make device_attribute const
hid: make device_attribute const
qlogic: make device_attribute const
platform/x86: make device_attribute const
power: supply: make device_attribute const
drivers/acpi/battery.c | 2 +- drivers/acpi/sbs.c | 2 +- drivers/block/nbd.c | 2 +- drivers/hid/hid-core.c | 2 +- drivers/net/ethernet/qlogic/netxen/netxen_nic_main.c | 4 ++-- drivers/net/ethernet/qlogic/qlcnic/qlcnic_sysfs.c | 6 +++--- drivers/platform/x86/classmate-laptop.c | 6 +++--- drivers/platform/x86/intel-rst.c | 4 ++-- drivers/power/supply/olpc_battery.c | 2 +- 9 files changed, 15 insertions(+), 15 deletions(-)
Signature · 1 line
1.9.1
PATCH 1/6 ACPI: make device_attribute const
Make these const as they are only passed as an argument to the function device_create_file and device_remove_file and the corresponding arguments are of type const.
Done using Coccinelle
--- drivers/acpi/battery.c | 2 +- drivers/acpi/sbs.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/acpi/battery.c +1 -1
@@ -620,7 +620,7 @@ static ssize_t acpi_battery_alarm_store(struct device *dev,return count; } -static struct device_attribute alarm_attr = { +static const struct device_attribute alarm_attr = { .attr = {.name ="alarm" , .mode =0644 }, .show = acpi_battery_alarm_show, .store = acpi_battery_alarm_store,
drivers/acpi/sbs.c +1 -1
@@ -474,7 +474,7 @@ static ssize_t acpi_battery_alarm_store(struct device *dev,return count; } -static struct device_attribute alarm_attr = { +static const struct device_attribute alarm_attr = { .attr = {.name ="alarm" , .mode =0644 }, .show = acpi_battery_alarm_show, .store = acpi_battery_alarm_store,
Signature · 1 line
1.9.1
PATCH 2/6 nbd: make device_attribute const
In reply to Bhumika GoyalMake this const as is is only passed as an argument to the function device_create_file and device_remove_file and the corresponding arguments are of type const.
Done using Coccinelle
--- drivers/block/nbd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/block/nbd.c +1 -1
@@ -165,7 +165,7 @@ static ssize_t pid_show(struct device *dev,return sprintf (buf,"%d\n" ,task_pid_nr (nbd->task_recv)); } -static struct device_attribute pid_attr = { +static const struct device_attribute pid_attr = { .attr = { .name ="pid" , .mode =S_IRUGO }, .show = pid_show, };
Signature · 6 lines
1.9.1 ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot
PATCH 3/6 hid: make device_attribute const
In reply to Bhumika GoyalMake this const as it is only passed as an argument to the function device_create_file and device_remove_file and the corresponding arguments are of type const.
Done using Coccinelle
--- drivers/hid/hid-core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/hid/hid-core.c +1 -1
@@ -1662,7 +1662,7 @@ static bool hid_hiddev(struct hid_device *hdev) .size = HID_MAX_DESCRIPTOR_SIZE, }; -static struct device_attribute dev_attr_country = { +static const struct device_attribute dev_attr_country = { .attr = { .name ="country" , .mode =0444 }, .show = show_country, };
Signature · 1 line
1.9.1
PATCH 4/6 qlogic: make device_attribute const
In reply to Bhumika GoyalMake these const as they are only passed as an argument to the function device_create_file and device_remove_file and the corresponding arguments are of type const.
Done using Coccinelle
--- drivers/net/ethernet/qlogic/netxen/netxen_nic_main.c | 4 ++-- drivers/net/ethernet/qlogic/qlcnic/qlcnic_sysfs.c | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-)
drivers/net/ethernet/qlogic/netxen/netxen_nic_main.c +2 -2
@@ -2828,7 +2828,7 @@ static void netxen_nic_poll_controller(struct net_device *netdev)return sprintf (buf,"%d\n" , bridged_mode); } -static struct device_attribute dev_attr_bridged_mode = { +static const struct device_attribute dev_attr_bridged_mode = { .attr = {.name ="bridged_mode" , .mode = (S_IRUGO |S_IWUSR )}, .show = netxen_show_bridged_mode, .store = netxen_store_bridged_mode,
@@ -2860,7 +2860,7 @@ static void netxen_nic_poll_controller(struct net_device *netdev) !!(adapter->flags & NETXEN_NIC_DIAG_ENABLED)); } -static struct device_attribute dev_attr_diag_mode = { +static const struct device_attribute dev_attr_diag_mode = { .attr = {.name ="diag_mode" , .mode = (S_IRUGO |S_IWUSR )}, .show = netxen_show_diag_mode, .store = netxen_store_diag_mode,
drivers/net/ethernet/qlogic/qlcnic/qlcnic_sysfs.c +3 -3
@@ -1174,19 +1174,19 @@ static ssize_t qlcnic_83xx_sysfs_flash_write_handler(struct file *filp,return size; } -static struct device_attribute dev_attr_bridged_mode = { +static const struct device_attribute dev_attr_bridged_mode = { .attr = {.name ="bridged_mode" , .mode = (S_IRUGO |S_IWUSR )}, .show = qlcnic_show_bridged_mode, .store = qlcnic_store_bridged_mode, }; -static struct device_attribute dev_attr_diag_mode = { +static const struct device_attribute dev_attr_diag_mode = { .attr = {.name ="diag_mode" , .mode = (S_IRUGO |S_IWUSR )}, .show = qlcnic_show_diag_mode, .store = qlcnic_store_diag_mode, }; -static struct device_attribute dev_attr_beacon = { +static const struct device_attribute dev_attr_beacon = { .attr = {.name ="beacon" , .mode = (S_IRUGO |S_IWUSR )}, .show = qlcnic_show_beacon, .store = qlcnic_store_beacon,
Signature · 1 line
1.9.1
PATCH 5/6 platform/x86: make device_attribute const
In reply to Bhumika GoyalMake these const as they are only passed as an argument to the function device_create_file and device_remove_file and the corresponding arguments are of type const.
Done using Coccinelle
--- drivers/platform/x86/classmate-laptop.c | 6 +++--- drivers/platform/x86/intel-rst.c | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-)
drivers/platform/x86/classmate-laptop.c +3 -3
@@ -254,7 +254,7 @@ static ssize_t cmpc_accel_sensitivity_store_v4(struct device *dev,return strnlen (buf, count); } -static struct device_attribute cmpc_accel_sensitivity_attr_v4 = { +static const struct device_attribute cmpc_accel_sensitivity_attr_v4 = { .attr = { .name ="sensitivity" , .mode =0660 }, .show = cmpc_accel_sensitivity_show_v4, .store = cmpc_accel_sensitivity_store_v4
@@ -303,7 +303,7 @@ static ssize_t cmpc_accel_g_select_store_v4(struct device *dev,return strnlen (buf, count); } -static struct device_attribute cmpc_accel_g_select_attr_v4 = { +static const struct device_attribute cmpc_accel_g_select_attr_v4 = { .attr = { .name ="g_select" , .mode =0660 }, .show = cmpc_accel_g_select_show_v4, .store = cmpc_accel_g_select_store_v4
@@ -599,7 +599,7 @@ static ssize_t cmpc_accel_sensitivity_store(struct device *dev,return strnlen (buf, count); } -static struct device_attribute cmpc_accel_sensitivity_attr = { +static const struct device_attribute cmpc_accel_sensitivity_attr = { .attr = { .name ="sensitivity" , .mode =0660 }, .show = cmpc_accel_sensitivity_show, .store = cmpc_accel_sensitivity_store
drivers/platform/x86/intel-rst.c +2 -2
@@ -65,7 +65,7 @@ static ssize_t irst_store_wakeup_events(struct device *dev,return count; } -static struct device_attribute irst_wakeup_attr = { +static const struct device_attribute irst_wakeup_attr = { .attr = { .name ="wakeup_events" , .mode =0600 }, .show = irst_show_wakeup_events, .store = irst_store_wakeup_events
@@ -111,7 +111,7 @@ static ssize_t irst_store_wakeup_time(struct device *dev,return count; } -static struct device_attribute irst_timeout_attr = { +static const struct device_attribute irst_timeout_attr = { .attr = { .name ="wakeup_time" , .mode =0600 }, .show = irst_show_wakeup_time, .store = irst_store_wakeup_time
Signature · 1 line
1.9.1
PATCH 6/6 power: supply: make device_attribute const
In reply to Bhumika GoyalMake these const as they are only passed as an argument to the function device_create_file and device_remove_file and the corresponding arguments are of type const.
Done using Coccinelle.
--- drivers/power/supply/olpc_battery.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/power/supply/olpc_battery.c +1 -1
@@ -559,7 +559,7 @@ static ssize_t olpc_bat_error_read(struct device *dev,return sprintf (buf,"%d\n" , ec_byte); } -static struct device_attribute olpc_bat_error = { +static const struct device_attribute olpc_bat_error = { .attr = { .name ="error" , .mode =S_IRUGO ,
Signature · 1 line
1.9.1
Rafael J. Wysocki
maintainerQuoted 41 lines · Bhumika Goyal
Make these const. Done using Coccinelle.
@match disable optional_qualifier@
identifier s;
@@
static structdevice_attributes = {...};@ref@
position p;
identifier match.s;
@@
s@p@good1@
identifier match.s;
expression e1;
position ref.p;
@@device_remove_file(e1,&s@p,...)@good2@
identifier match.s;
expression e1;
position ref.p;
@@device_create_file(e1,&s@p,...)@bad depends on !good1 && !good2@
position ref.p;
identifier match.s;
@@
s@p@depends on forall !bad disable optional_qualifier@ identifier match.s;
@@
static
+ const
structdevice_attributes;
Quoted 7 lines
Bhumika Goyal (6):
ACPI: makedevice_attributeconst
nbd: makedevice_attributeconst
hid: makedevice_attributeconst
qlogic: makedevice_attributeconst
platform/x86: makedevice_attributeconst
power: supply: makedevice_attributeconst
It would be better to send these patches separately, because they touch code maintained by different people and I guess no one will take the whole series.
I'll take care of the ACPI one, but the rest needs to go in via their proper trees.
Thanks,
Rafael
Quoted 41 lines · Bhumika Goyal
Make these const. Done using Coccinelle.
@match disable optional_qualifier@
identifier s;
@@
static structdevice_attributes = {...};@ref@
position p;
identifier match.s;
@@
s@p@good1@
identifier match.s;
expression e1;
position ref.p;
@@device_remove_file(e1,&s@p,...)@good2@
identifier match.s;
expression e1;
position ref.p;
@@device_create_file(e1,&s@p,...)@bad depends on !good1 && !good2@
position ref.p;
identifier match.s;
@@
s@p@depends on forall !bad disable optional_qualifier@ identifier match.s;
@@
static
+ const
structdevice_attributes;
Quoted 8 lines
Bhumika Goyal (6):
ACPI: makedevice_attributeconst
nbd: makedevice_attributeconst
hid: makedevice_attributeconst
qlogic: makedevice_attributeconst
platform/x86: makedevice_attributeconst
power: supply: makedevice_attributeconst
Hello all,
The patches are all independent, so please take what seems relevant.
Thanks,
Bhumika
Quoted 14 lines
drivers/acpi/battery.c | 2 +- drivers/acpi/sbs.c | 2 +- drivers/block/nbd.c | 2 +- drivers/hid/hid-core.c | 2 +- drivers/net/ethernet/qlogic/netxen/netxen_nic_main.c | 4 ++-- drivers/net/ethernet/qlogic/qlcnic/qlcnic_sysfs.c | 6 +++--- drivers/platform/x86/classmate-laptop.c | 6 +++--- drivers/platform/x86/intel-rst.c | 4 ++-- drivers/power/supply/olpc_battery.c | 2 +- 9 files changed, 15 insertions(+), 15 deletions(-)--
1.9.1
Quoted 50 lines · Rafael J. Wysocki
Quoted 41 lines · Bhumika Goyal
Make these const. Done using Coccinelle.
@match disable optional_qualifier@
identifier s;
@@
static structdevice_attributes = {...};@ref@
position p;
identifier match.s;
@@
s@p@good1@
identifier match.s;
expression e1;
position ref.p;
@@device_remove_file(e1,&s@p,...)@good2@
identifier match.s;
expression e1;
position ref.p;
@@device_create_file(e1,&s@p,...)@bad depends on !good1 && !good2@
position ref.p;
identifier match.s;
@@
s@p@depends on forall !bad disable optional_qualifier@ identifier match.s;
@@
static
+ const
structdevice_attributes;Quoted 7 lines
Bhumika Goyal (6):
ACPI: makedevice_attributeconst
nbd: makedevice_attributeconst
hid: makedevice_attributeconst
qlogic: makedevice_attributeconst
platform/x86: makedevice_attributeconst
power: supply: makedevice_attributeconst
Quoted 7 lines
It would be better to send these patches separately, because they touch code maintained by different people and I guess no one will take the whole series.
I'll take care of the ACPI one, but the rest needs to go in via their proper trees.
Thanks for the note. From now onwards, I will send it separately depending on the maintainers. But is possible please consider it this time.
Thanks,
Bhumika
Quoted 2 lines
Thanks,
Rafael
Re: [PATCH 5/6] platform/x86: make device_attribute const
In reply to Bhumika GoyalFor classmate-laptop.c
Re: [PATCH 4/6] qlogic: make device_attribute const
In reply to Bhumika GoyalFrom: Bhumika Goyal <[email protected]>
Date: Mon, 21 Aug 2017 17:13:10 +0530
Quoted 6 lines
Make these const as they are only passed as an argument to the function
device_create_fileanddevice_remove_fileand the corresponding arguments are of type const.
Done using CoccinelleSigned-off-by Bhumika Goyal <[email protected]>
Applied.
But I would seriously suggest that when you have to cross subsystems like this, just send the patches individually to the respective maintainers rather than trying to make a "series" out of it.
Thanks.
Re: [PATCH 4/6] qlogic: make device_attribute const
Quoted 8 lines · David Miller
From: Bhumika Goyal <[email protected]>
Date: Mon, 21 Aug 2017 17:13:10 +0530Quoted 5 lines
Make these const as they are only passed as an argument to the function
device_create_fileanddevice_remove_fileand the corresponding arguments are of type const.
Done using Coccinelle
Quoted 8 lines
Quoted 1 line
Signed-off-by Bhumika Goyal <[email protected]>Applied.
But I would seriously suggest that when you have to cross subsystems like this, just send the patches individually to the respective maintainers rather than trying to make a "series" out of it.
Yes, noted. Thanks for the pointer.
Thanks,
Bhumika
Quoted 1 line
Thanks.
Rafael J. Wysocki
AppliedRe: [PATCH 1/6] ACPI: make device_attribute const
In reply to Bhumika GoyalQuoted 30 lines · CEST Bhumika Goyal
Make these const as they are only passed as an argument to the function
device_create_fileanddevice_remove_fileand the corresponding arguments are of type const.
Done using CoccinelleSigned-off-by Bhumika Goyal <[email protected]>--- drivers/acpi/battery.c | 2 +- drivers/acpi/sbs.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)drivers/acpi/battery.c +1
-1@@ -620,7 +620,7 @@ static ssize_t acpi_battery_alarm_store(struct device *dev,return count; } -static struct device_attribute alarm_attr = { +static const struct device_attribute alarm_attr = { .attr = {.name ="alarm" , .mode =0644 }, .show = acpi_battery_alarm_show, .store = acpi_battery_alarm_store,drivers/acpi/sbs.c +0
-0
drivers/acpi/sbs.c static ssize_t acpi_battery_alarm_store(struct device *dev, · line 480
Quoted 8 lines
drivers/acpi/sbs.c +1
-1@@ -474,7 +474,7 @@ static ssize_t acpi_battery_alarm_store(struct device *dev,return count; } -static struct device_attribute alarm_attr = { +static const struct device_attribute alarm_attr = { .attr = {.name ="alarm" , .mode =0644 }, .show = acpi_battery_alarm_show, .store = acpi_battery_alarm_store,
Applied, thanks!
Jens Axboe
maintainerRe: [PATCH 2/6] nbd: make device_attribute const
In reply to Bhumika GoyalQuoted 4 lines · Bhumika Goyal
Make this const as is is only passed as an argument to the function
device_create_fileanddevice_remove_fileand the corresponding arguments are of type const.
Done using Coccinelle
Added for 4.14, thanks.
Signature · 1 line
Jens Axboe
Re: [PATCH 6/6] power: supply: make device_attribute const
In reply to Bhumika GoyalHi,
Quoted 7 lines · Bhumika Goyal
Make these const as they are only passed as an argument to the function
device_create_fileanddevice_remove_fileand the corresponding arguments are of type const.
Done using Coccinelle.Signed-off-by Bhumika Goyal <[email protected]>---
Thanks, queued.
-- Sebastian
Quoted 19 lines
drivers/power/supply/olpc_battery.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/power/supply/olpc_battery.c +1
-1@@ -559,7 +559,7 @@ static ssize_t olpc_bat_error_read(struct device *dev,return sprintf (buf,"%d\n" , ec_byte); } -static struct device_attribute olpc_bat_error = { +static const struct device_attribute olpc_bat_error = { .attr = { .name ="error" , .mode =S_IRUGO ,Signature · 1 line
1.9.1
Re: [PATCH 5/6] platform/x86: make device_attribute const
In reply to Bhumika GoyalQuoted 5 lines · Bhumika Goyal
Make these const as they are only passed as an argument to the function
device_create_fileanddevice_remove_fileand the corresponding arguments are of type const.
Done using Coccinelle
Split on per driver basis.
Quoted 62 lines
Signed-off-by Bhumika Goyal <[email protected]>--- drivers/platform/x86/classmate-laptop.c | 6 +++--- drivers/platform/x86/intel-rst.c | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-)drivers/platform/x86/classmate-laptop.c +3
-3@@ -254,7 +254,7 @@ static ssize_t cmpc_accel_sensitivity_store_v4(struct device *dev,return strnlen (buf, count); } -static struct device_attribute cmpc_accel_sensitivity_attr_v4 = { +static const struct device_attribute cmpc_accel_sensitivity_attr_v4 = { .attr = { .name ="sensitivity" , .mode =0660 }, .show = cmpc_accel_sensitivity_show_v4, .store = cmpc_accel_sensitivity_store_v4@@ -303,7 +303,7 @@ static ssize_t cmpc_accel_g_select_store_v4(struct device *dev,return strnlen (buf, count); } -static struct device_attribute cmpc_accel_g_select_attr_v4 = { +static const struct device_attribute cmpc_accel_g_select_attr_v4 = { .attr = { .name ="g_select" , .mode =0660 }, .show = cmpc_accel_g_select_show_v4, .store = cmpc_accel_g_select_store_v4@@ -599,7 +599,7 @@ static ssize_t cmpc_accel_sensitivity_store(struct device *dev,return strnlen (buf, count); } -static struct device_attribute cmpc_accel_sensitivity_attr = { +static const struct device_attribute cmpc_accel_sensitivity_attr = { .attr = { .name ="sensitivity" , .mode =0660 }, .show = cmpc_accel_sensitivity_show, .store = cmpc_accel_sensitivity_storedrivers/platform/x86/intel-rst.c +2
-3@@ -65,7 +65,7 @@ static ssize_t irst_store_wakeup_events(struct device *dev,return count; } -static struct device_attribute irst_wakeup_attr = { +static const struct device_attribute irst_wakeup_attr = { .attr = { .name ="wakeup_events" , .mode =0600 }, .show = irst_show_wakeup_events, .store = irst_store_wakeup_events@@ -111,7 +111,7 @@ static ssize_t irst_store_wakeup_time(struct device *dev,return count; } -static struct device_attribute irst_timeout_attr = { +static const struct device_attribute irst_timeout_attr = { .attr = { .name ="wakeup_time" , .mode =0600 }, .show = irst_show_wakeup_time, .store = irst_store_wakeup_time --1.9.1
Signature · 2 lines
With Best Regards, Andy Shevchenko
Re: [PATCH 3/6] hid: make device_attribute const
In reply to Bhumika GoyalQuoted 15 lines · Bhumika Goyal
Make this const as it is only passed as an argument to the function
device_create_fileanddevice_remove_fileand the corresponding arguments are of type const.
Done using CoccinelleSigned-off-by Bhumika Goyal <[email protected]>--- drivers/hid/hid-core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/hid/hid-core.c +0
-0
drivers/hid/hid-core.c static bool hid_hiddev(struct hid_device *hdev) · line 1667
Quoted 7 lines
drivers/hid/hid-core.c +1
-1@@ -1662,7 +1662,7 @@ static bool hid_hiddev(struct hid_device *hdev) .size = HID_MAX_DESCRIPTOR_SIZE, }; -static struct device_attribute dev_attr_country = { +static const struct device_attribute dev_attr_country = { .attr = { .name ="country" , .mode =0444 }, .show = show_country,
Applied, thanks.
Signature · 2 lines
Jiri Kosina SUSE Labs