Commit 7ea98f70 authored by Daniel Lezcano's avatar Daniel Lezcano Committed by Daniel Lezcano

thermal/drivers/samsung: Switch to new of thermal API

The thermal OF code has a new API allowing to migrate the OF
initialization to a simpler approach. The ops are no longer device
tree specific and are the generic ones provided by the core code.

Convert the ops to the thermal_zone_device_ops format and use the new
API to register the thermal zone with these generic ops.
Signed-off-by: default avatarDaniel Lezcano <daniel.lezcano@linexp.org>
Reviewed-by: default avatarKrzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Link: https://lore.kernel.org/r/20220804224349.1926752-32-daniel.lezcano@linexp.orgSigned-off-by: default avatarDaniel Lezcano <daniel.lezcano@linaro.org>
parent 826855ff
...@@ -650,9 +650,9 @@ static void exynos7_tmu_control(struct platform_device *pdev, bool on) ...@@ -650,9 +650,9 @@ static void exynos7_tmu_control(struct platform_device *pdev, bool on)
writel(con, data->base + EXYNOS_TMU_REG_CONTROL); writel(con, data->base + EXYNOS_TMU_REG_CONTROL);
} }
static int exynos_get_temp(void *p, int *temp) static int exynos_get_temp(struct thermal_zone_device *tz, int *temp)
{ {
struct exynos_tmu_data *data = p; struct exynos_tmu_data *data = tz->devdata;
int value, ret = 0; int value, ret = 0;
if (!data || !data->tmu_read) if (!data || !data->tmu_read)
...@@ -728,9 +728,9 @@ static void exynos4412_tmu_set_emulation(struct exynos_tmu_data *data, ...@@ -728,9 +728,9 @@ static void exynos4412_tmu_set_emulation(struct exynos_tmu_data *data,
writel(val, data->base + emul_con); writel(val, data->base + emul_con);
} }
static int exynos_tmu_set_emulation(void *drv_data, int temp) static int exynos_tmu_set_emulation(struct thermal_zone_device *tz, int temp)
{ {
struct exynos_tmu_data *data = drv_data; struct exynos_tmu_data *data = tz->devdata;
int ret = -EINVAL; int ret = -EINVAL;
if (data->soc == SOC_ARCH_EXYNOS4210) if (data->soc == SOC_ARCH_EXYNOS4210)
...@@ -750,7 +750,7 @@ static int exynos_tmu_set_emulation(void *drv_data, int temp) ...@@ -750,7 +750,7 @@ static int exynos_tmu_set_emulation(void *drv_data, int temp)
} }
#else #else
#define exynos4412_tmu_set_emulation NULL #define exynos4412_tmu_set_emulation NULL
static int exynos_tmu_set_emulation(void *drv_data, int temp) static int exynos_tmu_set_emulation(struct thermal_zone_device *tz, int temp)
{ return -EINVAL; } { return -EINVAL; }
#endif /* CONFIG_THERMAL_EMULATION */ #endif /* CONFIG_THERMAL_EMULATION */
...@@ -997,7 +997,7 @@ static int exynos_map_dt_data(struct platform_device *pdev) ...@@ -997,7 +997,7 @@ static int exynos_map_dt_data(struct platform_device *pdev)
return 0; return 0;
} }
static const struct thermal_zone_of_device_ops exynos_sensor_ops = { static const struct thermal_zone_device_ops exynos_sensor_ops = {
.get_temp = exynos_get_temp, .get_temp = exynos_get_temp,
.set_emul_temp = exynos_tmu_set_emulation, .set_emul_temp = exynos_tmu_set_emulation,
}; };
...@@ -1091,8 +1091,8 @@ static int exynos_tmu_probe(struct platform_device *pdev) ...@@ -1091,8 +1091,8 @@ static int exynos_tmu_probe(struct platform_device *pdev)
* data->tzd must be registered before calling exynos_tmu_initialize(), * data->tzd must be registered before calling exynos_tmu_initialize(),
* requesting irq and calling exynos_tmu_control(). * requesting irq and calling exynos_tmu_control().
*/ */
data->tzd = thermal_zone_of_sensor_register(&pdev->dev, 0, data, data->tzd = devm_thermal_of_zone_register(&pdev->dev, 0, data,
&exynos_sensor_ops); &exynos_sensor_ops);
if (IS_ERR(data->tzd)) { if (IS_ERR(data->tzd)) {
ret = PTR_ERR(data->tzd); ret = PTR_ERR(data->tzd);
if (ret != -EPROBE_DEFER) if (ret != -EPROBE_DEFER)
...@@ -1104,21 +1104,19 @@ static int exynos_tmu_probe(struct platform_device *pdev) ...@@ -1104,21 +1104,19 @@ static int exynos_tmu_probe(struct platform_device *pdev)
ret = exynos_tmu_initialize(pdev); ret = exynos_tmu_initialize(pdev);
if (ret) { if (ret) {
dev_err(&pdev->dev, "Failed to initialize TMU\n"); dev_err(&pdev->dev, "Failed to initialize TMU\n");
goto err_thermal; goto err_sclk;
} }
ret = devm_request_irq(&pdev->dev, data->irq, exynos_tmu_irq, ret = devm_request_irq(&pdev->dev, data->irq, exynos_tmu_irq,
IRQF_TRIGGER_RISING | IRQF_SHARED, dev_name(&pdev->dev), data); IRQF_TRIGGER_RISING | IRQF_SHARED, dev_name(&pdev->dev), data);
if (ret) { if (ret) {
dev_err(&pdev->dev, "Failed to request irq: %d\n", data->irq); dev_err(&pdev->dev, "Failed to request irq: %d\n", data->irq);
goto err_thermal; goto err_sclk;
} }
exynos_tmu_control(pdev, true); exynos_tmu_control(pdev, true);
return 0; return 0;
err_thermal:
thermal_zone_of_sensor_unregister(&pdev->dev, data->tzd);
err_sclk: err_sclk:
clk_disable_unprepare(data->sclk); clk_disable_unprepare(data->sclk);
err_clk: err_clk:
...@@ -1136,9 +1134,7 @@ static int exynos_tmu_probe(struct platform_device *pdev) ...@@ -1136,9 +1134,7 @@ static int exynos_tmu_probe(struct platform_device *pdev)
static int exynos_tmu_remove(struct platform_device *pdev) static int exynos_tmu_remove(struct platform_device *pdev)
{ {
struct exynos_tmu_data *data = platform_get_drvdata(pdev); struct exynos_tmu_data *data = platform_get_drvdata(pdev);
struct thermal_zone_device *tzd = data->tzd;
thermal_zone_of_sensor_unregister(&pdev->dev, tzd);
exynos_tmu_control(pdev, false); exynos_tmu_control(pdev, false);
clk_disable_unprepare(data->sclk); clk_disable_unprepare(data->sclk);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment