Commit d36e2fa0 authored by Jean-Francois Dagenais's avatar Jean-Francois Dagenais Committed by Eduardo Valentin

thermal: generic-adc: make lookup table optional

Certain ADC channels, such as the xilinx-ams temperature channels, give
milliCelcius already when read with iio_read_channel_processed.

Rather than having to provide a 1:1 dummy lookup table, simply allow to
bypass the mechanism.
Signed-off-by: default avatarJean-Francois Dagenais <jeff.dagenais@gmail.com>
Signed-off-by: default avatarEduardo Valentin <edubezval@gmail.com>
parent f86a7a84
...@@ -29,6 +29,9 @@ static int gadc_thermal_adc_to_temp(struct gadc_thermal_info *gti, int val) ...@@ -29,6 +29,9 @@ static int gadc_thermal_adc_to_temp(struct gadc_thermal_info *gti, int val)
int temp, temp_hi, temp_lo, adc_hi, adc_lo; int temp, temp_hi, temp_lo, adc_hi, adc_lo;
int i; int i;
if (!gti->lookup_table)
return val;
for (i = 0; i < gti->nlookup_table; i++) { for (i = 0; i < gti->nlookup_table; i++) {
if (val >= gti->lookup_table[2 * i + 1]) if (val >= gti->lookup_table[2 * i + 1])
break; break;
...@@ -81,9 +84,9 @@ static int gadc_thermal_read_linear_lookup_table(struct device *dev, ...@@ -81,9 +84,9 @@ static int gadc_thermal_read_linear_lookup_table(struct device *dev,
ntable = of_property_count_elems_of_size(np, "temperature-lookup-table", ntable = of_property_count_elems_of_size(np, "temperature-lookup-table",
sizeof(u32)); sizeof(u32));
if (ntable < 0) { if (ntable <= 0) {
dev_err(dev, "Lookup table is not provided\n"); dev_notice(dev, "no lookup table, assuming DAC channel returns milliCelcius\n");
return ntable; return 0;
} }
if (ntable % 2) { if (ntable % 2) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment