Re: [PATCH 04/10] thermal: exynos: remove dead code for TYPE_TWO_POINT_TRIMMING calibration

2014-05-18 Thread Amit Kachhap
On 5/5/14, Bartlomiej Zolnierkiewicz b.zolnier...@samsung.com wrote:
 Only TYPE_ONE_POINT_TRIMMING calibration is used so remove
 the dead code for TYPE_TWO_POINT_TRIMMING calibration.
I prefer to retain this feature as it is provided by the TMU
controller. This will avoid unnecessary churning of code when some new
soc wants to use it. 2 point trimming should ideally give best
compensated thermal values.

 There should be no functional changes caused by this patch.

 Signed-off-by: Bartlomiej Zolnierkiewicz b.zolnier...@samsung.com
 ---
  drivers/thermal/samsung/exynos_tmu.c  | 55
 ++-
  drivers/thermal/samsung/exynos_tmu.h  | 20 +--
  drivers/thermal/samsung/exynos_tmu_data.c | 17 +-
  drivers/thermal/samsung/exynos_tmu_data.h |  2 --
  4 files changed, 12 insertions(+), 82 deletions(-)

 diff --git a/drivers/thermal/samsung/exynos_tmu.c
 b/drivers/thermal/samsung/exynos_tmu.c
 index 9f2a5ee..903566f 100644
 --- a/drivers/thermal/samsung/exynos_tmu.c
 +++ b/drivers/thermal/samsung/exynos_tmu.c
 @@ -47,8 +47,7 @@
   * @irq_work: pointer to the irq work structure.
   * @lock: lock to implement synchronization.
   * @clk: pointer to the clock structure.
 - * @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.
   */
 @@ -62,14 +61,13 @@ struct exynos_tmu_data {
   struct work_struct irq_work;
   struct mutex lock;
   struct clk *clk;
 - 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)
  {
 @@ -83,20 +81,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;
  }
 @@ -117,20 +102,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;
  }
 @@ -179,19 +151,12 @@ static int exynos_tmu_initialize(struct
 platform_device *pdev)
   } else {
   trim_info = readl(data-base + reg-triminfo_data);
   }
 - data-temp_error1 = trim_info  EXYNOS_TMU_TEMP_MASK;
 - data-temp_error2 = ((trim_info  reg-triminfo_85_shift) 
 - EXYNOS_TMU_TEMP_MASK);
 -
 - if (!data-temp_error1 ||
 - (pdata-min_efuse_value  data-temp_error1) ||
 - (data-temp_error1  pdata-max_efuse_value))
 - data-temp_error1 = pdata-efuse_value  EXYNOS_TMU_TEMP_MASK;
 -
 - if (!data-temp_error2)
 - data-temp_error2 =
 - (pdata-efuse_value  reg-triminfo_85_shift) 
 - EXYNOS_TMU_TEMP_MASK;
 + data-temp_error = trim_info  EXYNOS_TMU_TEMP_MASK;
 +
 + if (!data-temp_error ||
 + pdata-min_efuse_value  data-temp_error ||
 + data-temp_error  pdata-max_efuse_value)
 + data-temp_error = pdata-efuse_value  EXYNOS_TMU_TEMP_MASK;

   if (pdata-max_trigger_level  MAX_THRESHOLD_LEVS) {
   dev_err(pdev-dev, Invalid max trigger level\n);
 diff --git a/drivers/thermal/samsung/exynos_tmu.h
 b/drivers/thermal/samsung/exynos_tmu.h
 index e417af8..186e39e 100644
 --- a/drivers/thermal/samsung/exynos_tmu.h
 +++ 

Re: [PATCH 04/10] thermal: exynos: remove dead code for TYPE_TWO_POINT_TRIMMING calibration

2014-05-15 Thread Eduardo Valentin
Hello Bartlomiej,

On Mon, May 05, 2014 at 01:15:33PM +0200, Bartlomiej Zolnierkiewicz wrote:
 Only TYPE_ONE_POINT_TRIMMING calibration is used so remove
 the dead code for TYPE_TWO_POINT_TRIMMING calibration.
 

Only TYPE_ONE_POINT_TRIMMING is used by which SoC? This patch removes
all four types of calibrations, as present in the current code. Is this
the expected outcome?

According to commit 9d97e5c8, which introduced this feature,
TYPE_TWO_POINT_TRIMMING is supported by exynos4 tmu, as per code
history, for instance.

 There should be no functional changes caused by this patch.
 

Well, the patch seams to be doing more than removing type two trimming.

 Signed-off-by: Bartlomiej Zolnierkiewicz b.zolnier...@samsung.com
 ---
  drivers/thermal/samsung/exynos_tmu.c  | 55 
 ++-
  drivers/thermal/samsung/exynos_tmu.h  | 20 +--
  drivers/thermal/samsung/exynos_tmu_data.c | 17 +-
  drivers/thermal/samsung/exynos_tmu_data.h |  2 --
  4 files changed, 12 insertions(+), 82 deletions(-)
 
 diff --git a/drivers/thermal/samsung/exynos_tmu.c 
 b/drivers/thermal/samsung/exynos_tmu.c
 index 9f2a5ee..903566f 100644
 --- a/drivers/thermal/samsung/exynos_tmu.c
 +++ b/drivers/thermal/samsung/exynos_tmu.c
 @@ -47,8 +47,7 @@
   * @irq_work: pointer to the irq work structure.
   * @lock: lock to implement synchronization.
   * @clk: pointer to the clock structure.
 - * @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.
   */
 @@ -62,14 +61,13 @@ struct exynos_tmu_data {
   struct work_struct irq_work;
   struct mutex lock;
   struct clk *clk;
 - 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)
  {
 @@ -83,20 +81,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;
  }
 @@ -117,20 +102,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;
  }
 @@ -179,19 +151,12 @@ static int exynos_tmu_initialize(struct platform_device 
 *pdev)
   } else {
   trim_info = readl(data-base + reg-triminfo_data);
   }
 - data-temp_error1 = trim_info  EXYNOS_TMU_TEMP_MASK;
 - data-temp_error2 = ((trim_info  reg-triminfo_85_shift) 
 - EXYNOS_TMU_TEMP_MASK);
 -
 - if (!data-temp_error1 ||
 - (pdata-min_efuse_value  data-temp_error1) ||
 - (data-temp_error1  pdata-max_efuse_value))
 - data-temp_error1 = pdata-efuse_value  EXYNOS_TMU_TEMP_MASK;
 -
 - if (!data-temp_error2)
 - data-temp_error2 =
 - (pdata-efuse_value  reg-triminfo_85_shift) 
 - EXYNOS_TMU_TEMP_MASK;
 + data-temp_error = trim_info  EXYNOS_TMU_TEMP_MASK;
 +
 + if (!data-temp_error ||
 + pdata-min_efuse_value  data-temp_error ||
 + data-temp_error  pdata-max_efuse_value)
 + data-temp_error = pdata-efuse_value  EXYNOS_TMU_TEMP_MASK;
  
   if (pdata-max_trigger_level  MAX_THRESHOLD_LEVS) {
   dev_err(pdev-dev, Invalid max 

Re: [PATCH 04/10] thermal: exynos: remove dead code for TYPE_TWO_POINT_TRIMMING calibration

2014-05-15 Thread Bartlomiej Zolnierkiewicz

On Thursday, May 15, 2014 10:31:33 AM Eduardo Valentin wrote:
 Hello Bartlomiej,

Hi,

 On Mon, May 05, 2014 at 01:15:33PM +0200, Bartlomiej Zolnierkiewicz wrote:
  Only TYPE_ONE_POINT_TRIMMING calibration is used so remove
  the dead code for TYPE_TWO_POINT_TRIMMING calibration.
  
 
 Only TYPE_ONE_POINT_TRIMMING is used by which SoC? This patch removes

TYPE_ONE_POINT_TRIMMING is used by all Exynos SoCs currently.

 all four types of calibrations, as present in the current code. Is this
 the expected outcome?

There are only two types of calibration (TYPE_ONE_POINT_TRIMMING and
TYPE_TWO_POINT_TRIMMING) implemented in the driver currently, the other
ones (TYPE_ONE_POINT_TRIMMING_25 and TYPE_ONE_POINT_TRIMMING_85) are
defined in calibration_type enum but are not implemented.

 According to commit 9d97e5c8, which introduced this feature,
 TYPE_TWO_POINT_TRIMMING is supported by exynos4 tmu, as per code
 history, for instance.

The commit 9d97e5c8 (which is from Wed Sep 7 18:49:08 2011) introduced
TYPE_TWO_POINT_TRIMMING implementation but no users of it have ever been
added.  IOW it has been a dead code for over 2.5 years now.

  There should be no functional changes caused by this patch.
  
 
 Well, the patch seams to be doing more than removing type two trimming.

It does related dead code removals.  I can improve the patch description
if needed to be more verbose but it doesn't change the fact that the patch
doesn't contain any functional changes.

  Signed-off-by: Bartlomiej Zolnierkiewicz b.zolnier...@samsung.com
  ---
   drivers/thermal/samsung/exynos_tmu.c  | 55 
  ++-
   drivers/thermal/samsung/exynos_tmu.h  | 20 +--
   drivers/thermal/samsung/exynos_tmu_data.c | 17 +-
   drivers/thermal/samsung/exynos_tmu_data.h |  2 --
   4 files changed, 12 insertions(+), 82 deletions(-)
  
  diff --git a/drivers/thermal/samsung/exynos_tmu.c 
  b/drivers/thermal/samsung/exynos_tmu.c
  index 9f2a5ee..903566f 100644
  --- a/drivers/thermal/samsung/exynos_tmu.c
  +++ b/drivers/thermal/samsung/exynos_tmu.c
  @@ -47,8 +47,7 @@
* @irq_work: pointer to the irq work structure.
* @lock: lock to implement synchronization.
* @clk: pointer to the clock structure.
  - * @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.
*/
  @@ -62,14 +61,13 @@ struct exynos_tmu_data {
  struct work_struct irq_work;
  struct mutex lock;
  struct clk *clk;
  -   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)
   {
  @@ -83,20 +81,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;
   }
  @@ -117,20 +102,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;
   }
  @@ -179,19 +151,12 @@ static int exynos_tmu_initialize(struct 
  platform_device *pdev)
  } else {
  trim_info = readl(data-base + reg-triminfo_data);
  }
  -   data-temp_error1 = trim_info  EXYNOS_TMU_TEMP_MASK;
  -   data-temp_error2 = ((trim_info  reg-triminfo_85_shift) 
  -   

[PATCH 04/10] thermal: exynos: remove dead code for TYPE_TWO_POINT_TRIMMING calibration

2014-05-05 Thread Bartlomiej Zolnierkiewicz
Only TYPE_ONE_POINT_TRIMMING calibration is used so remove
the dead code for TYPE_TWO_POINT_TRIMMING calibration.

There should be no functional changes caused by this patch.

Signed-off-by: Bartlomiej Zolnierkiewicz b.zolnier...@samsung.com
---
 drivers/thermal/samsung/exynos_tmu.c  | 55 ++-
 drivers/thermal/samsung/exynos_tmu.h  | 20 +--
 drivers/thermal/samsung/exynos_tmu_data.c | 17 +-
 drivers/thermal/samsung/exynos_tmu_data.h |  2 --
 4 files changed, 12 insertions(+), 82 deletions(-)

diff --git a/drivers/thermal/samsung/exynos_tmu.c 
b/drivers/thermal/samsung/exynos_tmu.c
index 9f2a5ee..903566f 100644
--- a/drivers/thermal/samsung/exynos_tmu.c
+++ b/drivers/thermal/samsung/exynos_tmu.c
@@ -47,8 +47,7 @@
  * @irq_work: pointer to the irq work structure.
  * @lock: lock to implement synchronization.
  * @clk: pointer to the clock structure.
- * @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.
  */
@@ -62,14 +61,13 @@ struct exynos_tmu_data {
struct work_struct irq_work;
struct mutex lock;
struct clk *clk;
-   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)
 {
@@ -83,20 +81,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;
 }
@@ -117,20 +102,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;
 }
