Skip to content

Commit

Permalink
thermal: exynos: check STATUS register in exynos_tmu_initialize()
Browse files Browse the repository at this point in the history
STATUS register is present on all SoCs so move its checking into
exynos_tmu_initialize().

There should be no functional changes caused by this patch.

Signed-off-by: Bartlomiej Zolnierkiewicz <[email protected]>
Reviewed-by: Daniel Lezcano <[email protected]>
Signed-off-by: Eduardo Valentin <[email protected]>
  • Loading branch information
bzolnier authored and Eduardo Valentin committed May 6, 2018
1 parent 8f1c404 commit 97b3881
Showing 1 changed file with 13 additions and 32 deletions.
45 changes: 13 additions & 32 deletions drivers/thermal/samsung/exynos_tmu.c
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +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);
unsigned int status;
int ret = 0, temp;

if (!trips) {
Expand Down Expand Up @@ -359,7 +360,13 @@ static int exynos_tmu_initialize(struct platform_device *pdev)
clk_enable(data->clk);
if (!IS_ERR(data->clk_sec))
clk_enable(data->clk_sec);
ret = data->tmu_initialize(pdev);

status = readb(data->base + EXYNOS_TMU_REG_STATUS);
if (!status)
ret = -EBUSY;
else
ret = data->tmu_initialize(pdev);

clk_disable(data->clk);
mutex_unlock(&data->lock);
if (!IS_ERR(data->clk_sec))
Expand Down Expand Up @@ -406,13 +413,6 @@ static int exynos4210_tmu_initialize(struct platform_device *pdev)
of_thermal_get_trip_points(tz);
int ret = 0, threshold_code, i;
unsigned long reference, temp;
unsigned int status;

status = readb(data->base + EXYNOS_TMU_REG_STATUS);
if (!status) {
ret = -EBUSY;
goto out;
}

sanitize_temp_error(data, readl(data->base + EXYNOS_TMU_REG_TRIMINFO));

Expand Down Expand Up @@ -441,16 +441,10 @@ static int exynos4412_tmu_initialize(struct platform_device *pdev)
struct exynos_tmu_data *data = platform_get_drvdata(pdev);
const struct thermal_trip * const trips =
of_thermal_get_trip_points(data->tzd);
unsigned int status, trim_info, con, ctrl, rising_threshold;
unsigned int trim_info, con, ctrl, rising_threshold;
int ret = 0, threshold_code, i;
unsigned long crit_temp = 0;

status = readb(data->base + EXYNOS_TMU_REG_STATUS);
if (!status) {
ret = -EBUSY;
goto out;
}

if (data->soc == SOC_ARCH_EXYNOS3250 ||
data->soc == SOC_ARCH_EXYNOS4412 ||
data->soc == SOC_ARCH_EXYNOS5250) {
Expand Down Expand Up @@ -497,25 +491,18 @@ static int exynos4412_tmu_initialize(struct platform_device *pdev)
con |= (1 << EXYNOS_TMU_THERM_TRIP_EN_SHIFT);
writel(con, data->base + EXYNOS_TMU_REG_CONTROL);

out:
return ret;
}

static int exynos5433_tmu_initialize(struct platform_device *pdev)
{
struct exynos_tmu_data *data = platform_get_drvdata(pdev);
struct thermal_zone_device *tz = data->tzd;
unsigned int status, trim_info;
unsigned int trim_info;
unsigned int rising_threshold = 0, falling_threshold = 0;
int temp, temp_hist;
int ret = 0, threshold_code, i, sensor_id, cal_type;

status = readb(data->base + EXYNOS_TMU_REG_STATUS);
if (!status) {
ret = -EBUSY;
goto out;
}

trim_info = readl(data->base + EXYNOS_TMU_REG_TRIMINFO);
sanitize_temp_error(data, trim_info);

Expand Down Expand Up @@ -590,26 +577,20 @@ static int exynos5433_tmu_initialize(struct platform_device *pdev)
}

data->tmu_clear_irqs(data);
out:

return ret;
}

static int exynos7_tmu_initialize(struct platform_device *pdev)
{
struct exynos_tmu_data *data = platform_get_drvdata(pdev);
struct thermal_zone_device *tz = data->tzd;
unsigned int status, trim_info;
unsigned int trim_info;
unsigned int rising_threshold = 0, falling_threshold = 0;
int ret = 0, threshold_code, i;
int temp, temp_hist;
unsigned int reg_off, bit_off;

status = readb(data->base + EXYNOS_TMU_REG_STATUS);
if (!status) {
ret = -EBUSY;
goto out;
}

trim_info = readl(data->base + EXYNOS_TMU_REG_TRIMINFO);

data->temp_error1 = trim_info & EXYNOS7_TMU_TEMP_MASK;
Expand Down Expand Up @@ -667,7 +648,7 @@ static int exynos7_tmu_initialize(struct platform_device *pdev)
}

data->tmu_clear_irqs(data);
out:

return ret;
}

Expand Down

0 comments on commit 97b3881

Please sign in to comment.