[03/18] thermal: exynos: always check for critical trip points existence
diff mbox

Message ID 1524743493-28113-4-git-send-email-b.zolnierkie@samsung.com
State Accepted
Delegated to: Eduardo Valentin
Headers show

Commit Message

Bartlomiej Zolnierkiewicz April 26, 2018, 11:51 a.m. UTC
* Check for critical trip point existence in exynos_tmu_initialize()
  so it is checked on all SoCs (except Exynos5433 for now).

* Use dev_err() instead of pr_err().

* Fix dev_err() to reference "device tree" not "of-thermal.c".

* Remove no longer needed check from exynos4412_tmu_initialize().

Signed-off-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
---
 drivers/thermal/samsung/exynos_tmu.c | 19 ++++++++++---------
 1 file changed, 10 insertions(+), 9 deletions(-)

Comments

Daniel Lezcano April 30, 2018, 2:44 p.m. UTC | #1
On Thu, Apr 26, 2018 at 01:51:18PM +0200, Bartlomiej Zolnierkiewicz wrote:
> * Check for critical trip point existence in exynos_tmu_initialize()
>   so it is checked on all SoCs (except Exynos5433 for now).

Why "except Exynos5433" ?
 
> * Use dev_err() instead of pr_err().
> 
> * Fix dev_err() to reference "device tree" not "of-thermal.c".
> 
> * Remove no longer needed check from exynos4412_tmu_initialize().
> 
> Signed-off-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
> ---
Bartlomiej Zolnierkiewicz April 30, 2018, 3:24 p.m. UTC | #2
On Monday, April 30, 2018 04:44:50 PM Daniel Lezcano wrote:
> On Thu, Apr 26, 2018 at 01:51:18PM +0200, Bartlomiej Zolnierkiewicz wrote:
> > * Check for critical trip point existence in exynos_tmu_initialize()
> >   so it is checked on all SoCs (except Exynos5433 for now).
> 
> Why "except Exynos5433" ?

I was a bit vague here - Exynos5433 DTS needs to be fixed first to define
critical trip points.

Best regards,
--
Bartlomiej Zolnierkiewicz
Samsung R&D Institute Poland
Samsung Electronics
Daniel Lezcano May 1, 2018, 9 a.m. UTC | #3
On Mon, Apr 30, 2018 at 05:24:15PM +0200, Bartlomiej Zolnierkiewicz wrote:
> On Monday, April 30, 2018 04:44:50 PM Daniel Lezcano wrote:
> > On Thu, Apr 26, 2018 at 01:51:18PM +0200, Bartlomiej Zolnierkiewicz wrote:
> > > * Check for critical trip point existence in exynos_tmu_initialize()
> > >   so it is checked on all SoCs (except Exynos5433 for now).
> > 
> > Why "except Exynos5433" ?
> 
> I was a bit vague here - Exynos5433 DTS needs to be fixed first to define
> critical trip points.

Is it possible to fix the DT in the series, so we get rid of the "FIXME" ?
Bartlomiej Zolnierkiewicz May 2, 2018, 9:16 a.m. UTC | #4
On Tuesday, May 01, 2018 11:00:18 AM Daniel Lezcano wrote:
> On Mon, Apr 30, 2018 at 05:24:15PM +0200, Bartlomiej Zolnierkiewicz wrote:
> > On Monday, April 30, 2018 04:44:50 PM Daniel Lezcano wrote:
> > > On Thu, Apr 26, 2018 at 01:51:18PM +0200, Bartlomiej Zolnierkiewicz wrote:
> > > > * Check for critical trip point existence in exynos_tmu_initialize()
> > > >   so it is checked on all SoCs (except Exynos5433 for now).
> > > 
> > > Why "except Exynos5433" ?
> > 
> > I was a bit vague here - Exynos5433 DTS needs to be fixed first to define
> > critical trip points.
> 
> Is it possible to fix the DT in the series, so we get rid of the "FIXME" ?

This DT change needs more effort so it is planned for some later time
(also doing it in this series would create dependency on arm-soc tree).

Best regards,
--
Bartlomiej Zolnierkiewicz
Samsung R&D Institute Poland
Samsung Electronics

Patch
diff mbox

diff --git a/drivers/thermal/samsung/exynos_tmu.c b/drivers/thermal/samsung/exynos_tmu.c
index 9e040eb..a0c1604 100644
--- a/drivers/thermal/samsung/exynos_tmu.c
+++ b/drivers/thermal/samsung/exynos_tmu.c
@@ -331,7 +331,7 @@  static int exynos_tmu_initialize(struct platform_device *pdev)
 	struct thermal_zone_device *tzd = data->tzd;
 	const struct thermal_trip * const trips =
 		of_thermal_get_trip_points(tzd);
-	int ret;
+	int ret = 0, temp;
 
 	if (!trips) {
 		dev_err(&pdev->dev,
@@ -339,6 +339,14 @@  static int exynos_tmu_initialize(struct platform_device *pdev)
 		return -ENODEV;
 	}
 
+	if (data->soc != SOC_ARCH_EXYNOS5433) /* FIXME */
+		ret = tzd->ops->get_crit_temp(tzd, &temp);
+	if (ret) {
+		dev_err(&pdev->dev,
+			"No CRITICAL trip point defined in device tree!\n");
+		goto out;
+	}
+
 	if (of_thermal_get_ntrips(tzd) > data->ntrip) {
 		dev_info(&pdev->dev,
 			 "More trip points than supported by this TMU.\n");
@@ -356,7 +364,7 @@  static int exynos_tmu_initialize(struct platform_device *pdev)
 	mutex_unlock(&data->lock);
 	if (!IS_ERR(data->clk_sec))
 		clk_disable(data->clk_sec);
-
+out:
 	return ret;
 }
 
@@ -480,13 +488,6 @@  static int exynos4412_tmu_initialize(struct platform_device *pdev)
 		}
 	}
 
-	if (i == of_thermal_get_ntrips(data->tzd)) {
-		pr_err("%s: No CRITICAL trip point defined at of-thermal.c!\n",
-		       __func__);
-		ret = -EINVAL;
-		goto out;
-	}
-
 	threshold_code = temp_to_code(data, crit_temp / MCELSIUS);
 	/* 1-4 level to be assigned in th0 reg */
 	rising_threshold &= ~(0xff << 8 * i);