Re: [PATCH v3 04/13] thermal: qoriq: Add local struct qoriq_sensor pointer

From: Daniel Lezcano
Date: Wed Apr 03 2019 - 23:28:58 EST


On 01/04/2019 06:14, Andrey Smirnov wrote:
> Add local struct qoriq_sensor pointer in qoriq_tmu_register_tmu_zone()
> for brevity.
>
> Signed-off-by: Andrey Smirnov <andrew.smirnov@xxxxxxxxx>
> Cc: Chris Healy <cphealy@xxxxxxxxx>
> Cc: Lucas Stach <l.stach@xxxxxxxxxxxxxx>
> Cc: Zhang Rui <rui.zhang@xxxxxxxxx>
> Cc: Eduardo Valentin <edubezval@xxxxxxxxx>
> Cc: Daniel Lezcano <daniel.lezcano@xxxxxxxxxx>
> Cc: Angus Ainslie (Purism) <angus@xxxxxxxx>
> Cc: linux-imx@xxxxxxx
> Cc: linux-pm@xxxxxxxxxxxxxxx
> Cc: linux-kernel@xxxxxxxxxxxxxxx
> ---
> drivers/thermal/qoriq_thermal.c | 10 +++++-----
> 1 file changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/thermal/qoriq_thermal.c b/drivers/thermal/qoriq_thermal.c
> index 6d40b9788266..e281bdcfa11f 100644
> --- a/drivers/thermal/qoriq_thermal.c
> +++ b/drivers/thermal/qoriq_thermal.c
> @@ -114,18 +114,18 @@ static int qoriq_tmu_register_tmu_zone(struct platform_device *pdev)
>
> for (id = 0; id < SITES_MAX; id++) {
> struct thermal_zone_device *tzd;
> + struct qoriq_sensor *s;
>
> - qdata->sensor[id] = devm_kzalloc(&pdev->dev,
> + s = qdata->sensor[id] = devm_kzalloc(&pdev->dev,
> sizeof(struct qoriq_sensor), GFP_KERNEL);

I would not recommend this, especially if you use a variable helper for
clarity. Keep using the 's' variable and then assign qdata->sensor[id] =
s at the end when everything is ok. May be rename it 'sensor'?

> if (!qdata->sensor[id])
> return -ENOMEM;
>
> - qdata->sensor[id]->id = id;
> - qdata->sensor[id]->qdata = qdata;
> + s->id = id;
> + s->qdata = qdata;
>
> tzd = devm_thermal_zone_of_sensor_register(&pdev->dev, id,
> - qdata->sensor[id],
> - &tmu_tz_ops);
> + s, &tmu_tz_ops);
> if (IS_ERR(tzd)) {
> if (PTR_ERR(tzd) == -ENODEV)
> continue;
>


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