linux-hwmon.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Guenter Roeck <linux@roeck-us.net>
To: Linus Walleij <linus.walleij@linaro.org>
Cc: Jean Delvare <jdelvare@suse.com>, linux-hwmon@vger.kernel.org
Subject: Re: [PATCH 2/2] hwmon: (ad7418) Add device tree probing
Date: Mon, 25 Feb 2019 06:36:57 -0800	[thread overview]
Message-ID: <20190225143657.GA12447@roeck-us.net> (raw)
In-Reply-To: <20190128210637.22323-2-linus.walleij@linaro.org>

On Mon, Jan 28, 2019 at 10:06:37PM +0100, Linus Walleij wrote:
> 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>

Applied to hwmon-next.

Thanks,
Guenter

> ---
>  drivers/hwmon/ad7418.c | 14 +++++++++++++-
>  1 file changed, 13 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/hwmon/ad7418.c b/drivers/hwmon/ad7418.c
> index 76f0a5c01e8a..ec0f5d8f18c3 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>
>  
> @@ -220,7 +221,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:
> @@ -258,9 +262,17 @@ 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,

  reply	other threads:[~2019-02-25 14:37 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-28 21:06 [PATCH 1/2] hwmon: (ad741x) Add DT bindings for Analog Devices AD741x Linus Walleij
2019-01-28 21:06 ` [PATCH 2/2] hwmon: (ad7418) Add device tree probing Linus Walleij
2019-02-25 14:36   ` Guenter Roeck [this message]
2019-02-25 14:28 ` [PATCH 1/2] hwmon: (ad741x) Add DT bindings for Analog Devices AD741x Rob Herring
2019-02-25 14:36 ` 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=20190225143657.GA12447@roeck-us.net \
    --to=linux@roeck-us.net \
    --cc=jdelvare@suse.com \
    --cc=linus.walleij@linaro.org \
    --cc=linux-hwmon@vger.kernel.org \
    /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).