UPSTREAM: thermal: convert rockchip_thermal to use devm_thermal_zone_of_sensor_register

This changes the driver to use the devm_ version
of thermal_zone_of_sensor_register and cleans
up the  local points and unregister calls.

Change-Id: I9c13e9c91a626a0ef8df69edf3f383c494536bab
Cc: Zhang Rui <rui.zhang@intel.com>
Cc: Heiko Stuebner <heiko@sntech.de>
Cc: linux-pm@vger.kernel.org
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-rockchip@lists.infradead.org
Cc: linux-kernel@vger.kernel.org
Tested-by: Caesar Wang <wxt@rock-chips.com>
Reviewed-by: Caesar Wang <wxt@rock-chips.com>
Reviewed-by: Heiko Stuebner <heiko@sntech.de>
Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
Signed-off-by: Caesar Wang <wxt@rock-chips.com>
(cherry picked from git.kernel.org next/linux-next.git master
 commit 93c2f85df90edfc515f99cacd7720e286861f744)
This commit is contained in:
Eduardo Valentin
2016-03-09 13:10:28 -08:00
committed by Huang, Tao
parent f919aa0a80
commit 36e7a60254

View File

@@ -858,8 +858,8 @@ rockchip_thermal_register_sensor(struct platform_device *pdev,
sensor->thermal = thermal;
sensor->id = id;
sensor->tzd = thermal_zone_of_sensor_register(&pdev->dev, id, sensor,
&rockchip_of_thermal_ops);
sensor->tzd = devm_thermal_zone_of_sensor_register(&pdev->dev, id,
sensor, &rockchip_of_thermal_ops);
if (IS_ERR(sensor->tzd)) {
error = PTR_ERR(sensor->tzd);
dev_err(&pdev->dev, "failed to register sensor %d: %d\n",
@@ -887,7 +887,7 @@ static int rockchip_thermal_probe(struct platform_device *pdev)
const struct of_device_id *match;
struct resource *res;
int irq;
int i, j;
int i;
int error;
match = of_match_node(of_rockchip_thermal_match, np);
@@ -971,9 +971,6 @@ static int rockchip_thermal_probe(struct platform_device *pdev)
dev_err(&pdev->dev,
"failed to register sensor[%d] : error = %d\n",
i, error);
for (j = 0; j < i; j++)
thermal_zone_of_sensor_unregister(&pdev->dev,
thermal->sensors[j].tzd);
goto err_disable_pclk;
}
}
@@ -985,7 +982,7 @@ static int rockchip_thermal_probe(struct platform_device *pdev)
if (error) {
dev_err(&pdev->dev,
"failed to request tsadc irq: %d\n", error);
goto err_unregister_sensor;
goto err_disable_pclk;
}
thermal->chip->control(thermal->regs, true);
@@ -997,11 +994,6 @@ static int rockchip_thermal_probe(struct platform_device *pdev)
return 0;
err_unregister_sensor:
while (i--)
thermal_zone_of_sensor_unregister(&pdev->dev,
thermal->sensors[i].tzd);
err_disable_pclk:
clk_disable_unprepare(thermal->pclk);
err_disable_clk:
@@ -1019,7 +1011,6 @@ static int rockchip_thermal_remove(struct platform_device *pdev)
struct rockchip_thermal_sensor *sensor = &thermal->sensors[i];
rockchip_thermal_toggle_sensor(sensor, false);
thermal_zone_of_sensor_unregister(&pdev->dev, sensor->tzd);
}
thermal->chip->control(thermal->regs, false);