diff mbox series

[RFC,9/9] iio: inkern: Drop io-channel-ranges dt property support

Message ID 20201115192951.1073632-10-jic23@kernel.org
State New
Headers show
Series dt-bindings: IIO: Drop wrong use of io-channel-ranges then drop it as well. | expand

Commit Message

Jonathan Cameron Nov. 15, 2020, 7:29 p.m. UTC
From: Jonathan Cameron <Jonathan.Cameron@huawei.com>


This property has been almost exclusively missused in mainline and
we don't actually have any instances of it being necessary.

As such Rob Herring suggested we just drop it and I can't immediately
see any reason to disagree.

If anyone has an out of tree dts file that makes use of this then let
me know.  I'm not against keeping the code, but documenting it as a
deprecated property not to be used in new dts files.

Note build tested only. If someone could give it a sanity check
on a platform that uses this interface that would be great.
If not I'll mock something up before applying this.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

Cc: Guenter Roeck <linux@roeck-us.net>
Cc: Lars-Peter Clausen <lars@metafoo.de>
---
 drivers/iio/inkern.c | 49 +++++++++++++++-----------------------------
 1 file changed, 17 insertions(+), 32 deletions(-)

-- 
2.28.0

Comments

Jonathan Cameron Feb. 21, 2021, 4:31 p.m. UTC | #1
On Sun, 15 Nov 2020 19:29:51 +0000
Jonathan Cameron <jic23@kernel.org> wrote:

> From: Jonathan Cameron <Jonathan.Cameron@huawei.com>

> 

> This property has been almost exclusively missused in mainline and

> we don't actually have any instances of it being necessary.

> 

> As such Rob Herring suggested we just drop it and I can't immediately

> see any reason to disagree.

> 

> If anyone has an out of tree dts file that makes use of this then let

> me know.  I'm not against keeping the code, but documenting it as a

> deprecated property not to be used in new dts files.

> 

> Note build tested only. If someone could give it a sanity check

> on a platform that uses this interface that would be great.

> If not I'll mock something up before applying this.

> 

> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

Hi all,

I plan to apply this given no one has mentioned using it in out of tree
dts files.  If someone has time to sanity check I didn't actually mess
up the patch below that would be great!

Thanks,

Jonathan

> Cc: Guenter Roeck <linux@roeck-us.net>

> Cc: Lars-Peter Clausen <lars@metafoo.de>

> ---

>  drivers/iio/inkern.c | 49 +++++++++++++++-----------------------------

>  1 file changed, 17 insertions(+), 32 deletions(-)

> 

> diff --git a/drivers/iio/inkern.c b/drivers/iio/inkern.c

> index ede99e0d5371..85a6f6103ee9 100644

> --- a/drivers/iio/inkern.c

> +++ b/drivers/iio/inkern.c

> @@ -184,40 +184,25 @@ static struct iio_channel *of_iio_channel_get_by_name(struct device_node *np,

>  						      const char *name)

>  {

>  	struct iio_channel *chan = NULL;

> -

> -	/* Walk up the tree of devices looking for a matching iio channel */

> -	while (np) {

> -		int index = 0;

> -

> -		/*

> -		 * For named iio channels, first look up the name in the

> -		 * "io-channel-names" property.  If it cannot be found, the

> -		 * index will be an error code, and of_iio_channel_get()

> -		 * will fail.

> -		 */

> -		if (name)

> -			index = of_property_match_string(np, "io-channel-names",

> +	int index = 0;

> +

> +	/*

> +	 * For named iio channels, first look up the name in the

> +	 * "io-channel-names" property.  If it cannot be found, the

> +	 * index will be an error code, and of_iio_channel_get()

> +	 * will fail.

> +	 */

> +	if (name)

> +		index = of_property_match_string(np, "io-channel-names",

>  							 name);

> -		chan = of_iio_channel_get(np, index);

> -		if (!IS_ERR(chan) || PTR_ERR(chan) == -EPROBE_DEFER)

> -			break;

> -		else if (name && index >= 0) {

> -			pr_err("ERROR: could not get IIO channel %pOF:%s(%i)\n",

> -				np, name ? name : "", index);

> -			return NULL;

> -		}

> +	chan = of_iio_channel_get(np, index);

> +	if (!IS_ERR(chan) || PTR_ERR(chan) == -EPROBE_DEFER)

> +		return chan;

> +	else if (name && index >= 0)

> +		pr_err("ERROR: could not get IIO channel %pOF:%s(%i)\n",

> +		       np, name ? name : "", index);

>  

> -		/*

> -		 * No matching IIO channel found on this node.

> -		 * If the parent node has a "io-channel-ranges" property,

> -		 * then we can try one of its channels.

> -		 */

> -		np = np->parent;

> -		if (np && !of_get_property(np, "io-channel-ranges", NULL))

> -			return NULL;

> -	}

> -

> -	return chan;

> +	return NULL;

>  }

>  

>  static struct iio_channel *of_iio_channel_get_all(struct device *dev)
diff mbox series

Patch

diff --git a/drivers/iio/inkern.c b/drivers/iio/inkern.c
index ede99e0d5371..85a6f6103ee9 100644
--- a/drivers/iio/inkern.c
+++ b/drivers/iio/inkern.c
@@ -184,40 +184,25 @@  static struct iio_channel *of_iio_channel_get_by_name(struct device_node *np,
 						      const char *name)
 {
 	struct iio_channel *chan = NULL;
-
-	/* Walk up the tree of devices looking for a matching iio channel */
-	while (np) {
-		int index = 0;
-
-		/*
-		 * For named iio channels, first look up the name in the
-		 * "io-channel-names" property.  If it cannot be found, the
-		 * index will be an error code, and of_iio_channel_get()
-		 * will fail.
-		 */
-		if (name)
-			index = of_property_match_string(np, "io-channel-names",
+	int index = 0;
+
+	/*
+	 * For named iio channels, first look up the name in the
+	 * "io-channel-names" property.  If it cannot be found, the
+	 * index will be an error code, and of_iio_channel_get()
+	 * will fail.
+	 */
+	if (name)
+		index = of_property_match_string(np, "io-channel-names",
 							 name);
-		chan = of_iio_channel_get(np, index);
-		if (!IS_ERR(chan) || PTR_ERR(chan) == -EPROBE_DEFER)
-			break;
-		else if (name && index >= 0) {
-			pr_err("ERROR: could not get IIO channel %pOF:%s(%i)\n",
-				np, name ? name : "", index);
-			return NULL;
-		}
+	chan = of_iio_channel_get(np, index);
+	if (!IS_ERR(chan) || PTR_ERR(chan) == -EPROBE_DEFER)
+		return chan;
+	else if (name && index >= 0)
+		pr_err("ERROR: could not get IIO channel %pOF:%s(%i)\n",
+		       np, name ? name : "", index);
 
-		/*
-		 * No matching IIO channel found on this node.
-		 * If the parent node has a "io-channel-ranges" property,
-		 * then we can try one of its channels.
-		 */
-		np = np->parent;
-		if (np && !of_get_property(np, "io-channel-ranges", NULL))
-			return NULL;
-	}
-
-	return chan;
+	return NULL;
 }
 
 static struct iio_channel *of_iio_channel_get_all(struct device *dev)