2021-09-21 03:56:12

by Rikard Falkeborn

[permalink] [raw]
Subject: [PATCH] thermal: thermal_mmio: Constify static struct thermal_mmio_ops

The only usage of thermal_mmio_ops is to pass its address to
devm_thermal_zone_of_sensor_register(), which has a pointer to const
struct thermal_zone_of_device_ops as argument. Make it const to allow
the compiler to put it in read-only memory.

Signed-off-by: Rikard Falkeborn <[email protected]>
---
drivers/thermal/thermal_mmio.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/thermal/thermal_mmio.c b/drivers/thermal/thermal_mmio.c
index ded1dd0d4ef7..360b0dfdc3b0 100644
--- a/drivers/thermal/thermal_mmio.c
+++ b/drivers/thermal/thermal_mmio.c
@@ -34,7 +34,7 @@ static int thermal_mmio_get_temperature(void *private, int *temp)
return 0;
}

-static struct thermal_zone_of_device_ops thermal_mmio_ops = {
+static const struct thermal_zone_of_device_ops thermal_mmio_ops = {
.get_temp = thermal_mmio_get_temperature,
};

--
2.33.0


2021-09-22 11:03:08

by Shenhar, Talel

[permalink] [raw]
Subject: Re: thermal: thermal_mmio: Constify static struct thermal_mmio_ops

The only usage of thermal_mmio_ops is to pass its address to
> devm_thermal_zone_of_sensor_register(), which has a pointer to const
> struct thermal_zone_of_device_ops as argument. Make it const to allow
> the compiler to put it in read-only memory.
>
> Signed-off-by: Rikard Falkeborn <[email protected]>
Acked-by: Talel Shenhar <[email protected]>
> ---
> drivers/thermal/thermal_mmio.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/thermal/thermal_mmio.c b/drivers/thermal/thermal_mmio.c
> index ded1dd0d4ef7..360b0dfdc3b0 100644
> --- a/drivers/thermal/thermal_mmio.c
> +++ b/drivers/thermal/thermal_mmio.c
> @@ -34,7 +34,7 @@ static int thermal_mmio_get_temperature(void *private, int *temp)
> return 0;
> }
>
> -static struct thermal_zone_of_device_ops thermal_mmio_ops = {
> +static const struct thermal_zone_of_device_ops thermal_mmio_ops = {
> .get_temp = thermal_mmio_get_temperature,
> };
>
> --
> 2.33.0
>

2021-10-05 14:38:32

by Rafael J. Wysocki

[permalink] [raw]
Subject: Re: [PATCH] thermal: thermal_mmio: Constify static struct thermal_mmio_ops

On Tue, Sep 21, 2021 at 3:55 AM Rikard Falkeborn
<[email protected]> wrote:
>
> The only usage of thermal_mmio_ops is to pass its address to
> devm_thermal_zone_of_sensor_register(), which has a pointer to const
> struct thermal_zone_of_device_ops as argument. Make it const to allow
> the compiler to put it in read-only memory.
>
> Signed-off-by: Rikard Falkeborn <[email protected]>
> ---
> drivers/thermal/thermal_mmio.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/thermal/thermal_mmio.c b/drivers/thermal/thermal_mmio.c
> index ded1dd0d4ef7..360b0dfdc3b0 100644
> --- a/drivers/thermal/thermal_mmio.c
> +++ b/drivers/thermal/thermal_mmio.c
> @@ -34,7 +34,7 @@ static int thermal_mmio_get_temperature(void *private, int *temp)
> return 0;
> }
>
> -static struct thermal_zone_of_device_ops thermal_mmio_ops = {
> +static const struct thermal_zone_of_device_ops thermal_mmio_ops = {
> .get_temp = thermal_mmio_get_temperature,
> };
>
> --

I'm not sure what happened to this patch.

Daniel, are you going to pick it up?

2021-10-05 16:53:51

by Daniel Lezcano

[permalink] [raw]
Subject: Re: [PATCH] thermal: thermal_mmio: Constify static struct thermal_mmio_ops

On 05/10/2021 16:36, Rafael J. Wysocki wrote:
> On Tue, Sep 21, 2021 at 3:55 AM Rikard Falkeborn
> <[email protected]> wrote:
>>
>> The only usage of thermal_mmio_ops is to pass its address to
>> devm_thermal_zone_of_sensor_register(), which has a pointer to const
>> struct thermal_zone_of_device_ops as argument. Make it const to allow
>> the compiler to put it in read-only memory.
>>
>> Signed-off-by: Rikard Falkeborn <[email protected]>
>> ---
>> drivers/thermal/thermal_mmio.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/thermal/thermal_mmio.c b/drivers/thermal/thermal_mmio.c
>> index ded1dd0d4ef7..360b0dfdc3b0 100644
>> --- a/drivers/thermal/thermal_mmio.c
>> +++ b/drivers/thermal/thermal_mmio.c
>> @@ -34,7 +34,7 @@ static int thermal_mmio_get_temperature(void *private, int *temp)
>> return 0;
>> }
>>
>> -static struct thermal_zone_of_device_ops thermal_mmio_ops = {
>> +static const struct thermal_zone_of_device_ops thermal_mmio_ops = {
>> .get_temp = thermal_mmio_get_temperature,
>> };
>>
>> --
>
> I'm not sure what happened to this patch.
>
> Daniel, are you going to pick it up?

Yes.

I had picked also the intel ones but I'll drop them.




--
<http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs

Follow Linaro: <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog