diff mbox

[07/19] iio: adc: am335x: Add DT support

Message ID 1369681926-22185-8-git-send-email-bigeasy@linutronix.de (mailing list archive)
State New, archived
Headers show

Commit Message

Sebastian Andrzej Siewior May 27, 2013, 7:11 p.m. UTC
From: "Patil, Rachna" <rachna@ti.com>

Add DT support for client ADC driver.

[ panto@antoniou-consulting.com : use of_get_child_by_name
	instead of of_find_node_by_name ]

Signed-off-by: Pantelis Antoniou <panto@antoniou-consulting.com>
Signed-off-by: Patil, Rachna <rachna@ti.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
[bigeasy: shift the code to the left]
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
---
 drivers/iio/adc/ti_am335x_adc.c |   23 +++++++++++++++++++----
 1 file changed, 19 insertions(+), 4 deletions(-)

Comments

Jonathan Cameron June 2, 2013, 4:58 p.m. UTC | #1
On 05/27/2013 08:11 PM, Sebastian Andrzej Siewior wrote:
> From: "Patil, Rachna" <rachna@ti.com>
> 
> Add DT support for client ADC driver.
> 
> [ panto@antoniou-consulting.com : use of_get_child_by_name
> 	instead of of_find_node_by_name ]
> 
> Signed-off-by: Pantelis Antoniou <panto@antoniou-consulting.com>
> Signed-off-by: Patil, Rachna <rachna@ti.com>
> Signed-off-by: Felipe Balbi <balbi@ti.com>
> [bigeasy: shift the code to the left]
> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Acked-by: Jonathan Cameron <jic23@kernel.org>

I would take this directly but then I'd imagine that will cause havoc
when the later patches are applied and touch both iio and mfd.


> ---
>  drivers/iio/adc/ti_am335x_adc.c |   23 +++++++++++++++++++----
>  1 file changed, 19 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/iio/adc/ti_am335x_adc.c b/drivers/iio/adc/ti_am335x_adc.c
> index 5f9a7e7..e657709 100644
> --- a/drivers/iio/adc/ti_am335x_adc.c
> +++ b/drivers/iio/adc/ti_am335x_adc.c
> @@ -22,6 +22,8 @@
>  #include <linux/platform_device.h>
>  #include <linux/io.h>
>  #include <linux/iio/iio.h>
> +#include <linux/of.h>
> +#include <linux/of_device.h>
>  
>  #include <linux/mfd/ti_am335x_tscadc.h>
>  #include <linux/platform_data/ti_am335x_adc.h>
> @@ -141,11 +143,12 @@ static int tiadc_probe(struct platform_device *pdev)
>  	struct iio_dev		*indio_dev;
>  	struct tiadc_device	*adc_dev;
>  	struct ti_tscadc_dev	*tscadc_dev = pdev->dev.platform_data;
> -	struct mfd_tscadc_board	*pdata;
> +	struct mfd_tscadc_board	*pdata = tscadc_dev->dev->platform_data;
> +	struct device_node	*node = tscadc_dev->dev->of_node;
>  	int			err;
> +	u32			val32;
>  
> -	pdata = tscadc_dev->dev->platform_data;
> -	if (!pdata || !pdata->adc_init) {
> +	if (!pdata && !node) {
>  		dev_err(&pdev->dev, "Could not find platform data\n");
>  		return -EINVAL;
>  	}
> @@ -159,7 +162,19 @@ static int tiadc_probe(struct platform_device *pdev)
>  	adc_dev = iio_priv(indio_dev);
>  
>  	adc_dev->mfd_tscadc = tscadc_dev;
> -	adc_dev->channels = pdata->adc_init->adc_channels;
> +
> +	if (pdata)
> +		adc_dev->channels = pdata->adc_init->adc_channels;
> +	else {
> +		node = of_get_child_by_name(node, "adc");
> +		if (!node)
> +			return  -EINVAL;
> +		err = of_property_read_u32(node,
> +				"ti,adc-channels", &val32);
> +		if (err < 0)
> +			goto err_free_device;
> +		adc_dev->channels = val32;
> +	}
>  
>  	indio_dev->dev.parent = &pdev->dev;
>  	indio_dev->name = dev_name(&pdev->dev);
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Sebastian Andrzej Siewior June 4, 2013, 10:12 a.m. UTC | #2
* Jonathan Cameron | 2013-06-02 17:58:54 [+0100]:

>On 05/27/2013 08:11 PM, Sebastian Andrzej Siewior wrote:
>> From: "Patil, Rachna" <rachna@ti.com>
>> 
>> Add DT support for client ADC driver.
>> 
>> [ panto@antoniou-consulting.com : use of_get_child_by_name
>> 	instead of of_find_node_by_name ]
>> 
>> Signed-off-by: Pantelis Antoniou <panto@antoniou-consulting.com>
>> Signed-off-by: Patil, Rachna <rachna@ti.com>
>> Signed-off-by: Felipe Balbi <balbi@ti.com>
>> [bigeasy: shift the code to the left]
>> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
>Acked-by: Jonathan Cameron <jic23@kernel.org>
>
>I would take this directly but then I'd imagine that will cause havoc
>when the later patches are applied and touch both iio and mfd.

Yeah, I have no idea what to do here since it would be best to grab the
series in one go. The fact that I hear nothing from input/mfd does not
make it easier :)

