[PATCH v2 3/9] thermal: exynos: remove dead code for TYPE_TWO_POINT_TRIMMING calibration

2014-06-17 Thread Bartlomiej Zolnierkiewicz
There are two types of calibration (TYPE_[ONE,TWO]_POINT_TRIMMING)
implemented in the driver currently, the other ones are defined in
calibration_type enum but are not implemented.

The commit 9d97e5c8 ("hwmon: Add driver for EXYNOS4 TMU") added
TYPE_TWO_POINT_TRIMMING implementation but no users of it have
ever been added.  Thus it has been a dead code for almost 3 years
now and should be removed.

We don't keep the unused/untested features in the kernel just
in case that some future hardware might need it.  Such code has
a real maintainance cost (all other code changes have to take
the dead code into account) and usually makes future changes
more difficult, not easier (i.e. recent additions of Exynos5420
SoC and Exynos5260 SoC thermal support has not made use of any
of the driver's currently unused/untested features, moreover
the recently added code is more complex than needed because of
the existing dead code).  Also all removed dead code is still
accessible in the kernel git repository and can be easily
brought back if/when needed.

This patch does TYPE_TWO_POINT_TRIMMING and related dead code
removals.

Please note that in exynos_tmu_initialize() if ->temp_error2 was
zero then its value was obtained from bits 8-15 of efuse_value
(bits 16-31 are always zero).  After TYPE_TWO_POINT_TRIMMING code
removal ->temp_error2 was no longer needed and was also removed.
Thus only bits 0-7 of efuse_value are ever used and its type can
be changed from u32 to u8.

There should be no functional changes caused by this patch.

Signed-off-by: Bartlomiej Zolnierkiewicz 
Acked-by: Kyungmin Park 
---
 drivers/thermal/samsung/exynos_tmu.c  | 55 ++-
 drivers/thermal/samsung/exynos_tmu.h  | 20 +--
 drivers/thermal/samsung/exynos_tmu_data.c | 27 +--
 drivers/thermal/samsung/exynos_tmu_data.h |  2 --
 4 files changed, 12 insertions(+), 92 deletions(-)

diff --git a/drivers/thermal/samsung/exynos_tmu.c 
b/drivers/thermal/samsung/exynos_tmu.c
index 1050b36..1c64508 100644
--- a/drivers/thermal/samsung/exynos_tmu.c
+++ b/drivers/thermal/samsung/exynos_tmu.c
@@ -48,8 +48,7 @@
  * @lock: lock to implement synchronization.
  * @clk: pointer to the clock structure.
  * @clk_sec: pointer to the clock structure for accessing the base_second.
- * @temp_error1: fused value of the first point trim.
- * @temp_error2: fused value of the second point trim.
+ * @temp_error: fused value of the first point trim.
  * @regulator: pointer to the TMU regulator structure.
  * @reg_conf: pointer to structure to register with core thermal.
  */
@@ -63,14 +62,13 @@ struct exynos_tmu_data {
struct work_struct irq_work;
struct mutex lock;
struct clk *clk, *clk_sec;
-   u8 temp_error1, temp_error2;
+   u8 temp_error;
struct regulator *regulator;
struct thermal_sensor_conf *reg_conf;
 };
 
 /*
  * TMU treats temperature as a mapped temperature code.
- * The temperature is converted differently depending on the calibration type.
  */
 static int temp_to_code(struct exynos_tmu_data *data, u8 temp)
 {
@@ -84,20 +82,7 @@ static int temp_to_code(struct exynos_tmu_data *data, u8 
temp)
goto out;
}
 
-   switch (pdata->cal_type) {
-   case TYPE_TWO_POINT_TRIMMING:
-   temp_code = (temp - pdata->first_point_trim) *
-   (data->temp_error2 - data->temp_error1) /
-   (pdata->second_point_trim - pdata->first_point_trim) +
-   data->temp_error1;
-   break;
-   case TYPE_ONE_POINT_TRIMMING:
-   temp_code = temp + data->temp_error1 - pdata->first_point_trim;
-   break;
-   default:
-   temp_code = temp + pdata->default_temp_offset;
-   break;
-   }
+   temp_code = temp + data->temp_error - pdata->first_point_trim;
 out:
return temp_code;
 }
@@ -118,20 +103,7 @@ static int code_to_temp(struct exynos_tmu_data *data, u8 
temp_code)
goto out;
}
 
-   switch (pdata->cal_type) {
-   case TYPE_TWO_POINT_TRIMMING:
-   temp = (temp_code - data->temp_error1) *
-   (pdata->second_point_trim - pdata->first_point_trim) /
-   (data->temp_error2 - data->temp_error1) +
-   pdata->first_point_trim;
-   break;
-   case TYPE_ONE_POINT_TRIMMING:
-   temp = temp_code - data->temp_error1 + pdata->first_point_trim;
-   break;
-   default:
-   temp = temp_code - pdata->default_temp_offset;
-   break;
-   }
+   temp = temp_code - data->temp_error + pdata->first_point_trim;
 out:
return temp;
 }
@@ -187,19 +159,12 @@ static int exynos_tmu_initialize(struct platform_device 
*pdev)
else
trim_info = readl(data->base + reg->triminfo_data);
}
-   

