All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] thermal: generic-adc: make lookup table optional
@ 2019-04-18 16:37 Jean-Francois Dagenais
  2019-04-18 16:37 ` [PATCH 2/2] dt-bindings: thermal: generic-adc: make lookup-table optional Jean-Francois Dagenais
  0 siblings, 1 reply; 3+ messages in thread
From: Jean-Francois Dagenais @ 2019-04-18 16:37 UTC (permalink / raw)
  To: linux-pm; +Cc: daniel.lezcano, edubezval, rui.zhang, Jean-Francois Dagenais

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: Jean-Francois Dagenais <jeff.dagenais@gmail.com>
---
 drivers/thermal/thermal-generic-adc.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/thermal/thermal-generic-adc.c b/drivers/thermal/thermal-generic-adc.c
index e22fc60ad36d..deb244f12de4 100644
--- a/drivers/thermal/thermal-generic-adc.c
+++ b/drivers/thermal/thermal-generic-adc.c
@@ -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 i;
 
+	if (!gti->lookup_table)
+		return val;
+
 	for (i = 0; i < gti->nlookup_table; i++) {
 		if (val >= gti->lookup_table[2 * i + 1])
 			break;
@@ -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",
 						 sizeof(u32));
-	if (ntable < 0) {
-		dev_err(dev, "Lookup table is not provided\n");
-		return ntable;
+	if (ntable <= 0) {
+		dev_notice(dev, "no lookup table, assuming DAC channel returns milliCelcius\n");
+		return 0;
 	}
 
 	if (ntable % 2) {
-- 
2.11.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH 2/2] dt-bindings: thermal: generic-adc: make lookup-table optional
  2019-04-18 16:37 [PATCH 1/2] thermal: generic-adc: make lookup table optional Jean-Francois Dagenais
@ 2019-04-18 16:37 ` Jean-Francois Dagenais
  2019-05-11 18:56   ` Eduardo Valentin
  0 siblings, 1 reply; 3+ messages in thread
From: Jean-Francois Dagenais @ 2019-04-18 16:37 UTC (permalink / raw)
  To: linux-pm; +Cc: daniel.lezcano, edubezval, rui.zhang, Jean-Francois Dagenais

Signed-off-by: Jean-Francois Dagenais <jeff.dagenais@gmail.com>
---
 .../devicetree/bindings/thermal/thermal-generic-adc.txt        | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/Documentation/devicetree/bindings/thermal/thermal-generic-adc.txt b/Documentation/devicetree/bindings/thermal/thermal-generic-adc.txt
index d72355502b78..691a09db2fef 100644
--- a/Documentation/devicetree/bindings/thermal/thermal-generic-adc.txt
+++ b/Documentation/devicetree/bindings/thermal/thermal-generic-adc.txt
@@ -8,16 +8,22 @@ temperature using voltage-temperature lookup table.
 Required properties:
 ===================
 - compatible:		     Must be "generic-adc-thermal".
+- #thermal-sensor-cells:     Should be 1. See ./thermal.txt for a description
+		             of this property.
+Optional properties:
+===================
 - temperature-lookup-table:  Two dimensional array of Integer; lookup table
 			     to map the relation between ADC value and
 			     temperature. When ADC is read, the value is
 			     looked up on the table to get the equivalent
 			     temperature.
+
 			     The first value of the each row of array is the
 			     temperature in milliCelsius and second value of
 			     the each row of array is the ADC read value.
-- #thermal-sensor-cells:     Should be 1. See ./thermal.txt for a description
-			     of this property.
+
+			     If not specified, driver assumes the ADC channel
+			     gives milliCelsius directly.
 
 Example :
 #include <dt-bindings/thermal/thermal.h>
-- 
2.11.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH 2/2] dt-bindings: thermal: generic-adc: make lookup-table optional
  2019-04-18 16:37 ` [PATCH 2/2] dt-bindings: thermal: generic-adc: make lookup-table optional Jean-Francois Dagenais
@ 2019-05-11 18:56   ` Eduardo Valentin
  0 siblings, 0 replies; 3+ messages in thread
From: Eduardo Valentin @ 2019-05-11 18:56 UTC (permalink / raw)
  To: Jean-Francois Dagenais; +Cc: linux-pm, daniel.lezcano, rui.zhang

Hello,

On Thu, Apr 18, 2019 at 12:37:33PM -0400, Jean-Francois Dagenais wrote:

I added a description to this patch, but next time, on your next
patches, describe your change. Description is not an optional field
of a commit, it is very mandatory!


BR,

> Signed-off-by: Jean-Francois Dagenais <jeff.dagenais@gmail.com>
> ---
>  .../devicetree/bindings/thermal/thermal-generic-adc.txt        | 10 ++++++++--
>  1 file changed, 8 insertions(+), 2 deletions(-)
> 
> diff --git a/Documentation/devicetree/bindings/thermal/thermal-generic-adc.txt b/Documentation/devicetree/bindings/thermal/thermal-generic-adc.txt
> index d72355502b78..691a09db2fef 100644
> --- a/Documentation/devicetree/bindings/thermal/thermal-generic-adc.txt
> +++ b/Documentation/devicetree/bindings/thermal/thermal-generic-adc.txt
> @@ -8,16 +8,22 @@ temperature using voltage-temperature lookup table.
>  Required properties:
>  ===================
>  - compatible:		     Must be "generic-adc-thermal".
> +- #thermal-sensor-cells:     Should be 1. See ./thermal.txt for a description
> +		             of this property.
> +Optional properties:
> +===================
>  - temperature-lookup-table:  Two dimensional array of Integer; lookup table
>  			     to map the relation between ADC value and
>  			     temperature. When ADC is read, the value is
>  			     looked up on the table to get the equivalent
>  			     temperature.
> +
>  			     The first value of the each row of array is the
>  			     temperature in milliCelsius and second value of
>  			     the each row of array is the ADC read value.
> -- #thermal-sensor-cells:     Should be 1. See ./thermal.txt for a description
> -			     of this property.
> +
> +			     If not specified, driver assumes the ADC channel
> +			     gives milliCelsius directly.
>  
>  Example :
>  #include <dt-bindings/thermal/thermal.h>

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-05-11 18:56 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-18 16:37 [PATCH 1/2] thermal: generic-adc: make lookup table optional Jean-Francois Dagenais
2019-04-18 16:37 ` [PATCH 2/2] dt-bindings: thermal: generic-adc: make lookup-table optional Jean-Francois Dagenais
2019-05-11 18:56   ` Eduardo Valentin

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.