diff mbox series

[v4,12/12] iio: adc: qcom-vadc-common: use <linux/units.h> helpers

Message ID 1576386975-7941-13-git-send-email-akinobu.mita@gmail.com (mailing list archive)
State Not Applicable
Headers show
Series add header file for kelvin to/from Celsius conversion helpers | expand

Commit Message

Akinobu Mita Dec. 15, 2019, 5:16 a.m. UTC
This switches the qcom-vadc-common to use milli_kelvin_to_millicelsius()
in <linux/units.h>.

Cc: Jonathan Cameron <jic23@kernel.org>
Cc: Hartmut Knaack <knaack.h@gmx.de>
Cc: Lars-Peter Clausen <lars@metafoo.de>
Cc: Peter Meerwald-Stadler <pmeerw@pmeerw.net>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
---
* v4
- add Reviewed-by tag

 drivers/iio/adc/qcom-vadc-common.c | 6 +++---
 drivers/iio/adc/qcom-vadc-common.h | 1 -
 2 files changed, 3 insertions(+), 4 deletions(-)

Comments

Jonathan Cameron Dec. 15, 2019, 12:29 p.m. UTC | #1
On Sun, 15 Dec 2019 14:16:15 +0900
Akinobu Mita <akinobu.mita@gmail.com> wrote:

> This switches the qcom-vadc-common to use milli_kelvin_to_millicelsius()
> in <linux/units.h>.
> 
> Cc: Jonathan Cameron <jic23@kernel.org>
> Cc: Hartmut Knaack <knaack.h@gmx.de>
> Cc: Lars-Peter Clausen <lars@metafoo.de>
> Cc: Peter Meerwald-Stadler <pmeerw@pmeerw.net>
> Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
> Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>

Acked-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

Thanks,


> ---
> * v4
> - add Reviewed-by tag
> 
>  drivers/iio/adc/qcom-vadc-common.c | 6 +++---
>  drivers/iio/adc/qcom-vadc-common.h | 1 -
>  2 files changed, 3 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/iio/adc/qcom-vadc-common.c b/drivers/iio/adc/qcom-vadc-common.c
> index dcd7fb5..2bb78d1 100644
> --- a/drivers/iio/adc/qcom-vadc-common.c
> +++ b/drivers/iio/adc/qcom-vadc-common.c
> @@ -6,6 +6,7 @@
>  #include <linux/log2.h>
>  #include <linux/err.h>
>  #include <linux/module.h>
> +#include <linux/units.h>
>  
>  #include "qcom-vadc-common.h"
>  
> @@ -236,8 +237,7 @@ static int qcom_vadc_scale_die_temp(const struct vadc_linear_graph *calib_graph,
>  		voltage = 0;
>  	}
>  
> -	voltage -= KELVINMIL_CELSIUSMIL;
> -	*result_mdec = voltage;
> +	*result_mdec = milli_kelvin_to_millicelsius(voltage);
>  
>  	return 0;
>  }
> @@ -325,7 +325,7 @@ static int qcom_vadc_scale_hw_calib_die_temp(
>  {
>  	*result_mdec = qcom_vadc_scale_code_voltage_factor(adc_code,
>  				prescale, data, 2);
> -	*result_mdec -= KELVINMIL_CELSIUSMIL;
> +	*result_mdec = milli_kelvin_to_millicelsius(*result_mdec);
>  
>  	return 0;
>  }
> diff --git a/drivers/iio/adc/qcom-vadc-common.h b/drivers/iio/adc/qcom-vadc-common.h
> index bbb1fa0..e074902a 100644
> --- a/drivers/iio/adc/qcom-vadc-common.h
> +++ b/drivers/iio/adc/qcom-vadc-common.h
> @@ -38,7 +38,6 @@
>  #define VADC_AVG_SAMPLES_MAX			512
>  #define ADC5_AVG_SAMPLES_MAX			16
>  
> -#define KELVINMIL_CELSIUSMIL			273150
>  #define PMIC5_CHG_TEMP_SCALE_FACTOR		377500
>  #define PMIC5_SMB_TEMP_CONSTANT			419400
>  #define PMIC5_SMB_TEMP_SCALE_FACTOR		356
diff mbox series

Patch

diff --git a/drivers/iio/adc/qcom-vadc-common.c b/drivers/iio/adc/qcom-vadc-common.c
index dcd7fb5..2bb78d1 100644
--- a/drivers/iio/adc/qcom-vadc-common.c
+++ b/drivers/iio/adc/qcom-vadc-common.c
@@ -6,6 +6,7 @@ 
 #include <linux/log2.h>
 #include <linux/err.h>
 #include <linux/module.h>
+#include <linux/units.h>
 
 #include "qcom-vadc-common.h"
 
@@ -236,8 +237,7 @@  static int qcom_vadc_scale_die_temp(const struct vadc_linear_graph *calib_graph,
 		voltage = 0;
 	}
 
-	voltage -= KELVINMIL_CELSIUSMIL;
-	*result_mdec = voltage;
+	*result_mdec = milli_kelvin_to_millicelsius(voltage);
 
 	return 0;
 }
@@ -325,7 +325,7 @@  static int qcom_vadc_scale_hw_calib_die_temp(
 {
 	*result_mdec = qcom_vadc_scale_code_voltage_factor(adc_code,
 				prescale, data, 2);
-	*result_mdec -= KELVINMIL_CELSIUSMIL;
+	*result_mdec = milli_kelvin_to_millicelsius(*result_mdec);
 
 	return 0;
 }
diff --git a/drivers/iio/adc/qcom-vadc-common.h b/drivers/iio/adc/qcom-vadc-common.h
index bbb1fa0..e074902a 100644
--- a/drivers/iio/adc/qcom-vadc-common.h
+++ b/drivers/iio/adc/qcom-vadc-common.h
@@ -38,7 +38,6 @@ 
 #define VADC_AVG_SAMPLES_MAX			512
 #define ADC5_AVG_SAMPLES_MAX			16
 
-#define KELVINMIL_CELSIUSMIL			273150
 #define PMIC5_CHG_TEMP_SCALE_FACTOR		377500
 #define PMIC5_SMB_TEMP_CONSTANT			419400
 #define PMIC5_SMB_TEMP_SCALE_FACTOR		356