2017-08-21 11:43:42

by Bhumika Goyal

[permalink] [raw]
Subject: [PATCH 0/6] 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(-)

--
1.9.1


2017-08-21 11:43:53

by Bhumika Goyal

[permalink] [raw]
Subject: [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

Signed-off-by: Bhumika Goyal <[email protected]>
---
drivers/acpi/battery.c | 2 +-
drivers/acpi/sbs.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c
index 1cbb88d..13e7b56 100644
--- a/drivers/acpi/battery.c
+++ b/drivers/acpi/battery.c
@@ -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,
diff --git a/drivers/acpi/sbs.c b/drivers/acpi/sbs.c
index a184637..a2428e9 100644
--- a/drivers/acpi/sbs.c
+++ b/drivers/acpi/sbs.c
@@ -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,
--
1.9.1

2017-08-21 11:44:07

by Bhumika Goyal

[permalink] [raw]
Subject: [PATCH 2/6] nbd: make device_attribute const

Make 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

Signed-off-by: Bhumika Goyal <[email protected]>
---
drivers/block/nbd.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c
index 5bdf923..49d7763 100644
--- a/drivers/block/nbd.c
+++ b/drivers/block/nbd.c
@@ -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,
};
--
1.9.1

2017-08-21 11:44:16

by Bhumika Goyal

[permalink] [raw]
Subject: [PATCH 3/6] hid: make device_attribute const

Make 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

Signed-off-by: Bhumika Goyal <[email protected]>
---
drivers/hid/hid-core.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
index 9bc9116..24e929c 100644
--- a/drivers/hid/hid-core.c
+++ b/drivers/hid/hid-core.c
@@ -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,
};
--
1.9.1

2017-08-21 11:44:29

by Bhumika Goyal

[permalink] [raw]
Subject: [PATCH 4/6] qlogic: 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

Signed-off-by: Bhumika Goyal <[email protected]>
---
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(-)

diff --git a/drivers/net/ethernet/qlogic/netxen/netxen_nic_main.c b/drivers/net/ethernet/qlogic/netxen/netxen_nic_main.c
index 827de83..f2e8de6 100644
--- a/drivers/net/ethernet/qlogic/netxen/netxen_nic_main.c
+++ b/drivers/net/ethernet/qlogic/netxen/netxen_nic_main.c
@@ -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,
diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_sysfs.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_sysfs.c
index 82fcb83..287d89d 100644
--- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_sysfs.c
+++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_sysfs.c
@@ -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,
--
1.9.1

2017-08-21 11:44:42

by Bhumika Goyal

[permalink] [raw]
Subject: [PATCH 5/6] platform/x86: 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

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(-)

diff --git a/drivers/platform/x86/classmate-laptop.c b/drivers/platform/x86/classmate-laptop.c
index 55cf10b..d3715e2 100644
--- a/drivers/platform/x86/classmate-laptop.c
+++ b/drivers/platform/x86/classmate-laptop.c
@@ -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
diff --git a/drivers/platform/x86/intel-rst.c b/drivers/platform/x86/intel-rst.c
index 7344d84..760a9bf 100644
--- a/drivers/platform/x86/intel-rst.c
+++ b/drivers/platform/x86/intel-rst.c
@@ -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

2017-08-21 11:44:53

by Bhumika Goyal

[permalink] [raw]
Subject: [PATCH 6/6] power: supply: 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.

Signed-off-by: Bhumika Goyal <[email protected]>
---
drivers/power/supply/olpc_battery.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/power/supply/olpc_battery.c b/drivers/power/supply/olpc_battery.c
index fc20ca3..3bc2eea 100644
--- a/drivers/power/supply/olpc_battery.c
+++ b/drivers/power/supply/olpc_battery.c
@@ -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,
--
1.9.1

2017-08-21 12:28:35

by Rafael J. Wysocki

[permalink] [raw]
Subject: Re: [PATCH 0/6] drivers: make device_attribute const

On Mon, Aug 21, 2017 at 1:43 PM, Bhumika Goyal <[email protected]> wrote:
> 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

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

2017-08-21 12:55:19

by Bhumika Goyal

[permalink] [raw]
Subject: Re: [PATCH 0/6] drivers: make device_attribute const

On Mon, Aug 21, 2017 at 5:13 PM, Bhumika Goyal <[email protected]> wrote:
> 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
>

Hello all,

The patches are all independent, so please take what seems relevant.

Thanks,
Bhumika

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

2017-08-21 12:57:37

by Bhumika Goyal

[permalink] [raw]
Subject: Re: [PATCH 0/6] drivers: make device_attribute const

