linux-hwmon.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] dt-bindings: hwmon: add B57891S0103 thermistor from Epcos
@ 2018-11-17 12:12 Peter Rosin
  2018-11-17 12:13 ` [PATCH 2/2] hwmon: (ntc_thermistor): add support for B57891S0103 " Peter Rosin
  2018-12-01 18:37 ` [PATCH 1/2] dt-bindings: hwmon: add B57891S0103 thermistor " Guenter Roeck
  0 siblings, 2 replies; 14+ messages in thread
From: Peter Rosin @ 2018-11-17 12:12 UTC (permalink / raw)
  To: linux-kernel
  Cc: Peter Rosin, Jean Delvare, Guenter Roeck, Rob Herring,
	Mark Rutland, linux-hwmon, devicetree

These are Negative Temperature Coefficient thermistors, like the others
in the list.

Signed-off-by: Peter Rosin <peda@axentia.se>
---
 Documentation/devicetree/bindings/hwmon/ntc_thermistor.txt | 1 +
 1 file changed, 1 insertion(+)

diff --git a/Documentation/devicetree/bindings/hwmon/ntc_thermistor.txt b/Documentation/devicetree/bindings/hwmon/ntc_thermistor.txt
index c3b9c4cfe8df..37f18d684f6a 100644
--- a/Documentation/devicetree/bindings/hwmon/ntc_thermistor.txt
+++ b/Documentation/devicetree/bindings/hwmon/ntc_thermistor.txt
@@ -4,6 +4,7 @@ NTC Thermistor hwmon sensors
 Requires node properties:
 - "compatible" value : one of
 	"epcos,b57330v2103"
+	"epcos,b57891s0103"
 	"murata,ncp15wb473"
 	"murata,ncp18wb473"
 	"murata,ncp21wb473"
-- 
2.11.0

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

* [PATCH 2/2] hwmon: (ntc_thermistor): add support for B57891S0103 from Epcos
  2018-11-17 12:12 [PATCH 1/2] dt-bindings: hwmon: add B57891S0103 thermistor from Epcos Peter Rosin
@ 2018-11-17 12:13 ` Peter Rosin
  2018-11-19 17:07   ` Guenter Roeck
  2018-12-01 18:38   ` [PATCH 2/2] hwmon: (ntc_thermistor): add support for B57891S0103 from Epcos Guenter Roeck
  2018-12-01 18:37 ` [PATCH 1/2] dt-bindings: hwmon: add B57891S0103 thermistor " Guenter Roeck
  1 sibling, 2 replies; 14+ messages in thread
From: Peter Rosin @ 2018-11-17 12:13 UTC (permalink / raw)
  To: linux-kernel
  Cc: Peter Rosin, Jean Delvare, Guenter Roeck, Rob Herring,
	Mark Rutland, linux-hwmon, devicetree

More of the same...

Signed-off-by: Peter Rosin <peda@axentia.se>
---
 drivers/hwmon/Kconfig                        |  3 +-
 drivers/hwmon/ntc_thermistor.c               | 57 +++++++++++++++++++++++++++-
 include/linux/platform_data/ntc_thermistor.h |  1 +
 3 files changed, 58 insertions(+), 3 deletions(-)

diff --git a/drivers/hwmon/Kconfig b/drivers/hwmon/Kconfig
index f10840ad465c..5438cecace22 100644
--- a/drivers/hwmon/Kconfig
+++ b/drivers/hwmon/Kconfig
@@ -1206,7 +1206,8 @@ config SENSORS_NTC_THERMISTOR
 
 	  Currently, this driver supports
 	  NCP15WB473, NCP18WB473, NCP21WB473, NCP03WB473, NCP15WL333,
-	  NCP03WF104 and NCP15XH103 from Murata and B57330V2103 from EPCOS.
+	  NCP03WF104 and NCP15XH103 from Murata and B57330V2103 and
+	  B57891S0103 from EPCOS.
 
 	  This driver can also be built as a module.  If so, the module
 	  will be called ntc-thermistor.
diff --git a/drivers/hwmon/ntc_thermistor.c b/drivers/hwmon/ntc_thermistor.c
index c52d07c6b49f..e0c6b2f244a6 100644
--- a/drivers/hwmon/ntc_thermistor.c
+++ b/drivers/hwmon/ntc_thermistor.c
@@ -55,6 +55,7 @@ static const struct platform_device_id ntc_thermistor_id[] = {
 	{ "b57330v2103", TYPE_B57330V2103},
 	{ "ncp03wf104", TYPE_NCPXXWF104 },
 	{ "ncp15xh103", TYPE_NCPXXXH103 },
+	{ "b57891s0103", TYPE_B57891S0103 },
 	{ },
 };
 
