linux-hwmon.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Guenter Roeck <linux@roeck-us.net>
To: Peter Rosin <peda@axentia.se>
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	Jean Delvare <jdelvare@suse.com>,
	"linux-hwmon@vger.kernel.org" <linux-hwmon@vger.kernel.org>
Subject: Re: [PATCH 1/2] hwmon: (ntc_thermistor) sort thermistor id lists alphabetically
Date: Sat, 1 Dec 2018 10:39:51 -0800	[thread overview]
Message-ID: <20181201183951.GA11613@roeck-us.net> (raw)
In-Reply-To: <20181121160327.16772-2-peda@axentia.se>

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);

  reply	other threads:[~2018-12-02  5:53 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20181201183951.GA11613@roeck-us.net \
    --to=linux@roeck-us.net \
    --cc=jdelvare@suse.com \
    --cc=linux-hwmon@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=peda@axentia.se \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).