[PATCH v2 3/9] thermal: exynos: remove dead code for TYPE_TWO_POINT_TRIMMING calibration

2014-06-17 Thread Bartlomiej Zolnierkiewicz
There are two types of calibration (TYPE_[ONE,TWO]_POINT_TRIMMING)
implemented in the driver currently, the other ones are defined in
calibration_type enum but are not implemented.

The commit 9d97e5c8 (hwmon: Add driver for EXYNOS4 TMU) added
TYPE_TWO_POINT_TRIMMING implementation but no users of it have
ever been added.  Thus it has been a dead code for almost 3 years
now and should be removed.

We don't keep the unused/untested features in the kernel just
in case that some future hardware might need it.  Such code has
a real maintainance cost (all other code changes have to take
the dead code into account) and usually makes future changes
more difficult, not easier (i.e. recent additions of Exynos5420
SoC and Exynos5260 SoC thermal support has not made use of any
of the driver's currently unused/untested features, moreover
the recently added code is more complex than needed because of
the existing dead code).  Also all removed dead code is still
accessible in the kernel git repository and can be easily
brought back if/when needed.

This patch does TYPE_TWO_POINT_TRIMMING and related dead code
removals.

Please note that in exynos_tmu_initialize() if -temp_error2 was
zero then its value was obtained from bits 8-15 of efuse_value
(bits 16-31 are always zero).  After TYPE_TWO_POINT_TRIMMING code
removal -temp_error2 was no longer needed and was also removed.
Thus only bits 0-7 of efuse_value are ever used and its type can
be changed from u32 to u8.

There should be no functional changes caused by this patch.

Signed-off-by: Bartlomiej Zolnierkiewicz b.zolnier...@samsung.com
Acked-by: Kyungmin Park kyungmin.p...@samsung.com
---
 drivers/thermal/samsung/exynos_tmu.c  | 55 ++-
 drivers/thermal/samsung/exynos_tmu.h  | 20 +--
 drivers/thermal/samsung/exynos_tmu_data.c | 27 +--
 drivers/thermal/samsung/exynos_tmu_data.h |  2 --
 4 files changed, 12 insertions(+), 92 deletions(-)

diff --git a/drivers/thermal/samsung/exynos_tmu.c 
b/drivers/thermal/samsung/exynos_tmu.c
index 1050b36..1c64508 100644
--- a/drivers/thermal/samsung/exynos_tmu.c
+++ b/drivers/thermal/samsung/exynos_tmu.c
@@ -48,8 +48,7 @@
  * @lock: lock to implement synchronization.
  * @clk: pointer to the clock structure.
  * @clk_sec: pointer to the clock structure for accessing the base_second.
- * @temp_error1: fused value of the first point trim.
- * @temp_error2: fused value of the second point trim.
+ * @temp_error: fused value of the first point trim.
  * @regulator: pointer to the TMU regulator structure.
  * @reg_conf: pointer to structure to register with core thermal.
  */
@@ -63,14 +62,13 @@ struct exynos_tmu_data {
struct work_struct irq_work;
struct mutex lock;
struct clk *clk, *clk_sec;
-   u8 temp_error1, temp_error2;
+   u8 temp_error;
struct regulator *regulator;
struct thermal_sensor_conf *reg_conf;
 };
 
 /*
  * TMU treats temperature as a mapped temperature code.
- * The temperature is converted differently depending on the calibration type.
  */
 static int temp_to_code(struct exynos_tmu_data *data, u8 temp)
 {
@@ -84,20 +82,7 @@ static int temp_to_code(struct exynos_tmu_data *data, u8 
temp)
goto out;
}
 
-   switch (pdata-cal_type) {
-   case TYPE_TWO_POINT_TRIMMING:
-   temp_code = (temp - pdata-first_point_trim) *
-   (data-temp_error2 - data-temp_error1) /
-   (pdata-second_point_trim - pdata-first_point_trim) +
-   data-temp_error1;
-   break;
-   case TYPE_ONE_POINT_TRIMMING:
-   temp_code = temp + data-temp_error1 - pdata-first_point_trim;
-   break;
-   default:
-   temp_code = temp + pdata-default_temp_offset;
-   break;
-   }
+   temp_code = temp + data-temp_error - pdata-first_point_trim;
 out:
return temp_code;
 }
@@ -118,20 +103,7 @@ static int code_to_temp(struct exynos_tmu_data *data, u8 
temp_code)
goto out;
}
 
-   switch (pdata-cal_type) {
-   case TYPE_TWO_POINT_TRIMMING:
-   temp = (temp_code - data-temp_error1) *
-   (pdata-second_point_trim - pdata-first_point_trim) /
-   (data-temp_error2 - data-temp_error1) +
-   pdata-first_point_trim;
-   break;
-   case TYPE_ONE_POINT_TRIMMING:
-   temp = temp_code - data-temp_error1 + pdata-first_point_trim;
-   break;
-   default:
-   temp = temp_code - pdata-default_temp_offset;
-   break;
-   }
+   temp = temp_code - data-temp_error + pdata-first_point_trim;
 out:
return temp;
 }
@@ -187,19 +159,12 @@ static int exynos_tmu_initialize(struct platform_device 
*pdev)
else
trim_info = readl(data-base + reg-triminfo_data);