@@ -212,8 +213,8 @@ static const struct ntc_compensation ncpXXxh103[] = {
 };
 
 /*
- * The following compensation table is from the specification of EPCOS NTC
- * Thermistors Datasheet
+ * The following compensation tables are from the specifications in EPCOS NTC
+ * Thermistors Datasheets
  */
 static const struct ntc_compensation b57330v2103[] = {
 	{ .temp_c	= -40, .ohm	= 190030 },
@@ -252,6 +253,52 @@ static const struct ntc_compensation b57330v2103[] = {
 	{ .temp_c	= 125, .ohm	= 531 },
 };
 
+static const struct ntc_compensation b57891s0103[] = {
+	{ .temp_c	= -55.0, .ohm	= 878900 },
+	{ .temp_c	= -50.0, .ohm	= 617590 },
+	{ .temp_c	= -45.0, .ohm	= 439340 },
+	{ .temp_c	= -40.0, .ohm	= 316180 },
+	{ .temp_c	= -35.0, .ohm	= 230060 },
+	{ .temp_c	= -30.0, .ohm	= 169150 },
+	{ .temp_c	= -25.0, .ohm	= 125550 },
+	{ .temp_c	= -20.0, .ohm	= 94143 },
+	{ .temp_c	= -15.0, .ohm	= 71172 },
+	{ .temp_c	= -10.0, .ohm	= 54308 },
+	{ .temp_c	= -5.0, .ohm	= 41505 },
+	{ .temp_c	= 0.0, .ohm	= 32014 },
+	{ .temp_c	= 5.0, .ohm	= 25011 },
+	{ .temp_c	= 10.0, .ohm	= 19691 },
+	{ .temp_c	= 15.0, .ohm	= 15618 },
+	{ .temp_c	= 20.0, .ohm	= 12474 },
+	{ .temp_c	= 25.0, .ohm	= 10000 },
+	{ .temp_c	= 30.0, .ohm	= 8080 },
+	{ .temp_c	= 35.0, .ohm	= 6569 },
+	{ .temp_c	= 40.0, .ohm	= 5372 },
+	{ .temp_c	= 45.0, .ohm	= 4424 },
+	{ .temp_c	= 50.0, .ohm	= 3661 },
+	{ .temp_c	= 55.0, .ohm	= 3039 },
+	{ .temp_c	= 60.0, .ohm	= 2536 },
+	{ .temp_c	= 65.0, .ohm	= 2128 },
+	{ .temp_c	= 70.0, .ohm	= 1794 },
+	{ .temp_c	= 75.0, .ohm	= 1518 },
+	{ .temp_c	= 80.0, .ohm	= 1290 },
+	{ .temp_c	= 85.0, .ohm	= 1100 },
+	{ .temp_c	= 90.0, .ohm	= 942 },
+	{ .temp_c	= 95.0, .ohm	= 809 },
+	{ .temp_c	= 100.0, .ohm	= 697 },
+	{ .temp_c	= 105.0, .ohm	= 604 },
+	{ .temp_c	= 110.0, .ohm	= 525 },
+	{ .temp_c	= 115.0, .ohm	= 457 },
+	{ .temp_c	= 120.0, .ohm	= 400 },
+	{ .temp_c	= 125.0, .ohm	= 351 },
+	{ .temp_c	= 130.0, .ohm	= 308 },
+	{ .temp_c	= 135.0, .ohm	= 272 },
+	{ .temp_c	= 140.0, .ohm	= 240 },
+	{ .temp_c	= 145.0, .ohm	= 213 },
+	{ .temp_c	= 150.0, .ohm	= 189 },
+	{ .temp_c	= 155.0, .ohm	= 168 },
+};
+
 struct ntc_data {
 	struct ntc_thermistor_platform_data *pdata;
 	const struct ntc_compensation *comp;
@@ -296,6 +343,8 @@ static const struct of_device_id ntc_match[] = {
 		.data = &ntc_thermistor_id[6] },
 	{ .compatible = "murata,ncp15xh103",
 		.data = &ntc_thermistor_id[7] },
+	{ .compatible = "epcos,b57891s0103",
+		.data = &ntc_thermistor_id[8] },
 
 	/* Usage of vendor name "ntc" is deprecated */
 	{ .compatible = "ntc,ncp15wb473",
@@ -627,6 +676,10 @@ static int ntc_thermistor_probe(struct platform_device *pdev)
 		data->comp = ncpXXxh103;
 		data->n_comp = ARRAY_SIZE(ncpXXxh103);
 		break;
+	case TYPE_B57891S0103:
+		data->comp = b57891s0103;
+		data->n_comp = ARRAY_SIZE(b57891s0103);
+		break;
 	default:
 		dev_err(dev, "Unknown device type: %lu(%s)\n",
 				pdev_id->driver_data, pdev_id->name);
diff --git a/include/linux/platform_data/ntc_thermistor.h b/include/linux/platform_data/ntc_thermistor.h
index 698d0d59db76..231a27c302ec 100644
--- a/include/linux/platform_data/ntc_thermistor.h
+++ b/include/linux/platform_data/ntc_thermistor.h
@@ -29,6 +29,7 @@ enum ntc_thermistor_type {
 	TYPE_B57330V2103,
 	TYPE_NCPXXWF104,
 	TYPE_NCPXXXH103,
+	TYPE_B57891S0103,
 };
 
 struct ntc_thermistor_platform_data {
-- 
2.11.0

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

* Re: [PATCH 2/2] hwmon: (ntc_thermistor): add support for B57891S0103 from Epcos
  2018-11-17 12:13 ` [PATCH 2/2] hwmon: (ntc_thermistor): add support for B57891S0103 " Peter Rosin
@ 2018-11-19 17:07   ` Guenter Roeck
  2018-11-19 21:16     ` Peter Rosin
  2018-12-01 18:38   ` [PATCH 2/2] hwmon: (ntc_thermistor): add support for B57891S0103 from Epcos Guenter Roeck
  1 sibling, 1 reply; 14+ messages in thread
From: Guenter Roeck @ 2018-11-19 17:07 UTC (permalink / raw)
  To: Peter Rosin
  Cc: linux-kernel, Jean Delvare, Rob Herring, Mark Rutland,
	linux-hwmon, devicetree

On Sat, Nov 17, 2018 at 12:13:00PM +0000, Peter Rosin wrote:
> More of the same...
> 
> Signed-off-by: Peter Rosin <peda@axentia.se>
> ---
>  drivers/hwmon/Kconfig                        |  3 +-
>  drivers/hwmon/ntc_thermistor.c               | 57 +++++++++++++++++++++++++++-
>  include/linux/platform_data/ntc_thermistor.h |  1 +
>  3 files changed, 58 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/hwmon/Kconfig b/drivers/hwmon/Kconfig
> index f10840ad465c..5438cecace22 100644
> --- a/drivers/hwmon/Kconfig
> +++ b/drivers/hwmon/Kconfig
> @@ -1206,7 +1206,8 @@ config SENSORS_NTC_THERMISTOR
>  
>  	  Currently, this driver supports
>  	  NCP15WB473, NCP18WB473, NCP21WB473, NCP03WB473, NCP15WL333,
> -	  NCP03WF104 and NCP15XH103 from Murata and B57330V2103 from EPCOS.
> +	  NCP03WF104 and NCP15XH103 from Murata and B57330V2103 and
> +	  B57891S0103 from EPCOS.
>  
>  	  This driver can also be built as a module.  If so, the module
>  	  will be called ntc-thermistor.
> diff --git a/drivers/hwmon/ntc_thermistor.c b/drivers/hwmon/ntc_thermistor.c
> index c52d07c6b49f..e0c6b2f244a6 100644
> --- a/drivers/hwmon/ntc_thermistor.c
> +++ b/drivers/hwmon/ntc_thermistor.c
> @@ -55,6 +55,7 @@ static const struct platform_device_id ntc_thermistor_id[] = {
>  	{ "b57330v2103", TYPE_B57330V2103},
>  	{ "ncp03wf104", TYPE_NCPXXWF104 },
>  	{ "ncp15xh103", TYPE_NCPXXXH103 },
> +	{ "b57891s0103", TYPE_B57891S0103 },
>  	{ },
>  };
>  
> @@ -212,8 +213,8 @@ static const struct ntc_compensation ncpXXxh103[] = {
>  };
>  
>  /*
> - * The following compensation table is from the specification of EPCOS NTC
> - * Thermistors Datasheet
> + * The following compensation tables are from the specifications in EPCOS NTC
> + * Thermistors Datasheets
>   */
>  static const struct ntc_compensation b57330v2103[] = {
>  	{ .temp_c	= -40, .ohm	= 190030 },
> @@ -252,6 +253,52 @@ static const struct ntc_compensation b57330v2103[] = {
>  	{ .temp_c	= 125, .ohm	= 531 },
>  };
>  
> +static const struct ntc_compensation b57891s0103[] = {
> +	{ .temp_c	= -55.0, .ohm	= 878900 },
> +	{ .temp_c	= -50.0, .ohm	= 617590 },
> +	{ .temp_c	= -45.0, .ohm	= 439340 },
> +	{ .temp_c	= -40.0, .ohm	= 316180 },
> +	{ .temp_c	= -35.0, .ohm	= 230060 },
> +	{ .temp_c	= -30.0, .ohm	= 169150 },
> +	{ .temp_c	= -25.0, .ohm	= 125550 },
> +	{ .temp_c	= -20.0, .ohm	= 94143 },
> +	{ .temp_c	= -15.0, .ohm	= 71172 },
> +	{ .temp_c	= -10.0, .ohm	= 54308 },
> +	{ .temp_c	= -5.0, .ohm	= 41505 },
> +	{ .temp_c	= 0.0, .ohm	= 32014 },
> +	{ .temp_c	= 5.0, .ohm	= 25011 },
> +	{ .temp_c	= 10.0, .ohm	= 19691 },
> +	{ .temp_c	= 15.0, .ohm	= 15618 },
> +	{ .temp_c	= 20.0, .ohm	= 12474 },
> +	{ .temp_c	= 25.0, .ohm	= 10000 },
> +	{ .temp_c	= 30.0, .ohm	= 8080 },
> +	{ .temp_c	= 35.0, .ohm	= 6569 },
> +	{ .temp_c	= 40.0, .ohm	= 5372 },
> +	{ .temp_c	= 45.0, .ohm	= 4424 },
> +	{ .temp_c	= 50.0, .ohm	= 3661 },
> +	{ .temp_c	= 55.0, .ohm	= 3039 },
> +	{ .temp_c	= 60.0, .ohm	= 2536 },
> +	{ .temp_c	= 65.0, .ohm	= 2128 },
> +	{ .temp_c	= 70.0, .ohm	= 1794 },
> +	{ .temp_c	= 75.0, .ohm	= 1518 },
> +	{ .temp_c	= 80.0, .ohm	= 1290 },
> +	{ .temp_c	= 85.0, .ohm	= 1100 },
> +	{ .temp_c	= 90.0, .ohm	= 942 },
> +	{ .temp_c	= 95.0, .ohm	= 809 },
> +	{ .temp_c	= 100.0, .ohm	= 697 },
> +	{ .temp_c	= 105.0, .ohm	= 604 },
> +	{ .temp_c	= 110.0, .ohm	= 525 },
> +	{ .temp_c	= 115.0, .ohm	= 457 },
> +	{ .temp_c	= 120.0, .ohm	= 400 },
> +	{ .temp_c	= 125.0, .ohm	= 351 },
> +	{ .temp_c	= 130.0, .ohm	= 308 },
> +	{ .temp_c	= 135.0, .ohm	= 272 },
> +	{ .temp_c	= 140.0, .ohm	= 240 },
> +	{ .temp_c	= 145.0, .ohm	= 213 },
> +	{ .temp_c	= 150.0, .ohm	= 189 },
> +	{ .temp_c	= 155.0, .ohm	= 168 },
> +};
> +
>  struct ntc_data {
>  	struct ntc_thermistor_platform_data *pdata;
>  	const struct ntc_compensation *comp;
> @@ -296,6 +343,8 @@ static const struct of_device_id ntc_match[] = {
>  		.data = &ntc_thermistor_id[6] },
>  	{ .compatible = "murata,ncp15xh103",
>  		.data = &ntc_thermistor_id[7] },
> +	{ .compatible = "epcos,b57891s0103",
> +		.data = &ntc_thermistor_id[8] },
>  
>  	/* Usage of vendor name "ntc" is deprecated */
>  	{ .compatible = "ntc,ncp15wb473",
> @@ -627,6 +676,10 @@ static int ntc_thermistor_probe(struct platform_device *pdev)
>  		data->comp = ncpXXxh103;
>  		data->n_comp = ARRAY_SIZE(ncpXXxh103);
>  		break;
> +	case TYPE_B57891S0103:
> +		data->comp = b57891s0103;
> +		data->n_comp = ARRAY_SIZE(b57891s0103);
> +		break;
>  	default:
>  		dev_err(dev, "Unknown device type: %lu(%s)\n",
>  				pdev_id->driver_data, pdev_id->name);
> diff --git a/include/linux/platform_data/ntc_thermistor.h b/include/linux/platform_data/ntc_thermistor.h
> index 698d0d59db76..231a27c302ec 100644
> --- a/include/linux/platform_data/ntc_thermistor.h
> +++ b/include/linux/platform_data/ntc_thermistor.h
> @@ -29,6 +29,7 @@ enum ntc_thermistor_type {
>  	TYPE_B57330V2103,
>  	TYPE_NCPXXWF104,
>  	TYPE_NCPXXXH103,
> +	TYPE_B57891S0103,

Guess I deserve the non-alphabetic order as penalty for not enforcing it 
earlier. I'll accept the patch after DT approval and submit another one
myself afterwards to restore alphabetic order.

Guenter

>  };
>  
>  struct ntc_thermistor_platform_data {
> -- 
> 2.11.0
> 

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

* Re: [PATCH 2/2] hwmon: (ntc_thermistor): add support for B57891S0103 from Epcos
  2018-11-19 17:07   ` Guenter Roeck
@ 2018-11-19 21:16     ` Peter Rosin
  2018-11-19 21:28       ` Guenter Roeck
  0 siblings, 1 reply; 14+ messages in thread
From: Peter Rosin @ 2018-11-19 21:16 UTC (permalink / raw)
  To: Guenter Roeck
  Cc: linux-kernel, Jean Delvare, Rob Herring, Mark Rutland,
	linux-hwmon, devicetree

On 2018-11-19 18:07, Guenter Roeck wrote:
> On Sat, Nov 17, 2018 at 12:13:00PM +0000, Peter Rosin wrote:
>> More of the same...
>>
>> Signed-off-by: Peter Rosin <peda@axentia.se>
>> ---
>>  drivers/hwmon/Kconfig                        |  3 +-
>>  drivers/hwmon/ntc_thermistor.c               | 57 +++++++++++++++++++++++++++-
>>  include/linux/platform_data/ntc_thermistor.h |  1 +
>>  3 files changed, 58 insertions(+), 3 deletions(-)
>>
>> diff --git a/drivers/hwmon/Kconfig b/drivers/hwmon/Kconfig
>> index f10840ad465c..5438cecace22 100644
>> --- a/drivers/hwmon/Kconfig
>> +++ b/drivers/hwmon/Kconfig
>> @@ -1206,7 +1206,8 @@ config SENSORS_NTC_THERMISTOR
>>  
>>  	  Currently, this driver supports
>>  	  NCP15WB473, NCP18WB473, NCP21WB473, NCP03WB473, NCP15WL333,
>> -	  NCP03WF104 and NCP15XH103 from Murata and B57330V2103 from EPCOS.
>> +	  NCP03WF104 and NCP15XH103 from Murata and B57330V2103 and
>> +	  B57891S0103 from EPCOS.
>>  
>>  	  This driver can also be built as a module.  If so, the module
>>  	  will be called ntc-thermistor.
>> diff --git a/drivers/hwmon/ntc_thermistor.c b/drivers/hwmon/ntc_thermistor.c
>> index c52d07c6b49f..e0c6b2f244a6 100644
>> --- a/drivers/hwmon/ntc_thermistor.c
>> +++ b/drivers/hwmon/ntc_thermistor.c
>> @@ -55,6 +55,7 @@ static const struct platform_device_id ntc_thermistor_id[] = {
>>  	{ "b57330v2103", TYPE_B57330V2103},
>>  	{ "ncp03wf104", TYPE_NCPXXWF104 },
>>  	{ "ncp15xh103", TYPE_NCPXXXH103 },
>> +	{ "b57891s0103", TYPE_B57891S0103 },
>>  	{ },
>>  };
>>  
>> @@ -212,8 +213,8 @@ static const struct ntc_compensation ncpXXxh103[] = {
>>  };
>>  
>>  /*
>> - * The following compensation table is from the specification of EPCOS NTC
>> - * Thermistors Datasheet
>> + * The following compensation tables are from the specifications in EPCOS NTC
>> + * Thermistors Datasheets
>>   */
>>  static const struct ntc_compensation b57330v2103[] = {
>>  	{ .temp_c	= -40, .ohm	= 190030 },
>> @@ -252,6 +253,52 @@ static const struct ntc_compensation b57330v2103[] = {
>>  	{ .temp_c	= 125, .ohm	= 531 },
>>  };
>>  
>> +static const struct ntc_compensation b57891s0103[] = {
>> +	{ .temp_c	= -55.0, .ohm	= 878900 },
>> +	{ .temp_c	= -50.0, .ohm	= 617590 },
>> +	{ .temp_c	= -45.0, .ohm	= 439340 },
>> +	{ .temp_c	= -40.0, .ohm	= 316180 },
>> +	{ .temp_c	= -35.0, .ohm	= 230060 },
>> +	{ .temp_c	= -30.0, .ohm	= 169150 },
>> +	{ .temp_c	= -25.0, .ohm	= 125550 },
>> +	{ .temp_c	= -20.0, .ohm	= 94143 },
>> +	{ .temp_c	= -15.0, .ohm	= 71172 },
>> +	{ .temp_c	= -10.0, .ohm	= 54308 },
>> +	{ .temp_c	= -5.0, .ohm	= 41505 },
>> +	{ .temp_c	= 0.0, .ohm	= 32014 },
>> +	{ .temp_c	= 5.0, .ohm	= 25011 },
>> +	{ .temp_c	= 10.0, .ohm	= 19691 },
>> +	{ .temp_c	= 15.0, .ohm	= 15618 },
>> +	{ .temp_c	= 20.0, .ohm	= 12474 },
>> +	{ .temp_c	= 25.0, .ohm	= 10000 },
>> +	{ .temp_c	= 30.0, .ohm	= 8080 },
>> +	{ .temp_c	= 35.0, .ohm	= 6569 },
>> +	{ .temp_c	= 40.0, .ohm	= 5372 },
>> +	{ .temp_c	= 45.0, .ohm	= 4424 },
>> +	{ .temp_c	= 50.0, .ohm	= 3661 },
>> +	{ .temp_c	= 55.0, .ohm	= 3039 },
>> +	{ .temp_c	= 60.0, .ohm	= 2536 },
>> +	{ .temp_c	= 65.0, .ohm	= 2128 },
>> +	{ .temp_c	= 70.0, .ohm	= 1794 },
>> +	{ .temp_c	= 75.0, .ohm	= 1518 },
>> +	{ .temp_c	= 80.0, .ohm	= 1290 },
>> +	{ .temp_c	= 85.0, .ohm	= 1100 },
>> +	{ .temp_c	= 90.0, .ohm	= 942 },
>> +	{ .temp_c	= 95.0, .ohm	= 809 },
>> +	{ .temp_c	= 100.0, .ohm	= 697 },
>> +	{ .temp_c	= 105.0, .ohm	= 604 },
>> +	{ .temp_c	= 110.0, .ohm	= 525 },
>> +	{ .temp_c	= 115.0, .ohm	= 457 },
>> +	{ .temp_c	= 120.0, .ohm	= 400 },
>> +	{ .temp_c	= 125.0, .ohm	= 351 },
>> +	{ .temp_c	= 130.0, .ohm	= 308 },
>> +	{ .temp_c	= 135.0, .ohm	= 272 },
>> +	{ .temp_c	= 140.0, .ohm	= 240 },
>> +	{ .temp_c	= 145.0, .ohm	= 213 },
>> +	{ .temp_c	= 150.0, .ohm	= 189 },
>> +	{ .temp_c	= 155.0, .ohm	= 168 },
>> +};
>> +
>>  struct ntc_data {
>>  	struct ntc_thermistor_platform_data *pdata;
>>  	const struct ntc_compensation *comp;
>> @@ -296,6 +343,8 @@ static const struct of_device_id ntc_match[] = {
>>  		.data = &ntc_thermistor_id[6] },
>>  	{ .compatible = "murata,ncp15xh103",
>>  		.data = &ntc_thermistor_id[7] },
>> +	{ .compatible = "epcos,b57891s0103",
>> +		.data = &ntc_thermistor_id[8] },
>>  
>>  	/* Usage of vendor name "ntc" is deprecated */
>>  	{ .compatible = "ntc,ncp15wb473",
>> @@ -627,6 +676,10 @@ static int ntc_thermistor_probe(struct platform_device *pdev)
>>  		data->comp = ncpXXxh103;
>>  		data->n_comp = ARRAY_SIZE(ncpXXxh103);
>>  		break;
>> +	case TYPE_B57891S0103:
>> +		data->comp = b57891s0103;
>> +		data->n_comp = ARRAY_SIZE(b57891s0103);
>> +		break;
>>  	default:
>>  		dev_err(dev, "Unknown device type: %lu(%s)\n",
>>  				pdev_id->driver_data, pdev_id->name);
>> diff --git a/include/linux/platform_data/ntc_thermistor.h b/include/linux/platform_data/ntc_thermistor.h
>> index 698d0d59db76..231a27c302ec 100644
>> --- a/include/linux/platform_data/ntc_thermistor.h
>> +++ b/include/linux/platform_data/ntc_thermistor.h
>> @@ -29,6 +29,7 @@ enum ntc_thermistor_type {
>>  	TYPE_B57330V2103,
>>  	TYPE_NCPXXWF104,
>>  	TYPE_NCPXXXH103,
>> +	TYPE_B57891S0103,
> 
> Guess I deserve the non-alphabetic order as penalty for not enforcing it 
> earlier. I'll accept the patch after DT approval and submit another one
> myself afterwards to restore alphabetic order.

Right, I'm thinking another good change would be to introduce an enum
into the ntc_thermistor_id array, because the hard-coded numbering in
the ntc_match variable is a bit fragile in my taste, and that list would
also benefit from being alphabetic. Currently there's simply no way to
add things in the middle without causing mayhem. I thought about doing
that, but didn't want to waste energy doing it up front without knowing
if it would be well received (the driver might have been superseded or
something). I'm glad that you have volunteered to clean things up.
Ha! :-)

Cheers,
Peter

> Guenter
> 
>>  };
>>  
>>  struct ntc_thermistor_platform_data {
>> -- 
>> 2.11.0
>>


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

* Re: [PATCH 2/2] hwmon: (ntc_thermistor): add support for B57891S0103 from Epcos
  2018-11-19 21:16     ` Peter Rosin
@ 2018-11-19 21:28       ` Guenter Roeck
  2018-11-21  6:06         ` Peter Rosin
  0 siblings, 1 reply; 14+ messages in thread
From: Guenter Roeck @ 2018-11-19 21:28 UTC (permalink / raw)
  To: Peter Rosin
  Cc: linux-kernel, Jean Delvare, Rob Herring, Mark Rutland,
	linux-hwmon, devicetree

On Mon, Nov 19, 2018 at 09:16:12PM +0000, Peter Rosin wrote:
> > 
> > Guess I deserve the non-alphabetic order as penalty for not enforcing it 
> > earlier. I'll accept the patch after DT approval and submit another one
> > myself afterwards to restore alphabetic order.
> 
> Right, I'm thinking another good change would be to introduce an enum
> into the ntc_thermistor_id array, because the hard-coded numbering in

Yes, sounds like a good idea.

> the ntc_match variable is a bit fragile in my taste, and that list would
> also benefit from being alphabetic. Currently there's simply no way to
> add things in the middle without causing mayhem. I thought about doing
> that, but didn't want to waste energy doing it up front without knowing
> if it would be well received (the driver might have been superseded or

It would.

Guenter

> something). I'm glad that you have volunteered to clean things up.
> Ha! :-)
> 
> Cheers,
> Peter
> 
> > Guenter
> > 
> >>  };
> >>  
> >>  struct ntc_thermistor_platform_data {
> >> -- 
> >> 2.11.0
> >>
> 

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

* Re: [PATCH 2/2] hwmon: (ntc_thermistor): add support for B57891S0103 from Epcos
  2018-11-19 21:28       ` Guenter Roeck
@ 2018-11-21  6:06         ` Peter Rosin
  2018-11-21  8:42           ` Guenter Roeck
  0 siblings, 1 reply; 14+ messages in thread
From: Peter Rosin @ 2018-11-21  6:06 UTC (permalink / raw)
  To: Guenter Roeck
  Cc: linux-kernel, Jean Delvare, Rob Herring, Mark Rutland,
	linux-hwmon, devicetree

On 2018-11-19 22:28, Guenter Roeck wrote:
> On Mon, Nov 19, 2018 at 09:16:12PM +0000, Peter Rosin wrote:
>>>
>>> Guess I deserve the non-alphabetic order as penalty for not enforcing it 
>>> earlier. I'll accept the patch after DT approval and submit another one
>>> myself afterwards to restore alphabetic order.
>>
>> Right, I'm thinking another good change would be to introduce an enum
>> into the ntc_thermistor_id array, because the hard-coded numbering in
> 
> Yes, sounds like a good idea.
> 
>> the ntc_match variable is a bit fragile in my taste, and that list would
>> also benefit from being alphabetic. Currently there's simply no way to
>> add things in the middle without causing mayhem. I thought about doing
>> that, but didn't want to waste energy doing it up front without knowing
>> if it would be well received (the driver might have been superseded or
> 
> It would.

Right, so I have some patches sorting things out... However, one question
before I send them: Is it ok to sort the enum ntc_thermistor_type in the
include/linux/platform_data/ntc_thermistor.h header or will that break
stuff?

Cheers,
Peter

> Guenter
> 
>> something). I'm glad that you have volunteered to clean things up.
>> Ha! :-)
>>
>> Cheers,
>> Peter
>>
>>> Guenter
>>>
>>>>  };
>>>>  
>>>>  struct ntc_thermistor_platform_data {
>>>> -- 
>>>> 2.11.0
>>>>
>>


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

* Re: [PATCH 2/2] hwmon: (ntc_thermistor): add support for B57891S0103 from Epcos
  2018-11-21  6:06         ` Peter Rosin
@ 2018-11-21  8:42           ` Guenter Roeck
  2018-11-21 16:03             ` [PATCH 0/2] hwmon: (ntc_thermistor) sort thermistors Peter Rosin
  0 siblings, 1 reply; 14+ messages in thread
From: Guenter Roeck @ 2018-11-21  8:42 UTC (permalink / raw)
  To: Peter Rosin
  Cc: linux-kernel, Jean Delvare, Rob Herring, Mark Rutland,
	linux-hwmon, devicetree

On 11/20/18 10:06 PM, Peter Rosin wrote:
> On 2018-11-19 22:28, Guenter Roeck wrote:
>> On Mon, Nov 19, 2018 at 09:16:12PM +0000, Peter Rosin wrote:
>>>>
>>>> Guess I deserve the non-alphabetic order as penalty for not enforcing it
>>>> earlier. I'll accept the patch after DT approval and submit another one
>>>> myself afterwards to restore alphabetic order.
>>>
>>> Right, I'm thinking another good change would be to introduce an enum
>>> into the ntc_thermistor_id array, because the hard-coded numbering in
>>
>> Yes, sounds like a good idea.
>>
>>> the ntc_match variable is a bit fragile in my taste, and that list would
>>> also benefit from being alphabetic. Currently there's simply no way to
>>> add things in the middle without causing mayhem. I thought about doing
>>> that, but didn't want to waste energy doing it up front without knowing
>>> if it would be well received (the driver might have been superseded or
>>
>> It would.
> 
> Right, so I have some patches sorting things out... However, one question

Sounds good.

> before I send them: Is it ok to sort the enum ntc_thermistor_type in the
> include/linux/platform_data/ntc_thermistor.h header or will that break
> stuff?
> 

Should be ok. It is not an UAPI, after all.

Guenter

> Cheers,
> Peter
> 
>> Guenter
>>
>>> something). I'm glad that you have volunteered to clean things up.
>>> Ha! :-)
>>>
>>> Cheers,
>>> Peter
>>>
>>>> Guenter
>>>>
>>>>>   };
>>>>>   
>>>>>   struct ntc_thermistor_platform_data {
>>>>> -- 
>>>>> 2.11.0
>>>>>
>>>
> 

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

* [PATCH 0/2] hwmon: (ntc_thermistor) sort thermistors
  2018-11-21  8:42           ` Guenter Roeck
@ 2018-11-21 16:03             ` Peter Rosin
  2018-11-21 16:03               ` [PATCH 1/2] hwmon: (ntc_thermistor) sort thermistor id lists alphabetically Peter Rosin
  2018-11-21 16:03               ` [PATCH 2/2] hwmon: (ntc_thermistor) use a table to lookup the thermistor type Peter Rosin
  0 siblings, 2 replies; 14+ messages in thread
From: Peter Rosin @ 2018-11-21 16:03 UTC (permalink / raw)
  To: linux-kernel; +Cc: Peter Rosin, Jean Delvare, Guenter Roeck, linux-hwmon

Hi!

These patches are on top of https://patchwork.kernel.org/patch/10687455/
("hwmon: (ntc_thermistor): add support for B57891S0103 from Epcos")

I suspect the bots will be confused since that patch is not applied yet.

Also, patch 2 of this series has a false positive check-patch issue [1].
At least with my copy of check-patch. I suspect check-patch warns about
the macro in case it is ever used to something other than to initialize
an array, but I fail to see how that would be possible and am therefore
ignoring the issue.

Further, check-patch warns about patch 1 since I appear to add DT
compatibles that are not documented. But of course, I'm not adding them,
I'm just moving them about, so I'm ignoring that too.

Cheers,
Peter

[1] check-patch output is as below

CHECK: Macro argument reuse 'compensation' - possible side-effects?
#28: FILE: drivers/hwmon/ntc_thermistor.c:323:
+#define NTC_TYPE(ntc, compensation) \
+[(ntc)] = { .comp = (compensation), .n_comp = ARRAY_SIZE(compensation) }


Peter Rosin (2):
  hwmon: (ntc_thermistor) sort thermistor id lists alphabetically
  hwmon: (ntc_thermistor) use a table to lookup the thermistor type

 drivers/hwmon/ntc_thermistor.c               | 129 +++++++++++++++------------
 include/linux/platform_data/ntc_thermistor.h |   6 +-
 2 files changed, 73 insertions(+), 62 deletions(-)

-- 
2.11.0

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

* [PATCH 1/2] hwmon: (ntc_thermistor) sort thermistor id lists alphabetically
  2018-11-21 16:03             ` [PATCH 0/2] hwmon: (ntc_thermistor) sort thermistors Peter Rosin
@ 2018-11-21 16:03               ` Peter Rosin
  2018-12-01 18:39                 ` Guenter Roeck
  2018-11-21 16:03               ` [PATCH 2/2] hwmon: (ntc_thermistor) use a table to lookup the thermistor type Peter Rosin
  1 sibling, 1 reply; 14+ messages in thread
From: Peter Rosin @ 2018-11-21 16:03 UTC (permalink / raw)
  To: linux-kernel; +Cc: Peter Rosin, Jean Delvare, Guenter Roeck, linux-hwmon

Use an enum to index the array, so that it is possible to add sorted
entries without causing churn.

Signed-off-by: Peter Rosin <peda@axentia.se>
---
 drivers/hwmon/ntc_thermistor.c | 82 +++++++++++++++++++++++++-----------------
 1 file changed, 49 insertions(+), 33 deletions(-)

diff --git a/drivers/hwmon/ntc_thermistor.c b/drivers/hwmon/ntc_thermistor.c
index e0c6b2f244a6..7747c1ed1f02 100644
--- a/drivers/hwmon/ntc_thermistor.c
+++ b/drivers/hwmon/ntc_thermistor.c
@@ -45,18 +45,34 @@ struct ntc_compensation {
 	unsigned int	ohm;
 };
 
-/* Order matters, ntc_match references the entries by index */
+/*
+ * Used as index in a zero-terminated array, holes not allowed so
+ * that NTC_LAST is the first empty array entry.
+ */
+enum {
+	NTC_B57330V2103,
+	NTC_B57891S0103,
+	NTC_NCP03WB473,
+	NTC_NCP03WF104,
+	NTC_NCP15WB473,
+	NTC_NCP15WL333,
+	NTC_NCP15XH103,
+	NTC_NCP18WB473,
+	NTC_NCP21WB473,
+	NTC_LAST,
+};
+
 static const struct platform_device_id ntc_thermistor_id[] = {
-	{ "ncp15wb473", TYPE_NCPXXWB473 },
-	{ "ncp18wb473", TYPE_NCPXXWB473 },
-	{ "ncp21wb473", TYPE_NCPXXWB473 },
-	{ "ncp03wb473", TYPE_NCPXXWB473 },
-	{ "ncp15wl333", TYPE_NCPXXWL333 },
-	{ "b57330v2103", TYPE_B57330V2103},
-	{ "ncp03wf104", TYPE_NCPXXWF104 },
-	{ "ncp15xh103", TYPE_NCPXXXH103 },
-	{ "b57891s0103", TYPE_B57891S0103 },
-	{ },
+	[NTC_B57330V2103]     = { "b57330v2103",     TYPE_B57330V2103 },
+	[NTC_B57891S0103]     = { "b57891s0103",     TYPE_B57891S0103 },
+	[NTC_NCP03WB473]      = { "ncp03wb473",      TYPE_NCPXXWB473 },
+	[NTC_NCP03WF104]      = { "ncp03wf104",      TYPE_NCPXXWF104 },
+	[NTC_NCP15WB473]      = { "ncp15wb473",      TYPE_NCPXXWB473 },
+	[NTC_NCP15WL333]      = { "ncp15wl333",      TYPE_NCPXXWL333 },
+	[NTC_NCP15XH103]      = { "ncp15xh103",      TYPE_NCPXXXH103 },
+	[NTC_NCP18WB473]      = { "ncp18wb473",      TYPE_NCPXXWB473 },
+	[NTC_NCP21WB473]      = { "ncp21wb473",      TYPE_NCPXXWB473 },
+	[NTC_LAST]            = { },
 };
 
 /*
@@ -327,36 +343,36 @@ static int ntc_adc_iio_read(struct ntc_thermistor_platform_data *pdata)
 }
 
 static const struct of_device_id ntc_match[] = {
-	{ .compatible = "murata,ncp15wb473",
-		.data = &ntc_thermistor_id[0] },
-	{ .compatible = "murata,ncp18wb473",
-		.data = &ntc_thermistor_id[1] },
-	{ .compatible = "murata,ncp21wb473",
-		.data = &ntc_thermistor_id[2] },
-	{ .compatible = "murata,ncp03wb473",
-		.data = &ntc_thermistor_id[3] },
-	{ .compatible = "murata,ncp15wl333",
-		.data = &ntc_thermistor_id[4] },
 	{ .compatible = "epcos,b57330v2103",
-		.data = &ntc_thermistor_id[5]},
+		.data = &ntc_thermistor_id[NTC_B57330V2103]},
+	{ .compatible = "epcos,b57891s0103",
+		.data = &ntc_thermistor_id[NTC_B57891S0103] },
+	{ .compatible = "murata,ncp03wb473",
+		.data = &ntc_thermistor_id[NTC_NCP03WB473] },
 	{ .compatible = "murata,ncp03wf104",
-		.data = &ntc_thermistor_id[6] },
+		.data = &ntc_thermistor_id[NTC_NCP03WF104] },
+	{ .compatible = "murata,ncp15wb473",
+		.data = &ntc_thermistor_id[NTC_NCP15WB473] },
+	{ .compatible = "murata,ncp15wl333",
+		.data = &ntc_thermistor_id[NTC_NCP15WL333] },
 	{ .compatible = "murata,ncp15xh103",
-		.data = &ntc_thermistor_id[7] },
-	{ .compatible = "epcos,b57891s0103",
-		.data = &ntc_thermistor_id[8] },
+		.data = &ntc_thermistor_id[NTC_NCP15XH103] },
+	{ .compatible = "murata,ncp18wb473",
+		.data = &ntc_thermistor_id[NTC_NCP18WB473] },
+	{ .compatible = "murata,ncp21wb473",
+		.data = &ntc_thermistor_id[NTC_NCP21WB473] },
 
 	/* Usage of vendor name "ntc" is deprecated */
+	{ .compatible = "ntc,ncp03wb473",
+		.data = &ntc_thermistor_id[NTC_NCP03WB473] },
 	{ .compatible = "ntc,ncp15wb473",
-		.data = &ntc_thermistor_id[0] },
+		.data = &ntc_thermistor_id[NTC_NCP15WB473] },
+	{ .compatible = "ntc,ncp15wl333",
+		.data = &ntc_thermistor_id[NTC_NCP15WL333] },
 	{ .compatible = "ntc,ncp18wb473",
-		.data = &ntc_thermistor_id[1] },
+		.data = &ntc_thermistor_id[NTC_NCP18WB473] },
 	{ .compatible = "ntc,ncp21wb473",
-		.data = &ntc_thermistor_id[2] },
-	{ .compatible = "ntc,ncp03wb473",
-		.data = &ntc_thermistor_id[3] },
-	{ .compatible = "ntc,ncp15wl333",
-		.data = &ntc_thermistor_id[4] },
+		.data = &ntc_thermistor_id[NTC_NCP21WB473] },
 	{ },
 };
 MODULE_DEVICE_TABLE(of, ntc_match);
-- 
2.11.0

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

* [PATCH 2/2] hwmon: (ntc_thermistor) use a table to lookup the thermistor type
  2018-11-21 16:03             ` [PATCH 0/2] hwmon: (ntc_thermistor) sort thermistors Peter Rosin
  2018-11-21 16:03               ` [PATCH 1/2] hwmon: (ntc_thermistor) sort thermistor id lists alphabetically Peter Rosin
@ 2018-11-21 16:03               ` Peter Rosin
  2018-12-01 18:40                 ` Guenter Roeck
  1 sibling, 1 reply; 14+ messages in thread
From: Peter Rosin @ 2018-11-21 16:03 UTC (permalink / raw)
  To: linux-kernel; +Cc: Peter Rosin, Jean Delvare, Guenter Roeck, linux-hwmon

Sort the entries while at it.

Signed-off-by: Peter Rosin <peda@axentia.se>
---
 drivers/hwmon/ntc_thermistor.c               | 47 +++++++++++++---------------
 include/linux/platform_data/ntc_thermistor.h |  6 ++--
 2 files changed, 24 insertions(+), 29 deletions(-)

diff --git a/drivers/hwmon/ntc_thermistor.c b/drivers/hwmon/ntc_thermistor.c
index 7747c1ed1f02..56d83b2472c8 100644
--- a/drivers/hwmon/ntc_thermistor.c
+++ b/drivers/hwmon/ntc_thermistor.c
@@ -315,6 +315,23 @@ static const struct ntc_compensation b57891s0103[] = {
 	{ .temp_c	= 155.0, .ohm	= 168 },
 };
 
+struct ntc_type {
+	const struct ntc_compensation *comp;
+	int n_comp;
+};
+
+#define NTC_TYPE(ntc, compensation) \
+[(ntc)] = { .comp = (compensation), .n_comp = ARRAY_SIZE(compensation) }
+
+static const struct ntc_type ntc_type[] = {
+	NTC_TYPE(TYPE_B57330V2103, b57330v2103),
+	NTC_TYPE(TYPE_B57891S0103, b57891s0103),
+	NTC_TYPE(TYPE_NCPXXWB473,  ncpXXwb473),
+	NTC_TYPE(TYPE_NCPXXWF104,  ncpXXwf104),
+	NTC_TYPE(TYPE_NCPXXWL333,  ncpXXwl333),
+	NTC_TYPE(TYPE_NCPXXXH103,  ncpXXxh103),
+};
+
 struct ntc_data {
 	struct ntc_thermistor_platform_data *pdata;
 	const struct ntc_compensation *comp;
@@ -671,37 +688,15 @@ static int ntc_thermistor_probe(struct platform_device *pdev)
 
 	data->pdata = pdata;
 
-	switch (pdev_id->driver_data) {
-	case TYPE_NCPXXWB473:
-		data->comp = ncpXXwb473;
-		data->n_comp = ARRAY_SIZE(ncpXXwb473);
-		break;
-	case TYPE_NCPXXWL333:
-		data->comp = ncpXXwl333;
-		data->n_comp = ARRAY_SIZE(ncpXXwl333);
-		break;
-	case TYPE_B57330V2103:
-		data->comp = b57330v2103;
-		data->n_comp = ARRAY_SIZE(b57330v2103);
-		break;
-	case TYPE_NCPXXWF104:
-		data->comp = ncpXXwf104;
-		data->n_comp = ARRAY_SIZE(ncpXXwf104);
-		break;
-	case TYPE_NCPXXXH103:
-		data->comp = ncpXXxh103;
-		data->n_comp = ARRAY_SIZE(ncpXXxh103);
-		break;
-	case TYPE_B57891S0103:
-		data->comp = b57891s0103;
-		data->n_comp = ARRAY_SIZE(b57891s0103);
-		break;
-	default:
+	if (pdev_id->driver_data >= ARRAY_SIZE(ntc_type)) {
 		dev_err(dev, "Unknown device type: %lu(%s)\n",
 				pdev_id->driver_data, pdev_id->name);
 		return -EINVAL;
 	}
 
+	data->comp   = ntc_type[pdev_id->driver_data].comp;
+	data->n_comp = ntc_type[pdev_id->driver_data].n_comp;
+
 	hwmon_dev = devm_hwmon_device_register_with_groups(dev, pdev_id->name,
 							   data, ntc_groups);
 	if (IS_ERR(hwmon_dev)) {
diff --git a/include/linux/platform_data/ntc_thermistor.h b/include/linux/platform_data/ntc_thermistor.h
index 231a27c302ec..ee03d429742b 100644
--- a/include/linux/platform_data/ntc_thermistor.h
+++ b/include/linux/platform_data/ntc_thermistor.h
@@ -24,12 +24,12 @@
 struct iio_channel;
 
 enum ntc_thermistor_type {
-	TYPE_NCPXXWB473,
-	TYPE_NCPXXWL333,
 	TYPE_B57330V2103,
+	TYPE_B57891S0103,
+	TYPE_NCPXXWB473,
 	TYPE_NCPXXWF104,
+	TYPE_NCPXXWL333,
 	TYPE_NCPXXXH103,
-	TYPE_B57891S0103,
 };
 
 struct ntc_thermistor_platform_data {
-- 
2.11.0

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

* Re: [PATCH 1/2] dt-bindings: hwmon: add B57891S0103 thermistor from Epcos
  2018-11-17 12:12 [PATCH 1/2] dt-bindings: hwmon: add B57891S0103 thermistor from Epcos Peter Rosin
  2018-11-17 12:13 ` [PATCH 2/2] hwmon: (ntc_thermistor): add support for B57891S0103 " Peter Rosin
@ 2018-12-01 18:37 ` Guenter Roeck
  1 sibling, 0 replies; 14+ messages in thread
From: Guenter Roeck @ 2018-12-01 18:37 UTC (permalink / raw)
  To: Peter Rosin
  Cc: linux-kernel, Jean Delvare, Rob Herring, Mark Rutland,
	linux-hwmon, devicetree

On Sat, Nov 17, 2018 at 12:12:57PM +0000, Peter Rosin wrote:
> These are Negative Temperature Coefficient thermistors, like the others
> in the list.
> 
> Signed-off-by: Peter Rosin <peda@axentia.se>

Atrictly speaking that should get an Ack from a DT maintainer, but it
doesn't make sense to me to hold up the series for a one-line addition.

Applied to hwmon-next.

Thanks,
Guenter

> ---
>  Documentation/devicetree/bindings/hwmon/ntc_thermistor.txt | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/Documentation/devicetree/bindings/hwmon/ntc_thermistor.txt b/Documentation/devicetree/bindings/hwmon/ntc_thermistor.txt
> index c3b9c4cfe8df..37f18d684f6a 100644
> --- a/Documentation/devicetree/bindings/hwmon/ntc_thermistor.txt
> +++ b/Documentation/devicetree/bindings/hwmon/ntc_thermistor.txt
> @@ -4,6 +4,7 @@ NTC Thermistor hwmon sensors
>  Requires node properties:
>  - "compatible" value : one of
>  	"epcos,b57330v2103"
> +	"epcos,b57891s0103"
>  	"murata,ncp15wb473"
>  	"murata,ncp18wb473"
>  	"murata,ncp21wb473"

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

* Re: [PATCH 2/2] hwmon: (ntc_thermistor): add support for B57891S0103 from Epcos
  2018-11-17 12:13 ` [PATCH 2/2] hwmon: (ntc_thermistor): add support for B57891S0103 " Peter Rosin
  2018-11-19 17:07   ` Guenter Roeck
@ 2018-12-01 18:38   ` Guenter Roeck
  1 sibling, 0 replies; 14+ messages in thread
From: Guenter Roeck @ 2018-12-01 18:38 UTC (permalink / raw)
  To: Peter Rosin
  Cc: linux-kernel, Jean Delvare, Rob Herring, Mark Rutland,
	linux-hwmon, devicetree

On Sat, Nov 17, 2018 at 12:13:00PM +0000, Peter Rosin wrote:
> More of the same...
> 
> Signed-off-by: Peter Rosin <peda@axentia.se>

Applied to hwmon-next.

Thanks,
Guenter

> ---
>  drivers/hwmon/Kconfig                        |  3 +-
>  drivers/hwmon/ntc_thermistor.c               | 57 +++++++++++++++++++++++++++-
>  include/linux/platform_data/ntc_thermistor.h |  1 +
>  3 files changed, 58 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/hwmon/Kconfig b/drivers/hwmon/Kconfig
> index f10840ad465c..5438cecace22 100644
> --- a/drivers/hwmon/Kconfig
> +++ b/drivers/hwmon/Kconfig
> @@ -1206,7 +1206,8 @@ config SENSORS_NTC_THERMISTOR
>  
>  	  Currently, this driver supports
>  	  NCP15WB473, NCP18WB473, NCP21WB473, NCP03WB473, NCP15WL333,
> -	  NCP03WF104 and NCP15XH103 from Murata and B57330V2103 from EPCOS.
> +	  NCP03WF104 and NCP15XH103 from Murata and B57330V2103 and
> +	  B57891S0103 from EPCOS.
>  
>  	  This driver can also be built as a module.  If so, the module
>  	  will be called ntc-thermistor.
> diff --git a/drivers/hwmon/ntc_thermistor.c b/drivers/hwmon/ntc_thermistor.c
> index c52d07c6b49f..e0c6b2f244a6 100644
> --- a/drivers/hwmon/ntc_thermistor.c
> +++ b/drivers/hwmon/ntc_thermistor.c
> @@ -55,6 +55,7 @@ static const struct platform_device_id ntc_thermistor_id[] = {
>  	{ "b57330v2103", TYPE_B57330V2103},
>  	{ "ncp03wf104", TYPE_NCPXXWF104 },
>  	{ "ncp15xh103", TYPE_NCPXXXH103 },
> +	{ "b57891s0103", TYPE_B57891S0103 },
>  	{ },
>  };
>  
> @@ -212,8 +213,8 @@ static const struct ntc_compensation ncpXXxh103[] = {
>  };
>  
>  /*
> - * The following compensation table is from the specification of EPCOS NTC
> - * Thermistors Datasheet
> + * The following compensation tables are from the specifications in EPCOS NTC
> + * Thermistors Datasheets
>   */
>  static const struct ntc_compensation b57330v2103[] = {
>  	{ .temp_c	= -40, .ohm	= 190030 },
> @@ -252,6 +253,52 @@ static const struct ntc_compensation b57330v2103[] = {
>  	{ .temp_c	= 125, .ohm	= 531 },
>  };
>  
> +static const struct ntc_compensation b57891s0103[] = {
> +	{ .temp_c	= -55.0, .ohm	= 878900 },
> +	{ .temp_c	= -50.0, .ohm	= 617590 },
> +	{ .temp_c	= -45.0, .ohm	= 439340 },
> +	{ .temp_c	= -40.0, .ohm	= 316180 },
> +	{ .temp_c	= -35.0, .ohm	= 230060 },
> +	{ .temp_c	= -30.0, .ohm	= 169150 },
> +	{ .temp_c	= -25.0, .ohm	= 125550 },
> +	{ .temp_c	= -20.0, .ohm	= 94143 },
> +	{ .temp_c	= -15.0, .ohm	= 71172 },
> +	{ .temp_c	= -10.0, .ohm	= 54308 },
> +	{ .temp_c	= -5.0, .ohm	= 41505 },
> +	{ .temp_c	= 0.0, .ohm	= 32014 },
> +	{ .temp_c	= 5.0, .ohm	= 25011 },
> +	{ .temp_c	= 10.0, .ohm	= 19691 },
> +	{ .temp_c	= 15.0, .ohm	= 15618 },
> +	{ .temp_c	= 20.0, .ohm	= 12474 },
> +	{ .temp_c	= 25.0, .ohm	= 10000 },
> +	{ .temp_c	= 30.0, .ohm	= 8080 },
> +	{ .temp_c	= 35.0, .ohm	= 6569 },
> +	{ .temp_c	= 40.0, .ohm	= 5372 },
> +	{ .temp_c	= 45.0, .ohm	= 4424 },
> +	{ .temp_c	= 50.0, .ohm	= 3661 },
> +	{ .temp_c	= 55.0, .ohm	= 3039 },
> +	{ .temp_c	= 60.0, .ohm	= 2536 },
> +	{ .temp_c	= 65.0, .ohm	= 2128 },
> +	{ .temp_c	= 70.0, .ohm	= 1794 },
> +	{ .temp_c	= 75.0, .ohm	= 1518 },
> +	{ .temp_c	= 80.0, .ohm	= 1290 },
> +	{ .temp_c	= 85.0, .ohm	= 1100 },
> +	{ .temp_c	= 90.0, .ohm	= 942 },
> +	{ .temp_c	= 95.0, .ohm	= 809 },
> +	{ .temp_c	= 100.0, .ohm	= 697 },
> +	{ .temp_c	= 105.0, .ohm	= 604 },
> +	{ .temp_c	= 110.0, .ohm	= 525 },
> +	{ .temp_c	= 115.0, .ohm	= 457 },
> +	{ .temp_c	= 120.0, .ohm	= 400 },
> +	{ .temp_c	= 125.0, .ohm	= 351 },
> +	{ .temp_c	= 130.0, .ohm	= 308 },
> +	{ .temp_c	= 135.0, .ohm	= 272 },
> +	{ .temp_c	= 140.0, .ohm	= 240 },
> +	{ .temp_c	= 145.0, .ohm	= 213 },
> +	{ .temp_c	= 150.0, .ohm	= 189 },
> +	{ .temp_c	= 155.0, .ohm	= 168 },
> +};
> +
>  struct ntc_data {
>  	struct ntc_thermistor_platform_data *pdata;
>  	const struct ntc_compensation *comp;
> @@ -296,6 +343,8 @@ static const struct of_device_id ntc_match[] = {
>  		.data = &ntc_thermistor_id[6] },
>  	{ .compatible = "murata,ncp15xh103",
>  		.data = &ntc_thermistor_id[7] },
> +	{ .compatible = "epcos,b57891s0103",
> +		.data = &ntc_thermistor_id[8] },
>  
>  	/* Usage of vendor name "ntc" is deprecated */
>  	{ .compatible = "ntc,ncp15wb473",
> @@ -627,6 +676,10 @@ static int ntc_thermistor_probe(struct platform_device *pdev)
>  		data->comp = ncpXXxh103;
>  		data->n_comp = ARRAY_SIZE(ncpXXxh103);
>  		break;
> +	case TYPE_B57891S0103:
> +		data->comp = b57891s0103;
> +		data->n_comp = ARRAY_SIZE(b57891s0103);
> +		break;
>  	default:
>  		dev_err(dev, "Unknown device type: %lu(%s)\n",
>  				pdev_id->driver_data, pdev_id->name);
> diff --git a/include/linux/platform_data/ntc_thermistor.h b/include/linux/platform_data/ntc_thermistor.h
> index 698d0d59db76..231a27c302ec 100644
> --- a/include/linux/platform_data/ntc_thermistor.h
> +++ b/include/linux/platform_data/ntc_thermistor.h
> @@ -29,6 +29,7 @@ enum ntc_thermistor_type {
>  	TYPE_B57330V2103,
>  	TYPE_NCPXXWF104,
>  	TYPE_NCPXXXH103,
> +	TYPE_B57891S0103,
>  };
>  
>  struct ntc_thermistor_platform_data {

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

* Re: [PATCH 1/2] hwmon: (ntc_thermistor) sort thermistor id lists alphabetically
  2018-11-21 16:03               ` [PATCH 1/2] hwmon: (ntc_thermistor) sort thermistor id lists alphabetically Peter Rosin
@ 2018-12-01 18:39                 ` Guenter Roeck
  0 siblings, 0 replies; 14+ messages in thread
From: Guenter Roeck @ 2018-12-01 18:39 UTC (permalink / raw)
  To: Peter Rosin; +Cc: linux-kernel, Jean Delvare, linux-hwmon

On Wed, Nov 21, 2018 at 04:03:39PM +0000, Peter Rosin wrote:
> Use an enum to index the array, so that it is possible to add sorted
> entries without causing churn.
> 
> Signed-off-by: Peter Rosin <peda@axentia.se>

Applied to hwmon-next.

Thanks,
Guenter

> ---
>  drivers/hwmon/ntc_thermistor.c | 82 +++++++++++++++++++++++++-----------------
>  1 file changed, 49 insertions(+), 33 deletions(-)
> 
> diff --git a/drivers/hwmon/ntc_thermistor.c b/drivers/hwmon/ntc_thermistor.c
> index e0c6b2f244a6..7747c1ed1f02 100644
> --- a/drivers/hwmon/ntc_thermistor.c
> +++ b/drivers/hwmon/ntc_thermistor.c
> @@ -45,18 +45,34 @@ struct ntc_compensation {
>  	unsigned int	ohm;
>  };
>  
> -/* Order matters, ntc_match references the entries by index */
> +/*
> + * Used as index in a zero-terminated array, holes not allowed so
> + * that NTC_LAST is the first empty array entry.
> + */
> +enum {
> +	NTC_B57330V2103,
> +	NTC_B57891S0103,
> +	NTC_NCP03WB473,
> +	NTC_NCP03WF104,
> +	NTC_NCP15WB473,
> +	NTC_NCP15WL333,
> +	NTC_NCP15XH103,
> +	NTC_NCP18WB473,
> +	NTC_NCP21WB473,
> +	NTC_LAST,
> +};
> +
>  static const struct platform_device_id ntc_thermistor_id[] = {
> -	{ "ncp15wb473", TYPE_NCPXXWB473 },
> -	{ "ncp18wb473", TYPE_NCPXXWB473 },
> -	{ "ncp21wb473", TYPE_NCPXXWB473 },
> -	{ "ncp03wb473", TYPE_NCPXXWB473 },
> -	{ "ncp15wl333", TYPE_NCPXXWL333 },
> -	{ "b57330v2103", TYPE_B57330V2103},
> -	{ "ncp03wf104", TYPE_NCPXXWF104 },
> -	{ "ncp15xh103", TYPE_NCPXXXH103 },
> -	{ "b57891s0103", TYPE_B57891S0103 },
> -	{ },
> +	[NTC_B57330V2103]     = { "b57330v2103",     TYPE_B57330V2103 },
> +	[NTC_B57891S0103]     = { "b57891s0103",     TYPE_B57891S0103 },
> +	[NTC_NCP03WB473]      = { "ncp03wb473",      TYPE_NCPXXWB473 },
> +	[NTC_NCP03WF104]      = { "ncp03wf104",      TYPE_NCPXXWF104 },
> +	[NTC_NCP15WB473]      = { "ncp15wb473",      TYPE_NCPXXWB473 },
> +	[NTC_NCP15WL333]      = { "ncp15wl333",      TYPE_NCPXXWL333 },
> +	[NTC_NCP15XH103]      = { "ncp15xh103",      TYPE_NCPXXXH103 },
> +	[NTC_NCP18WB473]      = { "ncp18wb473",      TYPE_NCPXXWB473 },
> +	[NTC_NCP21WB473]      = { "ncp21wb473",      TYPE_NCPXXWB473 },
> +	[NTC_LAST]            = { },
>  };
>  
>  /*
> @@ -327,36 +343,36 @@ static int ntc_adc_iio_read(struct ntc_thermistor_platform_data *pdata)
>  }
>  
>  static const struct of_device_id ntc_match[] = {
> -	{ .compatible = "murata,ncp15wb473",
> -		.data = &ntc_thermistor_id[0] },
> -	{ .compatible = "murata,ncp18wb473",
> -		.data = &ntc_thermistor_id[1] },
> -	{ .compatible = "murata,ncp21wb473",
> -		.data = &ntc_thermistor_id[2] },
> -	{ .compatible = "murata,ncp03wb473",
> -		.data = &ntc_thermistor_id[3] },
> -	{ .compatible = "murata,ncp15wl333",
> -		.data = &ntc_thermistor_id[4] },
>  	{ .compatible = "epcos,b57330v2103",
> -		.data = &ntc_thermistor_id[5]},
> +		.data = &ntc_thermistor_id[NTC_B57330V2103]},
> +	{ .compatible = "epcos,b57891s0103",
> +		.data = &ntc_thermistor_id[NTC_B57891S0103] },
> +	{ .compatible = "murata,ncp03wb473",
> +		.data = &ntc_thermistor_id[NTC_NCP03WB473] },
>  	{ .compatible = "murata,ncp03wf104",
> -		.data = &ntc_thermistor_id[6] },
> +		.data = &ntc_thermistor_id[NTC_NCP03WF104] },
> +	{ .compatible = "murata,ncp15wb473",
> +		.data = &ntc_thermistor_id[NTC_NCP15WB473] },
> +	{ .compatible = "murata,ncp15wl333",
> +		.data = &ntc_thermistor_id[NTC_NCP15WL333] },
>  	{ .compatible = "murata,ncp15xh103",
> -		.data = &ntc_thermistor_id[7] },
> -	{ .compatible = "epcos,b57891s0103",
> -		.data = &ntc_thermistor_id[8] },
> +		.data = &ntc_thermistor_id[NTC_NCP15XH103] },
> +	{ .compatible = "murata,ncp18wb473",
> +		.data = &ntc_thermistor_id[NTC_NCP18WB473] },
> +	{ .compatible = "murata,ncp21wb473",
> +		.data = &ntc_thermistor_id[NTC_NCP21WB473] },
>  
>  	/* Usage of vendor name "ntc" is deprecated */
> +	{ .compatible = "ntc,ncp03wb473",
> +		.data = &ntc_thermistor_id[NTC_NCP03WB473] },
>  	{ .compatible = "ntc,ncp15wb473",
> -		.data = &ntc_thermistor_id[0] },
> +		.data = &ntc_thermistor_id[NTC_NCP15WB473] },
> +	{ .compatible = "ntc,ncp15wl333",
> +		.data = &ntc_thermistor_id[NTC_NCP15WL333] },
>  	{ .compatible = "ntc,ncp18wb473",
> -		.data = &ntc_thermistor_id[1] },
> +		.data = &ntc_thermistor_id[NTC_NCP18WB473] },
>  	{ .compatible = "ntc,ncp21wb473",
> -		.data = &ntc_thermistor_id[2] },
> -	{ .compatible = "ntc,ncp03wb473",
> -		.data = &ntc_thermistor_id[3] },
> -	{ .compatible = "ntc,ncp15wl333",
> -		.data = &ntc_thermistor_id[4] },
> +		.data = &ntc_thermistor_id[NTC_NCP21WB473] },
>  	{ },
>  };
>  MODULE_DEVICE_TABLE(of, ntc_match);

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

* Re: [PATCH 2/2] hwmon: (ntc_thermistor) use a table to lookup the thermistor type
  2018-11-21 16:03               ` [PATCH 2/2] hwmon: (ntc_thermistor) use a table to lookup the thermistor type Peter Rosin
@ 2018-12-01 18:40                 ` Guenter Roeck
  0 siblings, 0 replies; 14+ messages in thread
From: Guenter Roeck @ 2018-12-01 18:40 UTC (permalink / raw)
  To: Peter Rosin; +Cc: linux-kernel, Jean Delvare, linux-hwmon

On Wed, Nov 21, 2018 at 04:03:46PM +0000, Peter Rosin wrote:
> Sort the entries while at it.
> 
> Signed-off-by: Peter Rosin <peda@axentia.se>

Applied to hwmon-next.

Thanks,
Guenter

> ---
>  drivers/hwmon/ntc_thermistor.c               | 47 +++++++++++++---------------
>  include/linux/platform_data/ntc_thermistor.h |  6 ++--
>  2 files changed, 24 insertions(+), 29 deletions(-)
> 
> diff --git a/drivers/hwmon/ntc_thermistor.c b/drivers/hwmon/ntc_thermistor.c
> index 7747c1ed1f02..56d83b2472c8 100644
> --- a/drivers/hwmon/ntc_thermistor.c
> +++ b/drivers/hwmon/ntc_thermistor.c
> @@ -315,6 +315,23 @@ static const struct ntc_compensation b57891s0103[] = {
>  	{ .temp_c	= 155.0, .ohm	= 168 },
>  };
>  
> +struct ntc_type {
> +	const struct ntc_compensation *comp;
> +	int n_comp;
> +};
> +
> +#define NTC_TYPE(ntc, compensation) \
> +[(ntc)] = { .comp = (compensation), .n_comp = ARRAY_SIZE(compensation) }
> +
> +static const struct ntc_type ntc_type[] = {
> +	NTC_TYPE(TYPE_B57330V2103, b57330v2103),
> +	NTC_TYPE(TYPE_B57891S0103, b57891s0103),
> +	NTC_TYPE(TYPE_NCPXXWB473,  ncpXXwb473),
> +	NTC_TYPE(TYPE_NCPXXWF104,  ncpXXwf104),
> +	NTC_TYPE(TYPE_NCPXXWL333,  ncpXXwl333),
> +	NTC_TYPE(TYPE_NCPXXXH103,  ncpXXxh103),
> +};
> +
>  struct ntc_data {
>  	struct ntc_thermistor_platform_data *pdata;
>  	const struct ntc_compensation *comp;
> @@ -671,37 +688,15 @@ static int ntc_thermistor_probe(struct platform_device *pdev)
>  
>  	data->pdata = pdata;
>  
> -	switch (pdev_id->driver_data) {
> -	case TYPE_NCPXXWB473:
> -		data->comp = ncpXXwb473;
> -		data->n_comp = ARRAY_SIZE(ncpXXwb473);
> -		break;
> -	case TYPE_NCPXXWL333:
> -		data->comp = ncpXXwl333;
> -		data->n_comp = ARRAY_SIZE(ncpXXwl333);
> -		break;
> -	case TYPE_B57330V2103:
> -		data->comp = b57330v2103;
> -		data->n_comp = ARRAY_SIZE(b57330v2103);
> -		break;
> -	case TYPE_NCPXXWF104:
> -		data->comp = ncpXXwf104;
> -		data->n_comp = ARRAY_SIZE(ncpXXwf104);
> -		break;
> -	case TYPE_NCPXXXH103:
> -		data->comp = ncpXXxh103;
> -		data->n_comp = ARRAY_SIZE(ncpXXxh103);
> -		break;
> -	case TYPE_B57891S0103:
> -		data->comp = b57891s0103;
> -		data->n_comp = ARRAY_SIZE(b57891s0103);
> -		break;
> -	default:
> +	if (pdev_id->driver_data >= ARRAY_SIZE(ntc_type)) {
>  		dev_err(dev, "Unknown device type: %lu(%s)\n",
>  				pdev_id->driver_data, pdev_id->name);
>  		return -EINVAL;
>  	}
>  
> +	data->comp   = ntc_type[pdev_id->driver_data].comp;
> +	data->n_comp = ntc_type[pdev_id->driver_data].n_comp;
> +
>  	hwmon_dev = devm_hwmon_device_register_with_groups(dev, pdev_id->name,
>  							   data, ntc_groups);
>  	if (IS_ERR(hwmon_dev)) {
> diff --git a/include/linux/platform_data/ntc_thermistor.h b/include/linux/platform_data/ntc_thermistor.h
> index 231a27c302ec..ee03d429742b 100644
> --- a/include/linux/platform_data/ntc_thermistor.h
> +++ b/include/linux/platform_data/ntc_thermistor.h
> @@ -24,12 +24,12 @@
>  struct iio_channel;
>  
>  enum ntc_thermistor_type {
> -	TYPE_NCPXXWB473,
> -	TYPE_NCPXXWL333,
>  	TYPE_B57330V2103,
> +	TYPE_B57891S0103,
> +	TYPE_NCPXXWB473,
>  	TYPE_NCPXXWF104,
> +	TYPE_NCPXXWL333,
>  	TYPE_NCPXXXH103,
> -	TYPE_B57891S0103,
>  };
>  
>  struct ntc_thermistor_platform_data {

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

end of thread, other threads:[~2018-12-02  5:53 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-11-17 12:12 [PATCH 1/2] dt-bindings: hwmon: add B57891S0103 thermistor from Epcos Peter Rosin
2018-11-17 12:13 ` [PATCH 2/2] hwmon: (ntc_thermistor): add support for B57891S0103 " Peter Rosin
2018-11-19 17:07   ` Guenter Roeck
2018-11-19 21:16     ` Peter Rosin
2018-11-19 21:28       ` Guenter Roeck
2018-11-21  6:06         ` Peter Rosin
2018-11-21  8:42           ` Guenter Roeck
2018-11-21 16:03             ` [PATCH 0/2] hwmon: (ntc_thermistor) sort thermistors Peter Rosin
2018-11-21 16:03               ` [PATCH 1/2] hwmon: (ntc_thermistor) sort thermistor id lists alphabetically Peter Rosin
2018-12-01 18:39                 ` Guenter Roeck
2018-11-21 16:03               ` [PATCH 2/2] hwmon: (ntc_thermistor) use a table to lookup the thermistor type Peter Rosin
2018-12-01 18:40                 ` Guenter Roeck
2018-12-01 18:38   ` [PATCH 2/2] hwmon: (ntc_thermistor): add support for B57891S0103 from Epcos Guenter Roeck
2018-12-01 18:37 ` [PATCH 1/2] dt-bindings: hwmon: add B57891S0103 thermistor " Guenter Roeck

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).