@@ -179,19 +151,12 @@ static int exynos_tmu_initialize(struct platform_device 
*pdev)
} else {
trim_info = readl(data-base + reg-triminfo_data);
}
-   data-temp_error1 = trim_info  EXYNOS_TMU_TEMP_MASK;
-   data-temp_error2 = ((trim_info  reg-triminfo_85_shift) 
-   EXYNOS_TMU_TEMP_MASK);
-
-   if (!data-temp_error1 ||
-   (pdata-min_efuse_value  data-temp_error1) ||
-   (data-temp_error1  pdata-max_efuse_value))
-   data-temp_error1 = pdata-efuse_value  EXYNOS_TMU_TEMP_MASK;
-
-   if (!data-temp_error2)
-   data-temp_error2 =
-   (pdata-efuse_value  reg-triminfo_85_shift) 
-   EXYNOS_TMU_TEMP_MASK;
+   data-temp_error = trim_info  EXYNOS_TMU_TEMP_MASK;
+
+   if (!data-temp_error ||
+   pdata-min_efuse_value  data-temp_error ||
+   data-temp_error  pdata-max_efuse_value)
+   data-temp_error = pdata-efuse_value  EXYNOS_TMU_TEMP_MASK;
 
if (pdata-max_trigger_level  MAX_THRESHOLD_LEVS) {
dev_err(pdev-dev, Invalid max trigger level\n);
diff --git a/drivers/thermal/samsung/exynos_tmu.h 
b/drivers/thermal/samsung/exynos_tmu.h
index e417af8..186e39e 100644
--- a/drivers/thermal/samsung/exynos_tmu.h
+++ b/drivers/thermal/samsung/exynos_tmu.h
@@ -26,14 +26,6 @@
 
 #include exynos_thermal_common.h
 
-enum calibration_type {
-   TYPE_ONE_POINT_TRIMMING,
-   TYPE_ONE_POINT_TRIMMING_25,
-   TYPE_ONE_POINT_TRIMMING_85,
-   TYPE_TWO_POINT_TRIMMING,
-   TYPE_NONE,
-};
-
 enum