mirror of
https://github.com/torvalds/linux.git
synced 2026-09-22 12:44:03 +02:00
hwmon: (sht3x) Add devicetree support
Add an of_device_id table to support devicetree based instantiation of the supported sensors. The devicetree binding models all higher accuracy parts with a fallback to the base part of their group, so only the two base compatibles need to be listed. The match data distinguishes the humidity and temperature parts (SHT3x) from the temperature-only parts (STS3x), which require different configuration. Start enum sht3x_chips at 1: with sht3x equal to 0, the OF match data for the SHT devices would be NULL, causing i2c_get_match_data() to fall back to i2c_device_id name matching, which fails for devicetree names. The devices would then only work because the resulting chip id 0 happens to equal sht3x. Non-zero match data avoids relying on that coincidence. Signed-off-by: Zaixiang Xu <zaixiang.xu.dev@gmail.com> Link: https://lore.kernel.org/r/20260713074559.12196-4-zaixiang.xu.dev@gmail.com Signed-off-by: Guenter Roeck <linux@roeck-us.net>
This commit is contained in:
parent
71b99f4242
commit
75186ab25c
|
|
@ -62,7 +62,7 @@ static const unsigned char sht3x_cmd_read_serial_number[] = { 0x37, 0x80 };
|
|||
#define SHT3X_MAX_HUMIDITY 100000
|
||||
|
||||
enum sht3x_chips {
|
||||
sht3x,
|
||||
sht3x = 1,
|
||||
sts3x,
|
||||
};
|
||||
|
||||
|
|
@ -940,8 +940,19 @@ static const struct i2c_device_id sht3x_ids[] = {
|
|||
|
||||
MODULE_DEVICE_TABLE(i2c, sht3x_ids);
|
||||
|
||||
static const struct of_device_id sht3x_of_match[] = {
|
||||
{ .compatible = "sensirion,sht30", .data = (void *)(uintptr_t)sht3x },
|
||||
{ .compatible = "sensirion,sts30", .data = (void *)(uintptr_t)sts3x },
|
||||
{ }
|
||||
};
|
||||
|
||||
MODULE_DEVICE_TABLE(of, sht3x_of_match);
|
||||
|
||||
static struct i2c_driver sht3x_i2c_driver = {
|
||||
.driver.name = "sht3x",
|
||||
.driver = {
|
||||
.name = "sht3x",
|
||||
.of_match_table = sht3x_of_match,
|
||||
},
|
||||
.probe = sht3x_probe,
|
||||
.id_table = sht3x_ids,
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user