Commit e056fe25 authored by Peter Rosin's avatar Peter Rosin Committed by Guenter Roeck

hwmon: (ntc_thermistor) sort thermistor id lists alphabetically

Use an enum to index the array, so that it is possible to add sorted
entries without causing churn.
Signed-off-by: default avatarPeter Rosin <peda@axentia.se>
Signed-off-by: default avatarGuenter Roeck <linux@roeck-us.net>
parent e8fda2c8
...@@ -45,18 +45,34 @@ struct ntc_compensation { ...@@ -45,18 +45,34 @@ struct ntc_compensation {
unsigned int ohm; 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[] = { static const struct platform_device_id ntc_thermistor_id[] = {
{ "ncp15wb473", TYPE_NCPXXWB473 }, [NTC_B57330V2103] = { "b57330v2103", TYPE_B57330V2103 },
{ "ncp18wb473", TYPE_NCPXXWB473 }, [NTC_B57891S0103] = { "b57891s0103", TYPE_B57891S0103 },
{ "ncp21wb473", TYPE_NCPXXWB473 }, [NTC_NCP03WB473] = { "ncp03wb473", TYPE_NCPXXWB473 },
{ "ncp03wb473", TYPE_NCPXXWB473 }, [NTC_NCP03WF104] = { "ncp03wf104", TYPE_NCPXXWF104 },
{ "ncp15wl333", TYPE_NCPXXWL333 }, [NTC_NCP15WB473] = { "ncp15wb473", TYPE_NCPXXWB473 },
{ "b57330v2103", TYPE_B57330V2103}, [NTC_NCP15WL333] = { "ncp15wl333", TYPE_NCPXXWL333 },
{ "ncp03wf104", TYPE_NCPXXWF104 }, [NTC_NCP15XH103] = { "ncp15xh103", TYPE_NCPXXXH103 },
{ "ncp15xh103", TYPE_NCPXXXH103 }, [NTC_NCP18WB473] = { "ncp18wb473", TYPE_NCPXXWB473 },
{ "b57891s0103", TYPE_B57891S0103 }, [NTC_NCP21WB473] = { "ncp21wb473", TYPE_NCPXXWB473 },
{ }, [NTC_LAST] = { },
}; };
/* /*
...@@ -327,36 +343,36 @@ static int ntc_adc_iio_read(struct ntc_thermistor_platform_data *pdata) ...@@ -327,36 +343,36 @@ static int ntc_adc_iio_read(struct ntc_thermistor_platform_data *pdata)
} }
static const struct of_device_id ntc_match[] = { 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", { .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", { .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", { .compatible = "murata,ncp15xh103",
.data = &ntc_thermistor_id[7] }, .data = &ntc_thermistor_id[NTC_NCP15XH103] },
{ .compatible = "epcos,b57891s0103", { .compatible = "murata,ncp18wb473",
.data = &ntc_thermistor_id[8] }, .data = &ntc_thermistor_id[NTC_NCP18WB473] },
{ .compatible = "murata,ncp21wb473",
.data = &ntc_thermistor_id[NTC_NCP21WB473] },
/* Usage of vendor name "ntc" is deprecated */ /* Usage of vendor name "ntc" is deprecated */
{ .compatible = "ntc,ncp03wb473",
.data = &ntc_thermistor_id[NTC_NCP03WB473] },
{ .compatible = "ntc,ncp15wb473", { .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", { .compatible = "ntc,ncp18wb473",
.data = &ntc_thermistor_id[1] }, .data = &ntc_thermistor_id[NTC_NCP18WB473] },
{ .compatible = "ntc,ncp21wb473", { .compatible = "ntc,ncp21wb473",
.data = &ntc_thermistor_id[2] }, .data = &ntc_thermistor_id[NTC_NCP21WB473] },
{ .compatible = "ntc,ncp03wb473",
.data = &ntc_thermistor_id[3] },
{ .compatible = "ntc,ncp15wl333",
.data = &ntc_thermistor_id[4] },
{ }, { },
}; };
MODULE_DEVICE_TABLE(of, ntc_match); MODULE_DEVICE_TABLE(of, ntc_match);
......
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