Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f4c2965e authored by Linus Walleij's avatar Linus Walleij Committed by Guenter Roeck
Browse files

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: default avatarLinus Walleij <linus.walleij@linaro.org>
[groeck: Added missing {} to terminate ad7418_dt_ids]
Signed-off-by: default avatarGuenter Roeck <linux@roeck-us.net>
parent badf14ce
Loading
Loading
Loading
Loading
+14 −1
Original line number Diff line number Diff line
@@ -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,6 +254,9 @@ static int ad7418_probe(struct i2c_client *client,

	mutex_init(&data->lock);
	data->client = client;
	if (dev->of_node)
		data->type = (enum chips)of_device_get_match_data(dev);
	else
		data->type = id->driver_data;

	switch (data->type) {
@@ -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,