thermal: Eliminate thermal_zone_device_register()
Subsystems (3)
cover thermal: Eliminate thermal_zone_device_register()
Hi Everyone,
After recently merged changes in the ACPI thermal and Intel DTS IOSF thermal drivers, the only callers of thermal_zone_device_register() are the ones using it for registering thermal zones without any trip points. They all pass zeros as 4 (out of 8) function arguments, so retaining the full thermal_zone_device_register() just for this purpose seems a bit excessive.
For this reason, the series adds a thermal_zone_device_register() replacement tailored to this specific use case and called thermal_tripless_zone_device_register() [2/4] and makes all of the existing callers of the former use the replacement [3/4]. This allows thermal_zone_device_register() to be dropped [4/4].
The first patch is just a clean up making function headers in thermal.h a bit more consistent.
This series it not intended to make any functional impact, but if the changes are fine with everyone, I would like to introduce them during the ongoing merge window to prevent the obsolete interface from lingering.
The series applies to the linux-next branch in linux-pm.git.
Thanks!
PATCH 1/4 thermal: core: Clean up headers of thermal zone registration functions
From: Rafael J. Wysocki <[email protected]>
For consistency, add a missing thermal_zone_device_register_with_trips() stub for the CONFIG_THERMAL unset case, specify argument names in all of the thermal zone registration and unregistration function headers and make all of them use white space consistently.
No intentional functional impact.
--- include/linux/thermal.h | 53 +++++++++++++++++++++++++++++++++--------------- 1 file changed, 37 insertions(+), 16 deletions(-)
include/linux/thermal.h +37 -16
@@ -300,16 +300,24 @@ int thermal_acpi_critical_trip_temp(stru#endif #ifdef CONFIG_THERMAL -struct thermal_zone_device *thermal_zone_device_register (const char *,int ,int , -void *,struct thermal_zone_device_ops *, -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 *, -const struct thermal_zone_params *,int ,int ); +struct thermal_zone_device *thermal_zone_device_register ( +const char *type, +int num_trips,int mask, +void *devdata, +struct thermal_zone_device_ops *ops, +const struct thermal_zone_params *tzp, +int passive_delay,int polling_delay); + +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, +const struct thermal_zone_params *tzp, +int passive_delay,int polling_delay); + +void thermal_zone_device_unregister (struct thermal_zone_device *tz);void *thermal_zone_device_priv (struct thermal_zone_device *tzd);const char *thermal_zone_device_type (struct thermal_zone_device *tzd);
@@ -351,14 +359,27 @@ int thermal_zone_device_disable(struct tvoid thermal_zone_device_critical (struct thermal_zone_device *tz);#else 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, -const struct thermal_zone_params *tzp, -int passive_delay,int polling_delay) +const char *type, +int num_trips,int mask, +void *devdata, +struct thermal_zone_device_ops *ops, +const struct thermal_zone_params *tzp, +int passive_delay,int polling_delay) +{return ERR_PTR (-ENODEV ); } + +static inline 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, +const struct thermal_zone_params *tzp, +int passive_delay,int polling_delay); {return ERR_PTR (-ENODEV ); } -static inline void thermal_zone_device_unregister ( -struct thermal_zone_device *tz) + +static inline void thermal_zone_device_unregister (struct thermal_zone_device *tz) { } +static inline struct thermal_cooling_device *thermal_cooling_device_register (const char *type,void *devdata,const struct thermal_cooling_device_ops *ops)
PATCH 2/4 thermal: core: Add function for registering tripless thermal zones
In reply to Rafael J. WysockiFrom: Rafael J. Wysocki <[email protected]>
Multiple callers of thermal_zone_device_register() don't pass any trips to it and they might use a shortened argument list for that, so add a special function with fewer arguments for this purpose.
--- drivers/thermal/thermal_core.c | 11 +++++++++++ include/linux/thermal.h | 13 +++++++++++++ 2 files changed, 24 insertions(+)
drivers/thermal/thermal_core.c +11 -0
@@ -1400,6 +1400,17 @@ struct thermal_zone_device *thermal_zone }EXPORT_SYMBOL_GPL (thermal_zone_device_register); +struct thermal_zone_device *thermal_tripless_zone_device_register ( +const char *type, +void *devdata, +struct thermal_zone_device_ops *ops, +const struct thermal_zone_params *tzp) +{ +return thermal_zone_device_register_with_trips (type,NULL ,0 ,0 , devdata, + ops, tzp,0 ,0 ); +} +EXPORT_SYMBOL_GPL (thermal_tripless_zone_device_register); +void *thermal_zone_device_priv (struct thermal_zone_device *tzd) {return tzd->devdata;
include/linux/thermal.h +13 -0
@@ -317,6 +317,12 @@ struct thermal_zone_device *thermal_zoneconst struct thermal_zone_params *tzp, int passive_delay, int polling_delay); +struct thermal_zone_device *thermal_tripless_zone_device_register ( +const char *type, +void *devdata, +struct thermal_zone_device_ops *ops, +const struct thermal_zone_params *tzp); +void thermal_zone_device_unregister (struct thermal_zone_device *tz);void *thermal_zone_device_priv (struct thermal_zone_device *tzd);
@@ -377,6 +383,13 @@ static inline struct thermal_zone_device int passive_delay, int polling_delay); {return ERR_PTR (-ENODEV ); } +static inline struct thermal_zone_device *thermal_tripless_zone_device_register ( +const char *type, +void *devdata, +struct thermal_zone_device_ops *ops, +const struct thermal_zone_params *tzp) +{return ERR_PTR (-ENODEV ); } +static inline void thermal_zone_device_unregister (struct thermal_zone_device *tz) { }
PATCH 3/4 thermal: Use thermal_tripless_zone_device_register()
In reply to Rafael J. WysockiFrom: Rafael J. Wysocki <[email protected]>
All of the remaining callers of thermal_zone_device_register() can use thermal_tripless_zone_device_register(), so make them do so in order to allow the former to be dropped.
No intentional functional impact.
--- drivers/power/supply/power_supply_core.c | 4 ++-- drivers/thermal/armada_thermal.c | 5 +++-- drivers/thermal/dove_thermal.c | 4 ++-- drivers/thermal/intel/int340x_thermal/int3400_thermal.c | 6 +++--- drivers/thermal/kirkwood_thermal.c | 4 ++-- drivers/thermal/spear_thermal.c | 4 ++-- 6 files changed, 14 insertions(+), 13 deletions(-)
drivers/power/supply/power_supply_core.c +2 -2
@@ -1305,8 +1305,8 @@ static int psy_register_thermal(struct p/* Register battery zone device psy reports temperature */ if (psy_has_property (psy->desc,POWER_SUPPLY_PROP_TEMP )) { - psy->tzd =thermal_zone_device_register (psy->desc->name, -0 ,0 , psy, &psy_tzd_ops,NULL ,0 ,0 ); + psy->tzd =thermal_tripless_zone_device_register (psy->desc->name, + psy, &psy_tzd_ops,NULL );if (IS_ERR (psy->tzd))return PTR_ERR (psy->tzd); ret =thermal_zone_device_enable (psy->tzd);
drivers/thermal/armada_thermal.c +3 -2
@@ -876,8 +876,9 @@ static int armada_thermal_probe(struct p/* Wait the sensors to be valid */ armada_wait_sensor_validity (priv); - tz =thermal_zone_device_register (priv->zone_name,0 ,0 , priv, - &legacy_ops,NULL ,0 ,0 ); + tz =thermal_tripless_zone_device_register (priv->zone_name, + priv, &legacy_ops, +NULL );if (IS_ERR (tz)) {dev_err (&pdev->dev,"Failed to register thermal zone device\n" );
drivers/thermal/dove_thermal.c +2 -2
@@ -139,8 +139,8 @@ static int dove_thermal_probe(struct plareturn ret; } - thermal =thermal_zone_device_register ("dove_thermal" ,0 ,0 , - priv, &ops,NULL ,0 ,0 ); + thermal =thermal_tripless_zone_device_register ("dove_thermal" , priv, + &ops,NULL );if (IS_ERR (thermal)) {dev_err (&pdev->dev,"Failed to register thermal zone device\n" );
drivers/thermal/intel/int340x_thermal/int3400_thermal.c +3 -3
@@ -609,9 +609,9 @@ static int int3400_thermal_probe(structevaluate_odvp (priv); - priv->thermal =thermal_zone_device_register ("INT3400 Thermal" ,0 ,0 , - priv, &int3400_thermal_ops, - &int3400_thermal_params,0 ,0 ); + priv->thermal =thermal_tripless_zone_device_register ("INT3400 Thermal" , priv, + &int3400_thermal_ops, + &int3400_thermal_params);if (IS_ERR (priv->thermal)) { result =PTR_ERR (priv->thermal); goto free_art_trt;
drivers/thermal/kirkwood_thermal.c +2 -2
@@ -71,8 +71,8 @@ static int kirkwood_thermal_probe(structif (IS_ERR (priv->sensor))return PTR_ERR (priv->sensor); - thermal =thermal_zone_device_register ("kirkwood_thermal" ,0 ,0 , - priv, &ops,NULL ,0 ,0 ); + thermal =thermal_tripless_zone_device_register ("kirkwood_thermal" , + priv, &ops,NULL );if (IS_ERR (thermal)) {dev_err (&pdev->dev,"Failed to register thermal zone device\n" );
drivers/thermal/spear_thermal.c +2 -2
@@ -122,8 +122,8 @@ static int spear_thermal_probe(struct pl stdev->flags = val;writel_relaxed (stdev->flags, stdev->thermal_base); - spear_thermal =thermal_zone_device_register ("spear_thermal" ,0 ,0 , - stdev, &ops,NULL ,0 ,0 ); + spear_thermal =thermal_tripless_zone_device_register ("spear_thermal" , + stdev, &ops,NULL );if (IS_ERR (spear_thermal)) {dev_err (&pdev->dev,"thermal zone device is NULL\n" ); ret =PTR_ERR (spear_thermal);
Re: [PATCH v1 3/4] thermal: Use thermal_tripless_zone_device_register()
Hello,
[email protected] wrote on Wed, 30 Aug 2023 18:14:57 +0200:
Quoted 6 lines
From: Rafael J. Wysocki <[email protected]>
All of the remaining callers of
thermal_zone_device_register()can usethermal_tripless_zone_device_register(), so make them do so in order to allow the former to be dropped.
Quoted 6 lines
No intentional functional impact.
Signed-off-by Rafael J. Wysocki <[email protected]>---
drivers/thermal/armada_thermal.c | 5 +++--
For armada:
Thanks,
Miquèl
Rafael J. Wysocki
maintainerRe: [PATCH v1 3/4] thermal: Use thermal_tripless_zone_device_register()
Quoted 13 lines · Miquel Raynal
Hello,
[email protected] wrote on Wed, 30 Aug 2023 18:14:57 +0200:
Quoted 8 lines
From: Rafael J. Wysocki <[email protected]>
All of the remaining callers of
thermal_zone_device_register()can usethermal_tripless_zone_device_register(), so make them do so in order to allow the former to be dropped.No intentional functional impact.
Quoted 7 lines
Quoted 4 lines
Signed-off-by Rafael J. Wysocki <[email protected]>---
drivers/thermal/armada_thermal.c | 5 +++--For armada:
Acked-by Miquel Raynal <[email protected]>
Thank you!
Rafael J. Wysocki
maintainerRe: [PATCH v1 3/4] thermal: Use thermal_tripless_zone_device_register()
In reply to Rafael J. WysockiQuoted 10 lines · Rafael J. Wysocki
From: Rafael J. Wysocki <[email protected]>
All of the remaining callers of
thermal_zone_device_register()can usethermal_tripless_zone_device_register(), so make them do so in order to allow the former to be dropped.No intentional functional impact.
Signed-off-by Rafael J. Wysocki <[email protected]>
Due to the lack of negative feedback, I'm going to assume that this patch in particular and the entire series in general is fine with everyone in the CC.
Quoted 105 lines
--- drivers/power/supply/power_supply_core.c | 4 ++-- drivers/thermal/armada_thermal.c | 5 +++-- drivers/thermal/dove_thermal.c | 4 ++-- drivers/thermal/intel/int340x_thermal/int3400_thermal.c | 6 +++--- drivers/thermal/kirkwood_thermal.c | 4 ++-- drivers/thermal/spear_thermal.c | 4 ++-- 6 files changed, 14 insertions(+), 13 deletions(-)Index:
linux-pm/drivers/power/supply/power_supply_core.c
===================================================================drivers/power/supply/power_supply_core.c +2
-2@@ -1305,8 +1305,8 @@ static int psy_register_thermal(struct p/* Register battery zone device psy reports temperature */ if (psy_has_property (psy->desc,POWER_SUPPLY_PROP_TEMP )) { - psy->tzd =thermal_zone_device_register (psy->desc->name, -0 ,0 , psy, &psy_tzd_ops,NULL ,0 ,0 ); + psy->tzd =thermal_tripless_zone_device_register (psy->desc->name, + psy, &psy_tzd_ops,NULL );if (IS_ERR (psy->tzd))return PTR_ERR (psy->tzd); ret =thermal_zone_device_enable (psy->tzd);Index:
linux-pm/drivers/thermal/armada_thermal.c
===================================================================drivers/thermal/armada_thermal.c +3
-2@@ -876,8 +876,9 @@ static int armada_thermal_probe(struct p/* Wait the sensors to be valid */ armada_wait_sensor_validity (priv); - tz =thermal_zone_device_register (priv->zone_name,0 ,0 , priv, - &legacy_ops,NULL ,0 ,0 ); + tz =thermal_tripless_zone_device_register (priv->zone_name, + priv, &legacy_ops, +NULL );if (IS_ERR (tz)) {dev_err (&pdev->dev,"Failed to register thermal zone device\n" );Index:
linux-pm/drivers/thermal/dove_thermal.c
===================================================================drivers/thermal/dove_thermal.c +2
-2@@ -139,8 +139,8 @@ static int dove_thermal_probe(struct plareturn ret; } - thermal =thermal_zone_device_register ("dove_thermal" ,0 ,0 , - priv, &ops,NULL ,0 ,0 ); + thermal =thermal_tripless_zone_device_register ("dove_thermal" , priv, + &ops,NULL );if (IS_ERR (thermal)) {dev_err (&pdev->dev,"Failed to register thermal zone device\n" );Index:
linux-pm/drivers/thermal/intel/int340x_thermal/int3400_thermal.c
===================================================================drivers/thermal/intel/int340x_thermal/int3400_thermal.c +3
-3@@ -609,9 +609,9 @@ static int int3400_thermal_probe(structevaluate_odvp (priv); - priv->thermal =thermal_zone_device_register ("INT3400 Thermal" ,0 ,0 , - priv, &int3400_thermal_ops, - &int3400_thermal_params,0 ,0 ); + priv->thermal =thermal_tripless_zone_device_register ("INT3400 Thermal" , priv, + &int3400_thermal_ops, + &int3400_thermal_params);if (IS_ERR (priv->thermal)) { result =PTR_ERR (priv->thermal); goto free_art_trt;Index:
linux-pm/drivers/thermal/kirkwood_thermal.c
===================================================================drivers/thermal/kirkwood_thermal.c +2
-2@@ -71,8 +71,8 @@ static int kirkwood_thermal_probe(structif (IS_ERR (priv->sensor))return PTR_ERR (priv->sensor); - thermal =thermal_zone_device_register ("kirkwood_thermal" ,0 ,0 , - priv, &ops,NULL ,0 ,0 ); + thermal =thermal_tripless_zone_device_register ("kirkwood_thermal" , + priv, &ops,NULL );if (IS_ERR (thermal)) {dev_err (&pdev->dev,"Failed to register thermal zone device\n" );Index:
linux-pm/drivers/thermal/spear_thermal.c
===================================================================drivers/thermal/spear_thermal.c +2
-2@@ -122,8 +122,8 @@ static int spear_thermal_probe(struct pl stdev->flags = val;writel_relaxed (stdev->flags, stdev->thermal_base); - spear_thermal =thermal_zone_device_register ("spear_thermal" ,0 ,0 , - stdev, &ops,NULL ,0 ,0 ); + spear_thermal =thermal_tripless_zone_device_register ("spear_thermal" , + stdev, &ops,NULL );if (IS_ERR (spear_thermal)) {dev_err (&pdev->dev,"thermal zone device is NULL\n" ); ret =PTR_ERR (spear_thermal);
Re: [PATCH v1 3/4] thermal: Use thermal_tripless_zone_device_register()
In reply to Rafael J. WysockiHi,
Quoted 11 lines · Rafael J. Wysocki
From: Rafael J. Wysocki <[email protected]>
All of the remaining callers of
thermal_zone_device_register()can usethermal_tripless_zone_device_register(), so make them do so in order to allow the former to be dropped.No intentional functional impact.
Signed-off-by Rafael J. Wysocki <[email protected]>--- drivers/power/supply/power_supply_core.c | 4 ++--
For power-supply:
-- Sebastian
Quoted 103 lines
drivers/thermal/armada_thermal.c | 5 +++-- drivers/thermal/dove_thermal.c | 4 ++-- drivers/thermal/intel/int340x_thermal/int3400_thermal.c | 6 +++--- drivers/thermal/kirkwood_thermal.c | 4 ++-- drivers/thermal/spear_thermal.c | 4 ++-- 6 files changed, 14 insertions(+), 13 deletions(-)Index:
linux-pm/drivers/power/supply/power_supply_core.c
===================================================================drivers/power/supply/power_supply_core.c +2
-2@@ -1305,8 +1305,8 @@ static int psy_register_thermal(struct p/* Register battery zone device psy reports temperature */ if (psy_has_property (psy->desc,POWER_SUPPLY_PROP_TEMP )) { - psy->tzd =thermal_zone_device_register (psy->desc->name, -0 ,0 , psy, &psy_tzd_ops,NULL ,0 ,0 ); + psy->tzd =thermal_tripless_zone_device_register (psy->desc->name, + psy, &psy_tzd_ops,NULL );if (IS_ERR (psy->tzd))return PTR_ERR (psy->tzd); ret =thermal_zone_device_enable (psy->tzd);Index:
linux-pm/drivers/thermal/armada_thermal.c
===================================================================drivers/thermal/armada_thermal.c +3
-2@@ -876,8 +876,9 @@ static int armada_thermal_probe(struct p/* Wait the sensors to be valid */ armada_wait_sensor_validity (priv); - tz =thermal_zone_device_register (priv->zone_name,0 ,0 , priv, - &legacy_ops,NULL ,0 ,0 ); + tz =thermal_tripless_zone_device_register (priv->zone_name, + priv, &legacy_ops, +NULL );if (IS_ERR (tz)) {dev_err (&pdev->dev,"Failed to register thermal zone device\n" );Index:
linux-pm/drivers/thermal/dove_thermal.c
===================================================================drivers/thermal/dove_thermal.c +2
-2@@ -139,8 +139,8 @@ static int dove_thermal_probe(struct plareturn ret; } - thermal =thermal_zone_device_register ("dove_thermal" ,0 ,0 , - priv, &ops,NULL ,0 ,0 ); + thermal =thermal_tripless_zone_device_register ("dove_thermal" , priv, + &ops,NULL );if (IS_ERR (thermal)) {dev_err (&pdev->dev,"Failed to register thermal zone device\n" );Index:
linux-pm/drivers/thermal/intel/int340x_thermal/int3400_thermal.c
===================================================================drivers/thermal/intel/int340x_thermal/int3400_thermal.c +3
-3@@ -609,9 +609,9 @@ static int int3400_thermal_probe(structevaluate_odvp (priv); - priv->thermal =thermal_zone_device_register ("INT3400 Thermal" ,0 ,0 , - priv, &int3400_thermal_ops, - &int3400_thermal_params,0 ,0 ); + priv->thermal =thermal_tripless_zone_device_register ("INT3400 Thermal" , priv, + &int3400_thermal_ops, + &int3400_thermal_params);if (IS_ERR (priv->thermal)) { result =PTR_ERR (priv->thermal); goto free_art_trt;Index:
linux-pm/drivers/thermal/kirkwood_thermal.c
===================================================================drivers/thermal/kirkwood_thermal.c +2
-2@@ -71,8 +71,8 @@ static int kirkwood_thermal_probe(structif (IS_ERR (priv->sensor))return PTR_ERR (priv->sensor); - thermal =thermal_zone_device_register ("kirkwood_thermal" ,0 ,0 , - priv, &ops,NULL ,0 ,0 ); + thermal =thermal_tripless_zone_device_register ("kirkwood_thermal" , + priv, &ops,NULL );if (IS_ERR (thermal)) {dev_err (&pdev->dev,"Failed to register thermal zone device\n" );Index:
linux-pm/drivers/thermal/spear_thermal.c
===================================================================drivers/thermal/spear_thermal.c +2
-2@@ -122,8 +122,8 @@ static int spear_thermal_probe(struct pl stdev->flags = val;writel_relaxed (stdev->flags, stdev->thermal_base); - spear_thermal =thermal_zone_device_register ("spear_thermal" ,0 ,0 , - stdev, &ops,NULL ,0 ,0 ); + spear_thermal =thermal_tripless_zone_device_register ("spear_thermal" , + stdev, &ops,NULL );if (IS_ERR (spear_thermal)) {dev_err (&pdev->dev,"thermal zone device is NULL\n" ); ret =PTR_ERR (spear_thermal);
PATCH 4/4 thermal: core: Drop thermal_zone_device_register()
In reply to Rafael J. WysockiFrom: Rafael J. Wysocki <[email protected]>
There are no more users of thermal_zone_device_register(), so drop it from the core.
Note that thermal_zone_device_register_with_trips() may be renamed to thermal_zone_device_register() in the future, but only after a grace period allowing all of the possible work in progress that may be using the latter to adjust.
--- drivers/thermal/thermal_core.c | 11 ----------- include/linux/thermal.h | 17 ----------------- 2 files changed, 28 deletions(-)
drivers/thermal/thermal_core.c +0 -11
@@ -1389,17 +1389,6 @@ free_tz: }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, -const struct thermal_zone_params *tzp,int passive_delay, -int polling_delay) -{ -return thermal_zone_device_register_with_trips (type,NULL , ntrips, mask, - devdata, ops, tzp, - passive_delay, polling_delay); -} -EXPORT_SYMBOL_GPL (thermal_zone_device_register); - struct thermal_zone_device *thermal_tripless_zone_device_register( const char *type, void *devdata,
include/linux/thermal.h +0 -17
@@ -300,14 +300,6 @@ int thermal_acpi_critical_trip_temp(stru#endif #ifdef CONFIG_THERMAL -struct thermal_zone_device *thermal_zone_device_register ( -const char *type, -int num_trips,int mask, -void *devdata, -struct thermal_zone_device_ops *ops, -const struct thermal_zone_params *tzp, -int passive_delay,int polling_delay); - struct thermal_zone_device *thermal_zone_device_register_with_trips( const char *type, struct thermal_trip *trips,
@@ -364,15 +356,6 @@ int thermal_zone_device_enable(struct thint thermal_zone_device_disable (struct thermal_zone_device *tz);void thermal_zone_device_critical (struct thermal_zone_device *tz);#else -static inline struct thermal_zone_device *thermal_zone_device_register ( -const char *type, -int num_trips,int mask, -void *devdata, -struct thermal_zone_device_ops *ops, -const struct thermal_zone_params *tzp, -int passive_delay,int polling_delay) -{return ERR_PTR (-ENODEV ); } - static inline struct thermal_zone_device *thermal_zone_device_register_with_trips( const char *type, struct thermal_trip *trips,