Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965019AbbKDLST (ORCPT ); Wed, 4 Nov 2015 06:18:19 -0500 Received: from mailout3.samsung.com ([203.254.224.33]:37552 "EHLO mailout3.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932458AbbKDLSQ (ORCPT ); Wed, 4 Nov 2015 06:18:16 -0500 X-AuditID: cbfee61b-f79d56d0000048c5-63-5639e976c294 Date: Wed, 04 Nov 2015 12:18:09 +0100 From: Lukasz Majewski To: Alim Akhtar Cc: Krzysztof Kozlowski , Zhang Rui , Eduardo Valentin , Kukjin Kim , linux-pm@vger.kernel.org, "linux-samsung-soc@vger.kernel.org" , "linux-arm-kernel@lists.infradead.org" , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH 2/5] thermal: exynos: Fix first temperature read after registering sensor Message-id: <20151104121809.24f99f79@amdc2363> In-reply-to: References: <1444282446-6419-1-git-send-email-k.kozlowski@samsung.com> <1444282446-6419-2-git-send-email-k.kozlowski@samsung.com> Organization: SPRC Poland X-Mailer: Claws Mail 3.8.1 (GTK+ 2.24.10; x86_64-pc-linux-gnu) MIME-version: 1.0 Content-type: text/plain; charset=US-ASCII Content-transfer-encoding: 7bit X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrBLMWRmVeSWpSXmKPExsVy+t9jAd2yl5ZhBnMP81osvVVtMf/KNVaL 1y8MLfofv2a22PQYyLu8aw6bxefeI4wWM87vY7J48rCPzYHTY+esu+wei/e8ZPLYtKqTzWPz knqPvi2rGD0+b5ILYIvisklJzcksSy3St0vgynjbv4mpYIFWxeQLPSwNjMvkuxg5OSQETCS2 3bzIDGGLSVy4t56ti5GLQ0hgKaPEv8nP2UASQgJvGCW+3QFrYBFQlfj7tYsRxGYT0JP4fPcp E4gtIqAu8fL+RlaQZmaBKcwS15/2sIAkhAXiJa7snAtWxAvU0PLsEdg2ToFgiZ4N39ghtp1i lHjz9g5YA7+ApET7vx9QJ9lJnPu0gR2iWVDix+R7YDXMAloSm7c1sULY8hKb17xlnsAoOAtJ 2SwkZbOQlC1gZF7FKJFakFxQnJSea5SXWq5XnJhbXJqXrpecn7uJERwfz6R3MB7e5X6IUYCD UYmHt+G/RZgQa2JZcWXuIUYJDmYlEV7TU5ZhQrwpiZVVqUX58UWlOanFhxilOViUxHn1PY3C hATSE0tSs1NTC1KLYLJMHJxSDYxzH7cvMmlcuqKgtkU9yHLDX87FUxpsp1hwq2w9Errt9LNN 20KXiUydzl0muo/fU73u/A71Gas8T10rn2fpuUbwaFiE0haZwLZzygcMeFUi/6i6e4v2r/7X 5sjzVKCR+9OH0JWz5i3Xrq6vOfP4yj4rZePfnXN0XC+GrgoNlU288TPIkl9n5lklluKMREMt 5qLiRADXAiljiwIAAA== Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 5502 Lines: 156 Hi Alim, > Hello, > > On Thu, Oct 8, 2015 at 11:04 AM, Krzysztof Kozlowski > wrote: > > Thermal core could not read the temperature after registering the > > thermal sensor with thermal_zone_of_sensor_register() because the > > driver was not yet initialized. > > > > The call trace looked like: > > exynos_tmu_probe() > > thermal_zone_of_sensor_register() > > of_thermal_set_mode() > > thermal_zone_device_update() > > exynos_get_temp() > > if (!data->tmu_read) return -EINVAL; > > exynos_map_dt_data() > > data->tmu_read = ... > > > > This produced an error in dmesg: > > thermal thermal_zone0: failed to read out thermal zone (-22) > > > > Register the thermal_zone_device later, after parsing Device Tree > > and enabling necessary clocks, but before calling > > exynos_tmu_initialize() which uses the registered > > thermal_zone_device. > > > > Signed-off-by: Krzysztof Kozlowski > > Fixes: 3b6a1a805f34 ("thermal: samsung: core: Exynos TMU rework to > > use device tree for configuration") --- > Patch looks good to me. > > Before this patch I was getting below on exynos5800 board: > [ 2.648629] thermal thermal_zone0: failed to read out thermal zone > (-22) [ 2.653906] 10060000.tmu supply vtmu not found, using dummy > regulator [ 2.660521] thermal thermal_zone1: failed to read out > thermal zone (-22) [ 2.666985] 10064000.tmu supply vtmu not found, > using dummy regulator [ 2.673658] thermal thermal_zone2: failed to > read out thermal zone (-22) [ 2.680093] 10068000.tmu supply vtmu > not found, using dummy regulator [ 2.686901] thermal > thermal_zone3: failed to read out thermal zone (-22) [ 2.693187] > 1006c000.tmu supply vtmu not found, using dummy regulator > [ 2.699914] thermal thermal_zone4: failed to read out thermal zone > (-22) [ 2.706332] 100a0000.tmu supply vtmu not found, using dummy > regulator > > > Reviewed-by: Alim Akhtar > > Tested on exynos5800 peach board, so > Tested-by: Alim Akhtar > > > > drivers/thermal/samsung/exynos_tmu.c | 27 +++++++++++++++++-------- > -- > > 1 file changed, 17 insertions(+), 10 deletions(-) > > > > diff --git a/drivers/thermal/samsung/exynos_tmu.c > > b/drivers/thermal/samsung/exynos_tmu.c index > > 23f4320f8ef7..bc71a61f0c4a 100644 --- > > a/drivers/thermal/samsung/exynos_tmu.c +++ > > b/drivers/thermal/samsung/exynos_tmu.c @@ -1289,13 +1289,6 @@ > > static int exynos_tmu_probe(struct platform_device *pdev) > > platform_set_drvdata(pdev, data); mutex_init(&data->lock); > > > > - data->tzd = thermal_zone_of_sensor_register(&pdev->dev, 0, > > data, > > - > > &exynos_sensor_ops); > > - if (IS_ERR(data->tzd)) { > > - pr_err("thermal: tz: %p ERROR\n", data->tzd); > > - return PTR_ERR(data->tzd); > > - } > > - > > /* > > * Try enabling the regulator if found > > * TODO: Add regulator as an SOC feature, so that regulator > > enable @@ -1365,21 +1358,36 @@ static int exynos_tmu_probe(struct > > platform_device *pdev) break; > > }; > > > > + /* > > + * data->tzd must be registered before calling > > exynos_tmu_initialize(), > > + * requesting irq and calling exynos_tmu_control(). > > + */ > > + data->tzd = thermal_zone_of_sensor_register(&pdev->dev, 0, > > data, > > + > > &exynos_sensor_ops); > > + if (IS_ERR(data->tzd)) { > > + ret = PTR_ERR(data->tzd); > > + dev_err(&pdev->dev, "Failed to register sensor: > > %d\n", ret); > > + goto err_sclk; > > + } > > + > > ret = exynos_tmu_initialize(pdev); > > if (ret) { > > dev_err(&pdev->dev, "Failed to initialize TMU\n"); > > - goto err_sclk; > > + goto err_thermal; > > } > > > > ret = devm_request_irq(&pdev->dev, data->irq, > > exynos_tmu_irq, IRQF_TRIGGER_RISING | IRQF_SHARED, > > dev_name(&pdev->dev), data); if (ret) { > > dev_err(&pdev->dev, "Failed to request irq: %d\n", > > data->irq); > > - goto err_sclk; > > + goto err_thermal; > > } > > > > exynos_tmu_control(pdev, true); > > return 0; > > + > > +err_thermal: > > + thermal_zone_of_sensor_unregister(&pdev->dev, data->tzd); > > err_sclk: > > clk_disable_unprepare(data->sclk); > > err_clk: > > @@ -1390,7 +1398,6 @@ err_clk_sec: > > err_sensor: > > if (!IS_ERR_OR_NULL(data->regulator)) > > regulator_disable(data->regulator); > > - thermal_zone_of_sensor_unregister(&pdev->dev, data->tzd); > > > > return ret; > > } > > -- > > 1.9.1 > > > > > > _______________________________________________ > > linux-arm-kernel mailing list > > linux-arm-kernel@lists.infradead.org > > http://lists.infradead.org/mailman/listinfo/linux-arm-kernel > > > Acked-by: Lukasz Majewski Tested-by: Lukasz Majewski -- Best regards, Lukasz Majewski Samsung R&D Institute Poland (SRPOL) | Linux Platform Group -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/