diff options
author | Linus Walleij <linus.walleij@linaro.org> | 2019-01-28 22:06:37 +0100 |
---|---|---|
committer | Guenter Roeck <linux@roeck-us.net> | 2019-02-25 09:06:00 -0800 |
commit | f4c2965e425ab0adba63d9dcf5351e955fc95b60 (patch) | |
tree | b7d61da87083ab5f66f5885449ff2793c446a717 /drivers/hwmon | |
parent | badf14ceba5589711f149a48f57c342032e55d03 (diff) | |
download | linux-f4c2965e425ab0adba63d9dcf5351e955fc95b60.tar.gz linux-f4c2965e425ab0adba63d9dcf5351e955fc95b60.tar.bz2 linux-f4c2965e425ab0adba63d9dcf5351e955fc95b60.zip |
hwmon: (ad7418) Add device tree probing
This adds device tree probing for the AD7418 hwmon sensor.
When device tree is not enabled, stub functions will kick
in.
Tested on the Gateway Cambria GW2358-4.
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
[groeck: Added missing {} to terminate ad7418_dt_ids]
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Diffstat (limited to 'drivers/hwmon')
-rw-r--r-- | drivers/hwmon/ad7418.c | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/drivers/hwmon/ad7418.c b/drivers/hwmon/ad7418.c index a20d5ebe9d97..4aeba29b4629 100644 --- a/drivers/hwmon/ad7418.c +++ b/drivers/hwmon/ad7418.c @@ -19,6 +19,7 @@ #include <linux/hwmon-sysfs.h> #include <linux/err.h> #include <linux/mutex.h> +#include <linux/of_device.h> #include <linux/delay.h> #include <linux/slab.h> @@ -253,7 +254,10 @@ static int ad7418_probe(struct i2c_client *client, mutex_init(&data->lock); data->client = client; - data->type = id->driver_data; + if (dev->of_node) + data->type = (enum chips)of_device_get_match_data(dev); + else + data->type = id->driver_data; switch (data->type) { case ad7416: @@ -291,9 +295,18 @@ static const struct i2c_device_id ad7418_id[] = { }; MODULE_DEVICE_TABLE(i2c, ad7418_id); +static const struct of_device_id ad7418_dt_ids[] = { + { .compatible = "adi,ad7416", .data = (void *)ad7416, }, + { .compatible = "adi,ad7417", .data = (void *)ad7417, }, + { .compatible = "adi,ad7418", .data = (void *)ad7418, }, + { } +}; +MODULE_DEVICE_TABLE(of, ad7418_dt_ids); + static struct i2c_driver ad7418_driver = { .driver = { .name = "ad7418", + .of_match_table = ad7418_dt_ids, }, .probe = ad7418_probe, .id_table = ad7418_id, |