mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Peter Meerwald-Stadler <pmeerw@pmeerw.net>
To: Bjorn Andersson <bjorn.andersson@linaro.org>
Cc: Jonathan Cameron <jic23@kernel.org>,
	linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org,
	Lee Jones <lee.jones@linaro.org>
Subject: Re: [PATCH v6 4/5] iio: light: lm3533-als: Support initialization from Device Tree
Date: Tue, 31 Jan 2017 08:06:44 +0100 (CET)	[thread overview]
Message-ID: <alpine.DEB.2.02.1701310805580.1494@pmeerw.net> (raw)
In-Reply-To: <20170130211719.31017-4-bjorn.andersson@linaro.org>


> Implement support for initialization of the lm3533 als driver from
> Device Tree.

minor comment below
 
> Signed-off-by: Bjorn Andersson <bjorn.andersson@sonymobile.com>
> Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
> ---
> 
> Note that this patch can be merged independently of the other patches in the
> series.
> 
> Changes since v5:
> - None
> 
> Changes since v4:
> - None
> 
> Changes since v3:
> - Moved als DT parsing from mfd driver
> - Gave driver its own compatible
> 
>  drivers/iio/light/lm3533-als.c | 40 +++++++++++++++++++++++++++++++++++++++-
>  1 file changed, 39 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/iio/light/lm3533-als.c b/drivers/iio/light/lm3533-als.c
> index f409c2047c05..eef9f06eb0b1 100644
> --- a/drivers/iio/light/lm3533-als.c
> +++ b/drivers/iio/light/lm3533-als.c
> @@ -20,6 +20,7 @@
>  #include <linux/module.h>
>  #include <linux/mutex.h>
>  #include <linux/mfd/core.h>
> +#include <linux/of.h>
>  #include <linux/platform_device.h>
>  #include <linux/slab.h>
>  #include <linux/uaccess.h>
> @@ -831,6 +832,32 @@ static const struct iio_info lm3533_als_info = {
>  	.read_raw	= &lm3533_als_read_raw,
>  };
>  
> +static struct lm3533_als_platform_data *lm3533_als_of_parse(struct device *dev)
> +{
> +	struct lm3533_als_platform_data *als_pdata;
> +	struct device_node *node = dev->of_node;
> +	int ret;
> +	u32 val;
> +
> +	als_pdata = devm_kzalloc(dev, sizeof(*als_pdata), GFP_KERNEL);
> +	if (!als_pdata)
> +		return NULL;
> +
> +	als_pdata->pwm_mode = of_property_read_bool(node, "ti,pwm-mode");
> +
> +	ret = of_property_read_u32(node, "ti,als-resistance-ohm", &val);
> +	if (ret < 0 && ret != -EINVAL) {
> +		dev_err(dev, "unable to read ti,als-resistance-ohm");

\n missing

> +		return NULL;
> +	}
> +
> +	/* Leave at high-Z, if the property was omitted or specified as 0 */
> +	if (!ret && val != 0)
> +		als_pdata->r_select = 200000 / val;
> +
> +	return als_pdata;
> +}
> +
>  static int lm3533_als_probe(struct platform_device *pdev)
>  {
>  	struct lm3533 *lm3533;
> @@ -843,7 +870,11 @@ static int lm3533_als_probe(struct platform_device *pdev)
>  	if (!lm3533)
>  		return -EINVAL;
>  
> -	pdata = pdev->dev.platform_data;
> +	if (pdev->dev.of_node)
> +		pdata = lm3533_als_of_parse(&pdev->dev);
> +	else
> +		pdata = pdev->dev.platform_data;
> +
>  	if (!pdata) {
>  		dev_err(&pdev->dev, "no platform data\n");
>  		return -EINVAL;
> @@ -914,9 +945,16 @@ static int lm3533_als_remove(struct platform_device *pdev)
>  	return 0;
>  }
>  
> +static const struct of_device_id lm3533_als_of_match[] = {
> +	{ .compatible = "ti,lm3533-als", },
> +	{ },
> +};
> +MODULE_DEVICE_TABLE(of, lm3533_als_of_match);
> +
>  static struct platform_driver lm3533_als_driver = {
>  	.driver	= {
>  		.name	= "lm3533-als",
> +		.of_match_table = lm3533_als_of_match,
>  	},
>  	.probe		= lm3533_als_probe,
>  	.remove		= lm3533_als_remove,
> 

-- 

Peter Meerwald-Stadler
+43-664-2444418 (mobile)

  reply	other threads:[~2017-01-31  7:08 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-30 21:17 [PATCH v6 1/5] devicetree: mfd: Add binding for the TI LM3533 Bjorn Andersson
2017-01-30 21:17 ` [PATCH v6 2/5] mfd: lm3533: Support initialization from Device Tree Bjorn Andersson
2017-02-08 10:41   ` Lee Jones
2017-01-30 21:17 ` [PATCH v6 3/5] backlight: " Bjorn Andersson
2017-02-08 12:54   ` Lee Jones
2017-03-10 13:45   ` Daniel Thompson
2017-01-30 21:17 ` [PATCH v6 4/5] iio: light: lm3533-als: " Bjorn Andersson
2017-01-31  7:06   ` Peter Meerwald-Stadler [this message]
2017-01-30 21:17 ` [PATCH v6 5/5] leds: lm3533: " Bjorn Andersson
2017-01-31 21:15   ` Jacek Anaszewski

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=alpine.DEB.2.02.1701310805580.1494@pmeerw.net \
    --to=pmeerw@pmeerw.net \
    --cc=bjorn.andersson@linaro.org \
    --cc=jic23@kernel.org \
    --cc=lee.jones@linaro.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@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

all inboxes | Powered by JetHome®