]> nv-tegra.nvidia Code Review - linux-2.6.git/commitdiff
Thermal: generic_adc_thermal: Add second value read back on read channel raw
authorJinyoung Park <jinyoungp@nvidia.com>
Fri, 21 Jun 2013 06:53:20 +0000 (15:53 +0900)
committerMrutyunjay Sawant <msawant@nvidia.com>
Tue, 3 Sep 2013 13:52:51 +0000 (06:52 -0700)
Added second value read back on read channel raw.

Bug 1287901

Signed-off-by: Jinyoung Park <jinyoungp@nvidia.com>
Reviewed-on: http://git-master/r/241374
(cherry picked from commit 59aa8e57f663512f4489c11984673bc87e9a5738)

Change-Id: I0bde33c4cb16e1c500b0cf86b64ec3e84e9a61d7
Signed-off-by: Jinyoung Park <jinyoungp@nvidia.com>
Reviewed-on: http://git-master/r/252880
Reviewed-by: Mrutyunjay Sawant <msawant@nvidia.com>
Tested-by: Mrutyunjay Sawant <msawant@nvidia.com>
arch/arm/mach-tegra/board-tegratab-sensors.c
drivers/thermal/generic_adc_thermal.c
include/linux/generic_adc_thermal.h

index 06f1df798ea684787d48c32c9237f53973ca8001..1ce050d6db01ed61551103768717a8d22cc47cd6 100644 (file)
@@ -738,14 +738,14 @@ static struct ntc_thermistor_adc_table thermistor_table[] = {
 };
 
 static int gadc_thermal_thermistor_adc_to_temp(
-               struct gadc_thermal_platform_data *pdata, int val)
+               struct gadc_thermal_platform_data *pdata, int *val, int *val2)
 {
        int table_size = ARRAY_SIZE(thermistor_table);
        int temp = 0, adc_hi, adc_lo;
        int i;
 
        for (i = 0; i < table_size; i++)
-               if (val >= thermistor_table[i].adc)
+               if (*val >= thermistor_table[i].adc)
                        break;
 
        if (i == 0) {
@@ -756,18 +756,18 @@ static int gadc_thermal_thermistor_adc_to_temp(
                adc_hi = thermistor_table[i - 1].adc;
                adc_lo = thermistor_table[i].adc;
                temp = thermistor_table[i - 1].temp * 1000;
-               temp += ((val - adc_lo) * 1000 / (adc_hi - adc_lo));
+               temp += ((*val - adc_lo) * 1000 / (adc_hi - adc_lo));
        }
 
        return temp;
 };
 
 static int gadc_thermal_tdiode_adc_to_temp(
-               struct gadc_thermal_platform_data *pdata, int val)
+               struct gadc_thermal_platform_data *pdata, int *val, int *val2)
 {
        /* TODO: add adc raw to temp conversion. */
        pr_warn("%s: No adc raw to temp conversion.\n", __func__);
-       return val;
+       return *val;
 };
 
 static struct gadc_thermal_platform_data gadc_thermal_thermistor_pdata = {
index e2f05558f28c54e68da473cc882dc516365f12aa..486bd2658ac5e89c00ed125934b27f8e8f7cc41a 100644 (file)
@@ -46,22 +46,23 @@ static int gadc_thermal_get_temp(struct thermal_zone_device *tz,
                                 unsigned long *temp)
 {
        struct gadc_thermal_driver_data *drvdata = tz->devdata;
-       int val;
+       struct gadc_thermal_platform_data *pdata = drvdata->pdata;
+       int val, val2 = 0;
        int ret;
 
-       ret = iio_st_read_channel_raw(drvdata->channel, &val);
+       ret = iio_st_read_channel_raw(drvdata->channel, &val, &val2);
        if (ret < 0) {
                dev_err(drvdata->dev, "%s: Failed to read channel, %d\n",
                        __func__, ret);
                return ret;
        }
 
-       if (drvdata->pdata->adc_to_temp)
-               *temp = drvdata->pdata->adc_to_temp(drvdata->pdata, val);
+       if (pdata->adc_to_temp)
+               *temp = pdata->adc_to_temp(pdata, &val, &val2);
        else
                *temp = val;
 
-       *temp += drvdata->pdata->temp_offset;
+       *temp += pdata->temp_offset;
        return 0;
 }
 
@@ -73,24 +74,24 @@ static struct thermal_zone_device_ops gadc_thermal_ops = {
 static int adc_temp_show(struct seq_file *s, void *p)
 {
        struct gadc_thermal_driver_data *drvdata = s->private;
-       int adc, temp;
+       struct gadc_thermal_platform_data *pdata = drvdata->pdata;
+       int val, val2 = 0, temp;
        int ret;
 
-       ret = iio_st_read_channel_raw(drvdata->channel, &adc);
+       ret = iio_st_read_channel_raw(drvdata->channel, &val, &val2);
        if (ret < 0) {
                dev_err(drvdata->dev, "%s: Failed to read channel, %d\n",
                        __func__, ret);
                return ret;
        }
 
-       if (drvdata->pdata->adc_to_temp)
-               temp = drvdata->pdata->adc_to_temp(drvdata->pdata, adc);
+       if (pdata->adc_to_temp)
+               temp = pdata->adc_to_temp(pdata, &val, &val2);
        else
-               temp = adc;
+               temp = val;
 
-       temp += drvdata->pdata->temp_offset;
-
-       seq_printf(s, "%d %d\n", adc, temp);
+       temp += pdata->temp_offset;
+       seq_printf(s, "%d %d %d\n", val, val2, temp);
        return 0;
 }
 
index 0ab3323227de553382737a156d5222e24355efa2..4c060ce942d23b5e110ace3fa5ed126820496afa 100644 (file)
@@ -29,6 +29,6 @@ struct gadc_thermal_platform_data {
        const char *iio_channel_name;
        const char *tz_name;
        int temp_offset; /* mC */
-       int (*adc_to_temp)(struct gadc_thermal_platform_data *pdata, int val);
+       int (*adc_to_temp)(struct gadc_thermal_platform_data *, int *, int *);
 };
 #endif /* GENERIC_ADC_THERMAL_H */