diff mbox series

[RFC,02/26] thermal/of: Migrate to thermal_zone_device_register()

Message ID 20231221124825.149141-3-angelogioacchino.delregno@collabora.com
State New
Headers show
Series Add thermal zones names and new registration func | expand

Commit Message

AngeloGioacchino Del Regno Dec. 21, 2023, 12:48 p.m. UTC
The thermal API has a new thermal_zone_device_register() function which
is deprecating the older thermal_zone_device_register_with_trips() and
thermal_tripless_zone_device_register().

Migrate to the new thermal zone device registration function.

Signed-off-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
---
 drivers/thermal/thermal_of.c | 37 ++++++++++++++++--------------------
 1 file changed, 16 insertions(+), 21 deletions(-)

Comments

Daniel Lezcano Jan. 15, 2024, 5:17 p.m. UTC | #1
On 21/12/2023 13:48, AngeloGioacchino Del Regno wrote:
> The thermal API has a new thermal_zone_device_register() function which
> is deprecating the older thermal_zone_device_register_with_trips() and
> thermal_tripless_zone_device_register().
> 
> Migrate to the new thermal zone device registration function.

Sounds good to me.

May be add "No functional change intended" ?

> Signed-off-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com > ---
>   drivers/thermal/thermal_of.c | 37 ++++++++++++++++--------------------
>   1 file changed, 16 insertions(+), 21 deletions(-)
> 
> diff --git a/drivers/thermal/thermal_of.c b/drivers/thermal/thermal_of.c
> index 1e0655b63259..62a903ad649f 100644
> --- a/drivers/thermal/thermal_of.c
> +++ b/drivers/thermal/thermal_of.c
> @@ -471,16 +471,12 @@ static struct thermal_zone_device *thermal_of_zone_register(struct device_node *
>   							    const struct thermal_zone_device_ops *ops)
>   {
>   	struct thermal_zone_device *tz;
> -	struct thermal_trip *trips;
> -	struct thermal_zone_params tzp = {};
> -	struct thermal_zone_device_ops *of_ops;
> +	struct thermal_zone_device_params tzdp;
>   	struct device_node *np;
> -	int delay, pdelay;
> -	int ntrips, mask;
>   	int ret;
>   
> -	of_ops = kmemdup(ops, sizeof(*ops), GFP_KERNEL);
> -	if (!of_ops)
> +	tzdp.ops = kmemdup(ops, sizeof(*ops), GFP_KERNEL);
> +	if (!tzdp.ops)
>   		return ERR_PTR(-ENOMEM);
>   
>   	np = of_thermal_zone_find(sensor, id);
> @@ -490,30 +486,29 @@ static struct thermal_zone_device *thermal_of_zone_register(struct device_node *
>   		ret = PTR_ERR(np);
>   		goto out_kfree_of_ops;
>   	}
> +	tzdp.type = np->name;
>   
> -	trips = thermal_of_trips_init(np, &ntrips);
> -	if (IS_ERR(trips)) {
> +	tzdp.trips = thermal_of_trips_init(np, &tzdp.num_trips);
> +	if (IS_ERR(tzdp.trips)) {
>   		pr_err("Failed to find trip points for %pOFn id=%d\n", sensor, id);
> -		ret = PTR_ERR(trips);
> +		ret = PTR_ERR(tzdp.trips);
>   		goto out_kfree_of_ops;
>   	}
>   
> -	ret = thermal_of_monitor_init(np, &delay, &pdelay);
> +	ret = thermal_of_monitor_init(np, &tzdp.polling_delay, &tzdp.passive_delay);
>   	if (ret) {
>   		pr_err("Failed to initialize monitoring delays from %pOFn\n", np);
>   		goto out_kfree_trips;
>   	}
>   
> -	thermal_of_parameters_init(np, &tzp);
> +	thermal_of_parameters_init(np, &tzdp.tzp);
>   
> -	of_ops->bind = thermal_of_bind;
> -	of_ops->unbind = thermal_of_unbind;
> +	tzdp.ops->bind = thermal_of_bind;
> +	tzdp.ops->unbind = thermal_of_unbind;
> +	tzdp.mask = GENMASK_ULL((tzdp.num_trips) - 1, 0);
> +	tzdp.devdata = data;
>   
> -	mask = GENMASK_ULL((ntrips) - 1, 0);
> -
> -	tz = thermal_zone_device_register_with_trips(np->name, trips, ntrips,
> -						     mask, data, of_ops, &tzp,
> -						     pdelay, delay);
> +	tz = thermal_zone_device_register(&tzdp);
>   	if (IS_ERR(tz)) {
>   		ret = PTR_ERR(tz);
>   		pr_err("Failed to register thermal zone %pOFn: %d\n", np, ret);
> @@ -531,9 +526,9 @@ static struct thermal_zone_device *thermal_of_zone_register(struct device_node *
>   	return tz;
>   
>   out_kfree_trips:
> -	kfree(trips);
> +	kfree(tzdp.trips);
>   out_kfree_of_ops:
> -	kfree(of_ops);
> +	kfree(tzdp.ops);
>   
>   	return ERR_PTR(ret);
>   }
AngeloGioacchino Del Regno Jan. 16, 2024, 9:50 a.m. UTC | #2
Il 15/01/24 18:17, Daniel Lezcano ha scritto:
> On 21/12/2023 13:48, AngeloGioacchino Del Regno wrote:
>> The thermal API has a new thermal_zone_device_register() function which
>> is deprecating the older thermal_zone_device_register_with_trips() and
>> thermal_tripless_zone_device_register().
>>
>> Migrate to the new thermal zone device registration function.
> 
> Sounds good to me.
> 
> May be add "No functional change intended" ?
> 

Yeah, makes sense - will add "This patch brings no functional changes".

Cheers!

>> Signed-off-by: AngeloGioacchino Del Regno 
>> <angelogioacchino.delregno@collabora.com > ---
>>   drivers/thermal/thermal_of.c | 37 ++++++++++++++++--------------------
>>   1 file changed, 16 insertions(+), 21 deletions(-)
>>
>> diff --git a/drivers/thermal/thermal_of.c b/drivers/thermal/thermal_of.c
>> index 1e0655b63259..62a903ad649f 100644
>> --- a/drivers/thermal/thermal_of.c
>> +++ b/drivers/thermal/thermal_of.c
>> @@ -471,16 +471,12 @@ static struct thermal_zone_device 
>> *thermal_of_zone_register(struct device_node *
>>                                   const struct thermal_zone_device_ops *ops)
>>   {
>>       struct thermal_zone_device *tz;
>> -    struct thermal_trip *trips;
>> -    struct thermal_zone_params tzp = {};
>> -    struct thermal_zone_device_ops *of_ops;
>> +    struct thermal_zone_device_params tzdp;
>>       struct device_node *np;
>> -    int delay, pdelay;
>> -    int ntrips, mask;
>>       int ret;
>> -    of_ops = kmemdup(ops, sizeof(*ops), GFP_KERNEL);
>> -    if (!of_ops)
>> +    tzdp.ops = kmemdup(ops, sizeof(*ops), GFP_KERNEL);
>> +    if (!tzdp.ops)
>>           return ERR_PTR(-ENOMEM);
>>       np = of_thermal_zone_find(sensor, id);
>> @@ -490,30 +486,29 @@ static struct thermal_zone_device 
>> *thermal_of_zone_register(struct device_node *
>>           ret = PTR_ERR(np);
>>           goto out_kfree_of_ops;
>>       }
>> +    tzdp.type = np->name;
>> -    trips = thermal_of_trips_init(np, &ntrips);
>> -    if (IS_ERR(trips)) {
>> +    tzdp.trips = thermal_of_trips_init(np, &tzdp.num_trips);
>> +    if (IS_ERR(tzdp.trips)) {
>>           pr_err("Failed to find trip points for %pOFn id=%d\n", sensor, id);
>> -        ret = PTR_ERR(trips);
>> +        ret = PTR_ERR(tzdp.trips);
>>           goto out_kfree_of_ops;
>>       }
>> -    ret = thermal_of_monitor_init(np, &delay, &pdelay);
>> +    ret = thermal_of_monitor_init(np, &tzdp.polling_delay, &tzdp.passive_delay);
>>       if (ret) {
>>           pr_err("Failed to initialize monitoring delays from %pOFn\n", np);
>>           goto out_kfree_trips;
>>       }
>> -    thermal_of_parameters_init(np, &tzp);
>> +    thermal_of_parameters_init(np, &tzdp.tzp);
>> -    of_ops->bind = thermal_of_bind;
>> -    of_ops->unbind = thermal_of_unbind;
>> +    tzdp.ops->bind = thermal_of_bind;
>> +    tzdp.ops->unbind = thermal_of_unbind;
>> +    tzdp.mask = GENMASK_ULL((tzdp.num_trips) - 1, 0);
>> +    tzdp.devdata = data;
>> -    mask = GENMASK_ULL((ntrips) - 1, 0);
>> -
>> -    tz = thermal_zone_device_register_with_trips(np->name, trips, ntrips,
>> -                             mask, data, of_ops, &tzp,
>> -                             pdelay, delay);
>> +    tz = thermal_zone_device_register(&tzdp);
>>       if (IS_ERR(tz)) {
>>           ret = PTR_ERR(tz);
>>           pr_err("Failed to register thermal zone %pOFn: %d\n", np, ret);
>> @@ -531,9 +526,9 @@ static struct thermal_zone_device 
>> *thermal_of_zone_register(struct device_node *
>>       return tz;
>>   out_kfree_trips:
>> -    kfree(trips);
>> +    kfree(tzdp.trips);
>>   out_kfree_of_ops:
>> -    kfree(of_ops);
>> +    kfree(tzdp.ops);
>>       return ERR_PTR(ret);
>>   }
>
diff mbox series

Patch

diff --git a/drivers/thermal/thermal_of.c b/drivers/thermal/thermal_of.c
index 1e0655b63259..62a903ad649f 100644
--- a/drivers/thermal/thermal_of.c
+++ b/drivers/thermal/thermal_of.c
@@ -471,16 +471,12 @@  static struct thermal_zone_device *thermal_of_zone_register(struct device_node *
 							    const struct thermal_zone_device_ops *ops)
 {
 	struct thermal_zone_device *tz;
-	struct thermal_trip *trips;
-	struct thermal_zone_params tzp = {};
-	struct thermal_zone_device_ops *of_ops;
+	struct thermal_zone_device_params tzdp;
 	struct device_node *np;
-	int delay, pdelay;
-	int ntrips, mask;
 	int ret;
 
-	of_ops = kmemdup(ops, sizeof(*ops), GFP_KERNEL);
-	if (!of_ops)
+	tzdp.ops = kmemdup(ops, sizeof(*ops), GFP_KERNEL);
+	if (!tzdp.ops)
 		return ERR_PTR(-ENOMEM);
 
 	np = of_thermal_zone_find(sensor, id);
@@ -490,30 +486,29 @@  static struct thermal_zone_device *thermal_of_zone_register(struct device_node *
 		ret = PTR_ERR(np);
 		goto out_kfree_of_ops;
 	}
+	tzdp.type = np->name;
 
-	trips = thermal_of_trips_init(np, &ntrips);
-	if (IS_ERR(trips)) {
+	tzdp.trips = thermal_of_trips_init(np, &tzdp.num_trips);
+	if (IS_ERR(tzdp.trips)) {
 		pr_err("Failed to find trip points for %pOFn id=%d\n", sensor, id);
-		ret = PTR_ERR(trips);
+		ret = PTR_ERR(tzdp.trips);
 		goto out_kfree_of_ops;
 	}
 
-	ret = thermal_of_monitor_init(np, &delay, &pdelay);
+	ret = thermal_of_monitor_init(np, &tzdp.polling_delay, &tzdp.passive_delay);
 	if (ret) {
 		pr_err("Failed to initialize monitoring delays from %pOFn\n", np);
 		goto out_kfree_trips;
 	}
 
-	thermal_of_parameters_init(np, &tzp);
+	thermal_of_parameters_init(np, &tzdp.tzp);
 
-	of_ops->bind = thermal_of_bind;
-	of_ops->unbind = thermal_of_unbind;
+	tzdp.ops->bind = thermal_of_bind;
+	tzdp.ops->unbind = thermal_of_unbind;
+	tzdp.mask = GENMASK_ULL((tzdp.num_trips) - 1, 0);
+	tzdp.devdata = data;
 
-	mask = GENMASK_ULL((ntrips) - 1, 0);
-
-	tz = thermal_zone_device_register_with_trips(np->name, trips, ntrips,
-						     mask, data, of_ops, &tzp,
-						     pdelay, delay);
+	tz = thermal_zone_device_register(&tzdp);
 	if (IS_ERR(tz)) {
 		ret = PTR_ERR(tz);
 		pr_err("Failed to register thermal zone %pOFn: %d\n", np, ret);
@@ -531,9 +526,9 @@  static struct thermal_zone_device *thermal_of_zone_register(struct device_node *
 	return tz;
 
 out_kfree_trips:
-	kfree(trips);
+	kfree(tzdp.trips);
 out_kfree_of_ops:
-	kfree(of_ops);
+	kfree(tzdp.ops);
 
 	return ERR_PTR(ret);
 }