Sebastian
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Dmitry Torokhov June 4, 2013, 4:57 p.m. UTC | #3
On Tue, Jun 04, 2013 at 12:12:02PM +0200, Sebastian Andrzej Siewior wrote:
> * Jonathan Cameron | 2013-06-02 17:58:54 [+0100]:
> 
> >On 05/27/2013 08:11 PM, Sebastian Andrzej Siewior wrote:
> >> From: "Patil, Rachna" <rachna@ti.com>
> >> 
> >> Add DT support for client ADC driver.
> >> 
> >> [ panto@antoniou-consulting.com : use of_get_child_by_name
> >> 	instead of of_find_node_by_name ]
> >> 
> >> Signed-off-by: Pantelis Antoniou <panto@antoniou-consulting.com>
> >> Signed-off-by: Patil, Rachna <rachna@ti.com>
> >> Signed-off-by: Felipe Balbi <balbi@ti.com>
> >> [bigeasy: shift the code to the left]
> >> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
> >Acked-by: Jonathan Cameron <jic23@kernel.org>
> >
> >I would take this directly but then I'd imagine that will cause havoc
> >when the later patches are applied and touch both iio and mfd.
> 
> Yeah, I have no idea what to do here since it would be best to grab the
> series in one go. The fact that I hear nothing from input/mfd does not
> make it easier :)

It looks like it will have to go through MFD tree.

Thanks.
diff mbox

Patch

diff --git a/drivers/iio/adc/ti_am335x_adc.c b/drivers/iio/adc/ti_am335x_adc.c
index 5f9a7e7..e657709 100644
--- a/drivers/iio/adc/ti_am335x_adc.c
+++ b/drivers/iio/adc/ti_am335x_adc.c
@@ -22,6 +22,8 @@ 
 #include <linux/platform_device.h>
 #include <linux/io.h>
 #include <linux/iio/iio.h>
+#include <linux/of.h>
+#include <linux/of_device.h>
 
 #include <linux/mfd/ti_am335x_tscadc.h>
 #include <linux/platform_data/ti_am335x_adc.h>
@@ -141,11 +143,12 @@  static int tiadc_probe(struct platform_device *pdev)
 	struct iio_dev		*indio_dev;
 	struct tiadc_device	*adc_dev;
 	struct ti_tscadc_dev	*tscadc_dev = pdev->dev.platform_data;
-	struct mfd_tscadc_board	*pdata;
+	struct mfd_tscadc_board	*pdata = tscadc_dev->dev->platform_data;
+	struct device_node	*node = tscadc_dev->dev->of_node;
 	int			err;
+	u32			val32;
 
-	pdata = tscadc_dev->dev->platform_data;
-	if (!pdata || !pdata->adc_init) {
+	if (!pdata && !node) {
 		dev_err(&pdev->dev, "Could not find platform data\n");
 		return -EINVAL;
 	}
@@ -159,7 +162,19 @@  static int tiadc_probe(struct platform_device *pdev)
 	adc_dev = iio_priv(indio_dev);
 
 	adc_dev->mfd_tscadc = tscadc_dev;
-	adc_dev->channels = pdata->adc_init->adc_channels;
+
+	if (pdata)
+		adc_dev->channels = pdata->adc_init->adc_channels;
+	else {
+		node = of_get_child_by_name(node, "adc");
+		if (!node)
+			return  -EINVAL;
+		err = of_property_read_u32(node,
+				"ti,adc-channels", &val32);
+		if (err < 0)
+			goto err_free_device;
+		adc_dev->channels = val32;
+	}
 
 	indio_dev->dev.parent = &pdev->dev;
 	indio_dev->name = dev_name(&pdev->dev);