On Mon, Aug 21, 2017 at 5:58 PM, Rafael J. Wysocki <[email protected]> wrote:
> On Mon, Aug 21, 2017 at 1:43 PM, Bhumika Goyal <[email protected]> wrote:
>> 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
>
> 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

> Thanks,
> Rafael

Subject: Re: [PATCH 5/6] platform/x86: make device_attribute const

For classmate-laptop.c

Acked-by: Thadeu Lima de Souza Cascardo <[email protected]>

2017-08-21 17:25:11

by David Miller

[permalink] [raw]
Subject: Re: [PATCH 4/6] qlogic: make device_attribute const

From: Bhumika Goyal <[email protected]>
Date: Mon, 21 Aug 2017 17:13:10 +0530

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

Thanks.

2017-08-21 17:27:01

by Bhumika Goyal

[permalink] [raw]
Subject: Re: [PATCH 4/6] qlogic: make device_attribute const

On Mon, Aug 21, 2017 at 10:55 PM, David Miller <[email protected]> wrote:
> From: Bhumika Goyal <[email protected]>
> Date: Mon, 21 Aug 2017 17:13:10 +0530
>
>> 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
>>
>> 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

> Thanks.

2017-08-28 21:04:50

by Rafael J. Wysocki

[permalink] [raw]
Subject: Re: [PATCH 1/6] ACPI: make device_attribute const

On Monday, August 21, 2017 1:43:07 PM CEST Bhumika Goyal wrote:
> 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
>
> Signed-off-by: Bhumika Goyal <[email protected]>
> ---
> drivers/acpi/battery.c | 2 +-
> drivers/acpi/sbs.c | 2 +-
> 2 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c
> index 1cbb88d..13e7b56 100644
> --- a/drivers/acpi/battery.c
> +++ b/drivers/acpi/battery.c
> @@ -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,
> diff --git a/drivers/acpi/sbs.c b/drivers/acpi/sbs.c
> index a184637..a2428e9 100644
> --- a/drivers/acpi/sbs.c
> +++ b/drivers/acpi/sbs.c
> @@ -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!


2017-08-28 21:22:09

by Jens Axboe

[permalink] [raw]
Subject: Re: [PATCH 2/6] nbd: make device_attribute const

On 08/21/2017 05:43 AM, Bhumika Goyal wrote:
> Make 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

Added for 4.14, thanks.

--
Jens Axboe

2017-08-29 08:44:29

by Sebastian Reichel

[permalink] [raw]
Subject: Re: [PATCH 6/6] power: supply: make device_attribute const

Hi,

On Mon, Aug 21, 2017 at 05:13:12PM +0530, Bhumika Goyal wrote:
> 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.
>
> Signed-off-by: Bhumika Goyal <[email protected]>
> ---

Thanks, queued.

-- Sebastian

> drivers/power/supply/olpc_battery.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/power/supply/olpc_battery.c b/drivers/power/supply/olpc_battery.c
> index fc20ca3..3bc2eea 100644
> --- a/drivers/power/supply/olpc_battery.c
> +++ b/drivers/power/supply/olpc_battery.c
> @@ -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,
> --
> 1.9.1
>


Attachments:
(No filename) (979.00 B)
signature.asc (833.00 B)
Download all attachments

2017-08-30 19:18:34

by Andy Shevchenko

[permalink] [raw]
Subject: Re: [PATCH 5/6] platform/x86: make device_attribute const

On Mon, Aug 21, 2017 at 2:43 PM, Bhumika Goyal <[email protected]> wrote:
> 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
>

Split on per driver basis.

> 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(-)
>
> diff --git a/drivers/platform/x86/classmate-laptop.c b/drivers/platform/x86/classmate-laptop.c
> index 55cf10b..d3715e2 100644
> --- a/drivers/platform/x86/classmate-laptop.c
> +++ b/drivers/platform/x86/classmate-laptop.c
> @@ -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
> diff --git a/drivers/platform/x86/intel-rst.c b/drivers/platform/x86/intel-rst.c
> index 7344d84..760a9bf 100644
> --- a/drivers/platform/x86/intel-rst.c
> +++ b/drivers/platform/x86/intel-rst.c
> @@ -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
>



--
With Best Regards,
Andy Shevchenko

2017-09-06 08:57:40

by Jiri Kosina

[permalink] [raw]
Subject: Re: [PATCH 3/6] hid: make device_attribute const

On Mon, 21 Aug 2017, Bhumika Goyal wrote:

> Make 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
>
> Signed-off-by: Bhumika Goyal <[email protected]>
> ---
> drivers/hid/hid-core.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
> index 9bc9116..24e929c 100644
> --- a/drivers/hid/hid-core.c
> +++ b/drivers/hid/hid-core.c
> @@ -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.

--
Jiri Kosina
SUSE Labs