[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAJMQK-ivho3T1hnD9axV2EMKT3Srs_5zAXLqwts8nojY15fBGg@mail.gmail.com>
Date: Thu, 21 Nov 2019 15:00:31 +0800
From: Hsin-Yi Wang <hsinyi@...omium.org>
To: "michael.kao" <michael.kao@...iatek.com>
Cc: Zhang Rui <rui.zhang@...el.com>,
Eduardo Valentin <edubezval@...il.com>,
Daniel Lezcano <daniel.lezcano@...aro.org>,
Rob Herring <robh+dt@...nel.org>,
Mark Rutland <mark.rutland@....com>,
Matthias Brugger <matthias.bgg@...il.com>,
linux-pm@...r.kernel.org,
Devicetree List <devicetree@...r.kernel.org>,
lkml <linux-kernel@...r.kernel.org>,
"moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE"
<linux-arm-kernel@...ts.infradead.org>,
linux-mediatek@...ts.infradead.org
Subject: Re: [PATCH v2 7/8] thermal: mediatek: add another get_temp ops for
thermal sensors
On Fri, May 10, 2019 at 9:27 PM michael.kao <michael.kao@...iatek.com> wrote:
> - tzdev = devm_thermal_zone_of_sensor_register(&pdev->dev, 0, mt,
> - &mtk_thermal_ops);
> - if (IS_ERR(tzdev)) {
> - ret = PTR_ERR(tzdev);
> - goto err_disable_clk_peri_therm;
> + for (i = 0; i < mt->conf->num_sensors + 1; i++) {
> + tz = kmalloc(sizeof(*tz), GFP_KERNEL);
> + if (!tz)
> + return -ENOMEM;
> +
> + tz->mt = mt;
> + tz->id = i;
> +
> + tzdev = devm_thermal_zone_of_sensor_register(&pdev->dev, i,
> + tz, (i == 0) ?
> + &mtk_thermal_ops : &mtk_thermal_sensor_ops);
> +
> + if (IS_ERR(tzdev)) {
> + if (IS_ERR(tzdev) != -EACCES) {
PTR_ERR(tzdev)
> + ret = PTR_ERR(tzdev);
> + goto err_disable_clk_peri_therm;
> + }
> + }
This for loop adding thermal zone sensors will not work for mt8173. It
assumes that thermal-zones in dts have subnodes (eg. cpu_thermal,
tzts..) amount equal to num_sensors+1. Otherwise tzdev would be
-ENODEV and thermal failed to be probed.
In mt8183 this is fine, since each thermal zone only has one sensor,
but in mt8173, some sensor appears in multiple thermal zones.
In order to let the change also works for 8173, I think if the error
is -ENODEV, and the id is not 0 (0 is cpu_thermal), prompt a warning
instead of failing. Eg.
if (IS_ERR(tzdev)) {
+ if (i > 0 && PTR_ERR(tzdev) == -ENODEV) {
+ dev_warn(&pdev->dev, "can't find
thermal sensor %d\n", i);
+ continue;
+ }
if (PTR_ERR(tzdev) != -EACCES) {
Powered by blists - more mailing lists