[1/2] thermal: core: constify params in thermal_zone_device_register

Message ID 20230708112720.2897484-1-a.fatoum@pengutronix.de
State New
Headers
Series [1/2] thermal: core: constify params in thermal_zone_device_register |

Commit Message

Ahmad Fatoum July 8, 2023, 11:27 a.m. UTC
  Since commit 3d439b1a2ad3 ("thermal/core: Alloc-copy-free the thermal zone
parameters structure"), thermal_zone_device_register() allocates a copy
of the tzp argument and callers need not explicitly manage its lifetime.

This means the function no longer cares about the parameter being
mutable, so constify it.

No functional change.

Fixes: 3d439b1a2ad3 ("thermal/core: Alloc-copy-free the thermal zone parameters structure")
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 drivers/thermal/thermal_core.c | 4 ++--
 include/linux/thermal.h        | 6 +++---
 2 files changed, 5 insertions(+), 5 deletions(-)
  

Comments

Rafael J. Wysocki July 10, 2023, 5:33 p.m. UTC | #1
On Sat, Jul 8, 2023 at 1:27 PM Ahmad Fatoum <a.fatoum@pengutronix.de> wrote:
>
> Since commit 3d439b1a2ad3 ("thermal/core: Alloc-copy-free the thermal zone
> parameters structure"), thermal_zone_device_register() allocates a copy
> of the tzp argument and callers need not explicitly manage its lifetime.
>
> This means the function no longer cares about the parameter being
> mutable, so constify it.
>
> No functional change.
>
> Fixes: 3d439b1a2ad3 ("thermal/core: Alloc-copy-free the thermal zone parameters structure")

Why is this particular patch regarded as a fix?

> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
> ---
>  drivers/thermal/thermal_core.c | 4 ++--
>  include/linux/thermal.h        | 6 +++---
>  2 files changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c
> index 842f678c1c3e..cc2b5e81c620 100644
> --- a/drivers/thermal/thermal_core.c
> +++ b/drivers/thermal/thermal_core.c
> @@ -1203,7 +1203,7 @@ EXPORT_SYMBOL_GPL(thermal_zone_get_crit_temp);
>  struct thermal_zone_device *
>  thermal_zone_device_register_with_trips(const char *type, struct thermal_trip *trips, int num_trips, int mask,
>                                         void *devdata, struct thermal_zone_device_ops *ops,
> -                                       struct thermal_zone_params *tzp, int passive_delay,
> +                                       const struct thermal_zone_params *tzp, int passive_delay,
>                                         int polling_delay)
>  {
>         struct thermal_zone_device *tz;
> @@ -1371,7 +1371,7 @@ EXPORT_SYMBOL_GPL(thermal_zone_device_register_with_trips);
>
>  struct thermal_zone_device *thermal_zone_device_register(const char *type, int ntrips, int mask,
>                                                          void *devdata, struct thermal_zone_device_ops *ops,
> -                                                        struct thermal_zone_params *tzp, int passive_delay,
> +                                                        const struct thermal_zone_params *tzp, int passive_delay,
>                                                          int polling_delay)
>  {
>         return thermal_zone_device_register_with_trips(type, NULL, ntrips, mask,
> diff --git a/include/linux/thermal.h b/include/linux/thermal.h
> index 87837094d549..dee66ade89a0 100644
> --- a/include/linux/thermal.h
> +++ b/include/linux/thermal.h
> @@ -301,14 +301,14 @@ int thermal_acpi_critical_trip_temp(struct acpi_device *adev, int *ret_temp);
>  #ifdef CONFIG_THERMAL
>  struct thermal_zone_device *thermal_zone_device_register(const char *, int, int,
>                 void *, struct thermal_zone_device_ops *,
> -               struct thermal_zone_params *, int, int);
> +               const struct thermal_zone_params *, int, int);
>
>  void thermal_zone_device_unregister(struct thermal_zone_device *);
>
>  struct thermal_zone_device *
>  thermal_zone_device_register_with_trips(const char *, struct thermal_trip *, int, int,
>                                         void *, struct thermal_zone_device_ops *,
> -                                       struct thermal_zone_params *, int, int);
> +                                       const struct thermal_zone_params *, int, int);
>
>  void *thermal_zone_device_priv(struct thermal_zone_device *tzd);
>  const char *thermal_zone_device_type(struct thermal_zone_device *tzd);
> @@ -348,7 +348,7 @@ void thermal_zone_device_critical(struct thermal_zone_device *tz);
>  static inline struct thermal_zone_device *thermal_zone_device_register(
>         const char *type, int trips, int mask, void *devdata,
>         struct thermal_zone_device_ops *ops,
> -       struct thermal_zone_params *tzp,
> +       const struct thermal_zone_params *tzp,
>         int passive_delay, int polling_delay)
>  { return ERR_PTR(-ENODEV); }
>  static inline void thermal_zone_device_unregister(
> --
> 2.39.2
>
  
Ahmad Fatoum July 10, 2023, 7:21 p.m. UTC | #2
Hello,

On 10.07.23 19:33, Rafael J. Wysocki wrote:
> On Sat, Jul 8, 2023 at 1:27 PM Ahmad Fatoum <a.fatoum@pengutronix.de> wrote:
>>
>> Since commit 3d439b1a2ad3 ("thermal/core: Alloc-copy-free the thermal zone
>> parameters structure"), thermal_zone_device_register() allocates a copy
>> of the tzp argument and callers need not explicitly manage its lifetime.
>>
>> This means the function no longer cares about the parameter being
>> mutable, so constify it.
>>
>> No functional change.
>>
>> Fixes: 3d439b1a2ad3 ("thermal/core: Alloc-copy-free the thermal zone parameters structure")
> 
> Why is this particular patch regarded as a fix?

That the prototype wasn't adjust in aforementioned commit is IMO an oversight,
so this commit fixes that. As the commit is already referenced in the commit
message body, I don't mind dropping the Fixes: line. Please let me know if
I should resend.

Cheers,
Ahmad

>> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
>> ---
>>  drivers/thermal/thermal_core.c | 4 ++--
>>  include/linux/thermal.h        | 6 +++---
>>  2 files changed, 5 insertions(+), 5 deletions(-)
>>
>> diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c
>> index 842f678c1c3e..cc2b5e81c620 100644
>> --- a/drivers/thermal/thermal_core.c
>> +++ b/drivers/thermal/thermal_core.c
>> @@ -1203,7 +1203,7 @@ EXPORT_SYMBOL_GPL(thermal_zone_get_crit_temp);
>>  struct thermal_zone_device *
>>  thermal_zone_device_register_with_trips(const char *type, struct thermal_trip *trips, int num_trips, int mask,
>>                                         void *devdata, struct thermal_zone_device_ops *ops,
>> -                                       struct thermal_zone_params *tzp, int passive_delay,
>> +                                       const struct thermal_zone_params *tzp, int passive_delay,
>>                                         int polling_delay)
>>  {
>>         struct thermal_zone_device *tz;
>> @@ -1371,7 +1371,7 @@ EXPORT_SYMBOL_GPL(thermal_zone_device_register_with_trips);
>>
>>  struct thermal_zone_device *thermal_zone_device_register(const char *type, int ntrips, int mask,
>>                                                          void *devdata, struct thermal_zone_device_ops *ops,
>> -                                                        struct thermal_zone_params *tzp, int passive_delay,
>> +                                                        const struct thermal_zone_params *tzp, int passive_delay,
>>                                                          int polling_delay)
>>  {
>>         return thermal_zone_device_register_with_trips(type, NULL, ntrips, mask,
>> diff --git a/include/linux/thermal.h b/include/linux/thermal.h
>> index 87837094d549..dee66ade89a0 100644
>> --- a/include/linux/thermal.h
>> +++ b/include/linux/thermal.h
>> @@ -301,14 +301,14 @@ int thermal_acpi_critical_trip_temp(struct acpi_device *adev, int *ret_temp);
>>  #ifdef CONFIG_THERMAL
>>  struct thermal_zone_device *thermal_zone_device_register(const char *, int, int,
>>                 void *, struct thermal_zone_device_ops *,
>> -               struct thermal_zone_params *, int, int);
>> +               const struct thermal_zone_params *, int, int);
>>
>>  void thermal_zone_device_unregister(struct thermal_zone_device *);
>>
>>  struct thermal_zone_device *
>>  thermal_zone_device_register_with_trips(const char *, struct thermal_trip *, int, int,
>>                                         void *, struct thermal_zone_device_ops *,
>> -                                       struct thermal_zone_params *, int, int);
>> +                                       const struct thermal_zone_params *, int, int);
>>
>>  void *thermal_zone_device_priv(struct thermal_zone_device *tzd);
>>  const char *thermal_zone_device_type(struct thermal_zone_device *tzd);
>> @@ -348,7 +348,7 @@ void thermal_zone_device_critical(struct thermal_zone_device *tz);
>>  static inline struct thermal_zone_device *thermal_zone_device_register(
>>         const char *type, int trips, int mask, void *devdata,
>>         struct thermal_zone_device_ops *ops,
>> -       struct thermal_zone_params *tzp,
>> +       const struct thermal_zone_params *tzp,
>>         int passive_delay, int polling_delay)
>>  { return ERR_PTR(-ENODEV); }
>>  static inline void thermal_zone_device_unregister(
>> --
>> 2.39.2
>>
>
  
Daniel Lezcano July 13, 2023, 12:55 p.m. UTC | #3
On 08/07/2023 13:27, Ahmad Fatoum wrote:
> Since commit 3d439b1a2ad3 ("thermal/core: Alloc-copy-free the thermal zone
> parameters structure"), thermal_zone_device_register() allocates a copy
> of the tzp argument and callers need not explicitly manage its lifetime.
> 
> This means the function no longer cares about the parameter being
> mutable, so constify it.
> 
> No functional change.
> 
> Fixes: 3d439b1a2ad3 ("thermal/core: Alloc-copy-free the thermal zone parameters structure")
> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
> ---

Acked-by: Daniel Lezcano <daniel.lezcano@linaro.org>
  
Rafael J. Wysocki July 20, 2023, 6:58 p.m. UTC | #4
On Thu, Jul 13, 2023 at 2:55 PM Daniel Lezcano
<daniel.lezcano@linaro.org> wrote:
>
> On 08/07/2023 13:27, Ahmad Fatoum wrote:
> > Since commit 3d439b1a2ad3 ("thermal/core: Alloc-copy-free the thermal zone
> > parameters structure"), thermal_zone_device_register() allocates a copy
> > of the tzp argument and callers need not explicitly manage its lifetime.
> >
> > This means the function no longer cares about the parameter being
> > mutable, so constify it.
> >
> > No functional change.
> >
> > Fixes: 3d439b1a2ad3 ("thermal/core: Alloc-copy-free the thermal zone parameters structure")
> > Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
> > ---
>
> Acked-by: Daniel Lezcano <daniel.lezcano@linaro.org>

Both patches in the series applied as 6.5-rc material, thanks!
  

Patch

diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c
index 842f678c1c3e..cc2b5e81c620 100644
--- a/drivers/thermal/thermal_core.c
+++ b/drivers/thermal/thermal_core.c
@@ -1203,7 +1203,7 @@  EXPORT_SYMBOL_GPL(thermal_zone_get_crit_temp);
 struct thermal_zone_device *
 thermal_zone_device_register_with_trips(const char *type, struct thermal_trip *trips, int num_trips, int mask,
 					void *devdata, struct thermal_zone_device_ops *ops,
-					struct thermal_zone_params *tzp, int passive_delay,
+					const struct thermal_zone_params *tzp, int passive_delay,
 					int polling_delay)
 {
 	struct thermal_zone_device *tz;
@@ -1371,7 +1371,7 @@  EXPORT_SYMBOL_GPL(thermal_zone_device_register_with_trips);
 
 struct thermal_zone_device *thermal_zone_device_register(const char *type, int ntrips, int mask,
 							 void *devdata, struct thermal_zone_device_ops *ops,
-							 struct thermal_zone_params *tzp, int passive_delay,
+							 const struct thermal_zone_params *tzp, int passive_delay,
 							 int polling_delay)
 {
 	return thermal_zone_device_register_with_trips(type, NULL, ntrips, mask,
diff --git a/include/linux/thermal.h b/include/linux/thermal.h
index 87837094d549..dee66ade89a0 100644
--- a/include/linux/thermal.h
+++ b/include/linux/thermal.h
@@ -301,14 +301,14 @@  int thermal_acpi_critical_trip_temp(struct acpi_device *adev, int *ret_temp);
 #ifdef CONFIG_THERMAL
 struct thermal_zone_device *thermal_zone_device_register(const char *, int, int,
 		void *, struct thermal_zone_device_ops *,
-		struct thermal_zone_params *, int, int);
+		const struct thermal_zone_params *, int, int);
 
 void thermal_zone_device_unregister(struct thermal_zone_device *);
 
 struct thermal_zone_device *
 thermal_zone_device_register_with_trips(const char *, struct thermal_trip *, int, int,
 					void *, struct thermal_zone_device_ops *,
-					struct thermal_zone_params *, int, int);
+					const struct thermal_zone_params *, int, int);
 
 void *thermal_zone_device_priv(struct thermal_zone_device *tzd);
 const char *thermal_zone_device_type(struct thermal_zone_device *tzd);
@@ -348,7 +348,7 @@  void thermal_zone_device_critical(struct thermal_zone_device *tz);
 static inline struct thermal_zone_device *thermal_zone_device_register(
 	const char *type, int trips, int mask, void *devdata,
 	struct thermal_zone_device_ops *ops,
-	struct thermal_zone_params *tzp,
+	const struct thermal_zone_params *tzp,
 	int passive_delay, int polling_delay)
 { return ERR_PTR(-ENODEV); }
 static inline void thermal_zone_device_unregister(