Skip to contentSkip to conversation

iio: core: Propagate error codes from OF layer to client drivers

PATCH In review Ivan T. Ivanov 5 participants 9 messages Aug 25, 2014 – Aug 27, 2014 IIO

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 iio: core: Propagate error codes from OF layer to client drivers

Do not overwrite error codes returned from of_iio_channel_get(). Error codes are used to distinguish between "io-channel-names" not present in DT bindings, property is optional, and IIO channel provider driver still not being loaded, defer probe.

---
 drivers/iio/inkern.c | 24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)
drivers/iio/inkern.c +12 -12
index c749700..66a6cde 100644
@@ -162,7 +162,7 @@ err_free_channel:
 static struct iio_channel *of_iio_channel_get_by_name(struct device_node *np,
 						      const char *name)
 {
-	struct iio_channel *chan = NULL;
+	struct iio_channel *chan = ERR_PTR(-ENODEV);
 
 	/* Walk up the tree of devices looking for a matching iio channel */
 	while (np) {
@@ -183,7 +183,7 @@ static struct iio_channel *of_iio_channel_get_by_name(struct device_node *np,
 		else if (name && index >= 0) {
 			pr_err("ERROR: could not get IIO channel %s:%s(%i)\n",
 				np->full_name, name ? name : "", index);
-			return NULL;
+			break;
 		}
 
 		/*
@@ -193,7 +193,7 @@ static struct iio_channel *of_iio_channel_get_by_name(struct device_node *np,
 		 */
 		np = np->parent;
 		if (np && !of_get_property(np, "io-channel-ranges", NULL))
-			return NULL;
+			break;
 	}
 
 	return chan;
@@ -243,12 +243,12 @@ error_free_chans:
 static inline struct iio_channel *
 of_iio_channel_get_by_name(struct device_node *np, const char *name)
 {
-	return NULL;
+	return ERR_PTR(-ENODEV);
 }
 
 static inline struct iio_channel *of_iio_channel_get_all(struct device *dev)
 {
-	return NULL;
+	return ERR_PTR(-ENODEV);
 }
 
 #endif /* CONFIG_OF */
@@ -312,14 +312,14 @@ struct iio_channel *iio_channel_get(struct device *dev,
 	const char *name = dev ? dev_name(dev) : NULL;
 	struct iio_channel *channel;
 
-	if (dev) {
-		channel = of_iio_channel_get_by_name(dev->of_node,
-						     channel_name);
-		if (channel != NULL)
-			return channel;
-	}
+	channel = iio_channel_get_sys(name, channel_name);
+	if (!IS_ERR(channel))
+		return channel;
+
+	if (!dev)
+		return channel;
 
-	return iio_channel_get_sys(name, channel_name);
+	return of_iio_channel_get_by_name(dev->of_node, channel_name);
 }
 EXPORT_SYMBOL_GPL(iio_channel_get);
 
Signature · 1 line
1.9.1
maintainer
#1 lore raw
Quoted 6 lines · Ivan T. Ivanov

Do not overwrite error codes returned from of_iio_channel_get(). Error codes are used to distinguish between "io-channel-names" not present in DT bindings, property is optional, and IIO channel provider driver still not being loaded, defer probe.

Cc'd Guenter who often takes an interest in this code (and wrote it ;)

Mostly seems logical to me, though I don't like the change of priority in the last bit. I've also just taken a fix for this code so there may be some fuzz from that once it's propogated through to mainline and back to the togreg tree of iio.git

Thanks,

Jonathan

Quoted 60 lines
---
 drivers/iio/inkern.c | 24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)
drivers/iio/inkern.c +5 -11
index c749700..66a6cde 100644
@@ -162,7 +162,7 @@ err_free_channel:
 static struct iio_channel *of_iio_channel_get_by_name(struct device_node *np,
 						      const char *name)
 {
-	struct iio_channel *chan = NULL;
+	struct iio_channel *chan = ERR_PTR(-ENODEV);
 
 	/* Walk up the tree of devices looking for a matching iio channel */
 	while (np) {
@@ -183,7 +183,7 @@ static struct iio_channel *of_iio_channel_get_by_name(struct device_node *np,
 		else if (name && index >= 0) {
 			pr_err("ERROR: could not get IIO channel %s:%s(%i)\n",
 				np->full_name, name ? name : "", index);
-			return NULL;
+			break;
 		}
 
 		/*
@@ -193,7 +193,7 @@ static struct iio_channel *of_iio_channel_get_by_name(struct device_node *np,
 		 */
 		np = np->parent;
 		if (np && !of_get_property(np, "io-channel-ranges", NULL))
-			return NULL;
+			break;
 	}
 
 	return chan;
@@ -243,12 +243,12 @@ error_free_chans:
 static inline struct iio_channel *
 of_iio_channel_get_by_name(struct device_node *np, const char *name)
 {
-	return NULL;
+	return ERR_PTR(-ENODEV);
 }
 
 static inline struct iio_channel *of_iio_channel_get_all(struct device *dev)
 {
-	return NULL;
+	return ERR_PTR(-ENODEV);
 }
 
 #endif /* CONFIG_OF */
@@ -312,14 +312,14 @@ struct iio_channel *iio_channel_get(struct device *dev,
 	const char *name = dev ? dev_name(dev) : NULL;
 	struct iio_channel *channel;
 
-	if (dev) {
-		channel = of_iio_channel_get_by_name(dev->of_node,
-						     channel_name);
-		if (channel != NULL)
-			return channel;
-	}

drivers/iio/inkern.c struct iio_channel *iio_channel_get(struct device *dev, · line 323

Quoted 10 lines
drivers/iio/inkern.c +7 -1
+	channel = iio_channel_get_sys(name, channel_name);
+	if (!IS_ERR(channel))
+		return channel;
+
+	if (!dev)
+		return channel;
 
-	return iio_channel_get_sys(name, channel_name);
+	return of_iio_channel_get_by_name(dev->of_node, channel_name);
 }

Why reorder the logic? This makes this patch less obviously
correct for limited obvious gain?

Previously the priority was clearly given to device tree bindings wherease now it is given to board file provided map elements. It would be interesting to see boards with both provided, but it is possible.

Quoted 3 lines
drivers/iio/inkern.c +0 -0
 EXPORT_SYMBOL_GPL(iio_channel_get);
 
#2 lore raw
Quoted 90 lines · Jonathan Cameron
Quoted 6 lines · Ivan T. Ivanov

Do not overwrite error codes returned from of_iio_channel_get(). Error codes are used to distinguish between "io-channel-names" not present in DT bindings, property is optional, and IIO channel provider driver still not being loaded, defer probe.

Cc'd Guenter who often takes an interest in this code (and wrote it ;)

Mostly seems logical to me, though I don't like the change of priority in the last bit. I've also just taken a fix for this code so there may be some fuzz from that once it's propogated through to mainline and back to the togreg tree of iio.git

Thanks,

Jonathan

Quoted 60 lines
---
 drivers/iio/inkern.c | 24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)
drivers/iio/inkern.c +5 -11
index c749700..66a6cde 100644
@@ -162,7 +162,7 @@ err_free_channel:
 static struct iio_channel *of_iio_channel_get_by_name(struct device_node *np,
 						      const char *name)
 {
-	struct iio_channel *chan = NULL;
+	struct iio_channel *chan = ERR_PTR(-ENODEV);
 
 	/* Walk up the tree of devices looking for a matching iio channel */
 	while (np) {
@@ -183,7 +183,7 @@ static struct iio_channel *of_iio_channel_get_by_name(struct device_node *np,
 		else if (name && index >= 0) {
 			pr_err("ERROR: could not get IIO channel %s:%s(%i)\n",
 				np->full_name, name ? name : "", index);
-			return NULL;
+			break;
 		}
 
 		/*
@@ -193,7 +193,7 @@ static struct iio_channel *of_iio_channel_get_by_name(struct device_node *np,
 		 */
 		np = np->parent;
 		if (np && !of_get_property(np, "io-channel-ranges", NULL))
-			return NULL;
+			break;
 	}
 
 	return chan;
@@ -243,12 +243,12 @@ error_free_chans:
 static inline struct iio_channel *
 of_iio_channel_get_by_name(struct device_node *np, const char *name)
 {
-	return NULL;
+	return ERR_PTR(-ENODEV);
 }
 
 static inline struct iio_channel *of_iio_channel_get_all(struct device *dev)
 {
-	return NULL;
+	return ERR_PTR(-ENODEV);
 }
 
 #endif /* CONFIG_OF */
@@ -312,14 +312,14 @@ struct iio_channel *iio_channel_get(struct device *dev,
 	const char *name = dev ? dev_name(dev) : NULL;
 	struct iio_channel *channel;
 
-	if (dev) {
-		channel = of_iio_channel_get_by_name(dev->of_node,
-						     channel_name);
-		if (channel != NULL)
-			return channel;
-	}

drivers/iio/inkern.c struct iio_channel *iio_channel_get(struct device *dev, · line 323

Quoted 10 lines
drivers/iio/inkern.c +7 -1
+	channel = iio_channel_get_sys(name, channel_name);
+	if (!IS_ERR(channel))
+		return channel;
+
+	if (!dev)
+		return channel;
 
-	return iio_channel_get_sys(name, channel_name);
+	return of_iio_channel_get_by_name(dev->of_node, channel_name);
 }

Why reorder the logic? This makes this patch less obviously
correct for limited obvious gain?

Quoted 4 lines

Previously the priority was clearly given to device tree bindings wherease now it is given to board file provided map elements. It would be interesting to see boards with both provided, but it is possible.

I am not entirely sure I understand what problem this patch is supposed to fix on top of the patch you just applied, and I am also a bit concerned about reversing the logic. Also, iio_channel_get_sys can return -ENOMEM and -EINVAL besides -ENODEV, all of which is now being ignored unless dev is set, and then it is returned unconditionally. So instead of ignoring error codes from of_iio_channel_get_by_name, the code now ignores error codes from iio_channel_get_sys under some circumstances (which, coincidentially, does not return -EPROBE_DEFER), and in other circumstances may return an error even if devicetree data exists. Why and how is that better than before ? Seems to me it just introduces a whole number of new failure conditions.

Guenter

#3 lore raw

Hi,

Quoted 7 lines · Guenter Roeck
Quoted 6 lines · Jonathan Cameron
Quoted 5 lines · Ivan T. Ivanov

Do not overwrite error codes returned from of_iio_channel_get(). Error codes are used to distinguish between "io-channel-names" not present in DT bindings, property is optional, and IIO channel provider driver still not being loaded, defer probe.

Quoted 7 lines
Quoted 7 lines
Quoted 1 line

Cc'd Guenter who often takes an interest in this code (and wrote it ;)

Mostly seems logical to me, though I don't like the change of priority in the last bit. I've also just taken a fix for this code so there may be some fuzz from that once it's propogated through to mainline and back to the togreg tree of iio.git

It is propagated, but exactly this patch [1] is causing the troubles :-)

Quoted 71 lines
Quoted 71 lines

Thanks,

Jonathan

Quoted 67 lines
---
 drivers/iio/inkern.c | 24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)
drivers/iio/inkern.c +11 -11
index c749700..66a6cde 100644
@@ -162,7 +162,7 @@ err_free_channel:
 static struct iio_channel *of_iio_channel_get_by_name(struct device_node *np,
 						      const char *name)
 {
-	struct iio_channel *chan = NULL;
+	struct iio_channel *chan = ERR_PTR(-ENODEV);
 
 	/* Walk up the tree of devices looking for a matching iio channel */
 	while (np) {
@@ -183,7 +183,7 @@ static struct iio_channel *of_iio_channel_get_by_name(struct device_node *np,
 		else if (name && index >= 0) {
 			pr_err("ERROR: could not get IIO channel %s:%s(%i)\n",
 				np->full_name, name ? name : "", index);
-			return NULL;
+			break;
 		}
 
 		/*
@@ -193,7 +193,7 @@ static struct iio_channel *of_iio_channel_get_by_name(struct device_node *np,
 		 */
 		np = np->parent;
 		if (np && !of_get_property(np, "io-channel-ranges", NULL))
-			return NULL;
+			break;
 	}
 
 	return chan;
@@ -243,12 +243,12 @@ error_free_chans:
 static inline struct iio_channel *
 of_iio_channel_get_by_name(struct device_node *np, const char *name)
 {
-	return NULL;
+	return ERR_PTR(-ENODEV);
 }
 
 static inline struct iio_channel *of_iio_channel_get_all(struct device *dev)
 {
-	return NULL;
+	return ERR_PTR(-ENODEV);
 }
 
 #endif /* CONFIG_OF */
@@ -312,14 +312,14 @@ struct iio_channel *iio_channel_get(struct device *dev,
 	const char *name = dev ? dev_name(dev) : NULL;
 	struct iio_channel *channel;
 
-	if (dev) {
-		channel = of_iio_channel_get_by_name(dev->of_node,
-						     channel_name);
-		if (channel != NULL)
-			return channel;
-	}
+	channel = iio_channel_get_sys(name, channel_name);
+	if (!IS_ERR(channel))
+		return channel;
+
+	if (!dev)
+		return channel;
 
Quoted 5 lines
Quoted 5 lines

drivers/iio/inkern.c struct iio_channel *iio_channel_get(struct device *dev, · line 323

Quoted 3 lines
drivers/iio/inkern.c +1 -1
-	return iio_channel_get_sys(name, channel_name);
+	return of_iio_channel_get_by_name(dev->of_node, channel_name);
 }

Why reorder the logic? This makes this patch less obviously
correct for limited obvious gain?

I would like to avoid white listing EPROBE_DEFER error code on return of of_get() function.

Quoted 5 lines
Quoted 5 lines

Previously the priority was clearly given to device tree bindings wherease now it is given to board file provided map elements. It would be interesting to see boards with both provided, but it is possible.

I see.

Quoted 3 lines

I am not entirely sure I understand what problem this patch is supposed to fix on top of the patch you just applied,

Patch [1], Guenter please fix you date, introduce regression. It breaks deferred probe mechanism.

Quoted 3 lines

and I am also a bit concerned
about reversing the logic. Also, iio_channel_get_sys can return -ENOMEM and -EINVAL besides -ENODEV, all of which is now being ignored

Yes, and thats why we continue with trying to find channel using OF.

Quoted 1 line

unless dev is set, and then it is returned unconditionally.

If dev is not valid there is no point to go and ask OF layer for channel, so jut go out with error code from get_sys()

Quoted 6 lines

So instead of ignoring error
codes from of_iio_channel_get_by_name, the code now ignores error codes from iio_channel_get_sys under some circumstances (which, coincidentially, does not return -EPROBE_DEFER), and in other circumstances may return an error even if devicetree data exists. Why and how is that better than before ? Seems to me it just introduces a whole number of new failure conditions.

We should not mask error codes from OF layer. EPROBE_DEFER is one of them. So instead of checking for them explicitly on return from of_iio_get(), I decided that will be future proof if I just reverse the order of functions.

Another, less intrusive, solution will be if we revert last patch and explicitly check for EPROBE_DEFER on of_ by_name() return. How this sounds?

Regards,
Ivan

[1] commit a2c12493ed7e63a18cef33a71686d12ffcd6600e

Author: Adam Thomson <[email protected]>
Date:   Thu Nov 6 12:11:00 2014 +0000

iio: of_iio_channel_get_by_name() returns non-null pointers for error legs

#4 lore raw
Quoted 2 lines · Ivan T. Ivanov

Hi,

[ ... ]

Quoted 4 lines

Another, less intrusive, solution will be if we revert last patch and explicitly check for EPROBE_DEFER on of_ by_name() return. How this sounds?

How is that different to the just accepted patch ?

Guenter

#5 lore raw
Quoted 9 lines · Guenter Roeck
Quoted 2 lines · Ivan T. Ivanov

Hi,

[ ... ]

Quoted 4 lines

Another, less intrusive, solution will be if we revert last patch and explicitly check for EPROBE_DEFER on of_ by_name() return. How this sounds?

How is that different to the just accepted patch ?

You mean this one[1]. I have prepared fix last Friday and forget to check again before posting it, sorry. Please ignore my patch.

Thanks,
Ivan

[1] iio:inkern: fix overwritten -EPROBE_DEFER in of_iio_channel_get_by_name

#6 lore raw

T24gQXVndXN0IDI2LCAyMDE0IDE0OjQ4LCBJdmFuIFQuIEl2YW5vdiB3cm90ZToNCg0KPiBPbiBU dWUsIDIwMTQtMDgtMjYgYXQgMDY6MjUgLTA3MDAsIEd1ZW50ZXIgUm9lY2sgd3JvdGU6DQo+ID4g T24gMDgvMjYvMjAxNCAxMjo1MSBBTSwgSXZhbiBULiBJdmFub3Ygd3JvdGU6DQo+ID4gPiBIaSwN Cj4gPiA+DQo+ID4gWyAuLi4gXQ0KPiA+ID4NCj4gPiA+IEFub3RoZXIsIGxlc3MgaW50cnVzaXZl LCBzb2x1dGlvbiB3aWxsIGJlIGlmIHdlIHJldmVydCBsYXN0IHBhdGNoIGFuZCBle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GlhbmNlIG9uIGl0LCBpcyBwcm9o aWJpdGVkIGFuZCBtYXkgYmUgdW5sYXdmdWwuDQoNClBsZWFzZSBjb25zaWRlciB0aGUgZW52aXJv bm1lbnQgYmVmb3JlIHByaW50aW5nIHRoaXMgZS1tYWlsDQoNCg0K

maintainer
#8 lore raw
Quoted 60 lines · Adam Thomson
Quoted 27 lines · Adam Thomson
Quoted 11 lines · Ivan T. Ivanov
Quoted 9 lines · Guenter Roeck
Quoted 2 lines · Ivan T. Ivanov

Hi,

[ ... ]

Quoted 4 lines

Another, less intrusive, solution will be if we revert last patch and explicitly check for EPROBE_DEFER on of_ by_name() return. How this sounds?

How is that different to the just accepted patch ?

Quoted 8 lines

You mean this one[1]. I have prepared fix last Friday and forget to check again before posting it, sorry. Please ignore my patch.

Thanks,
Ivan

[1] iio:inkern: fix overwritten -EPROBE_DEFER in of_iio_channel_get_by_name

Apologies on my part for fixing one problem and introducing another. Didn't see that in my testing, and missed that potential return value when examining the code. At the time It looked like the parent function would only expect NULL pointers for failure, especially given the non CONFIG_OF definitions of the functions. Should've delved further. :(

Quoted 19 lines · Adam Thomson
Quoted 17 lines · Ivan T. Ivanov
Quoted 9 lines · Guenter Roeck
Quoted 2 lines · Ivan T. Ivanov

Hi,

[ ... ]

Quoted 4 lines

Another, less intrusive, solution will be if we revert last patch and explicitly check for EPROBE_DEFER on of_ by_name() return. How this sounds?

How is that different to the just accepted patch ?

You mean this one[1]. I have prepared fix last Friday and forget to check again before posting it, sorry. Please ignore my patch.

Thanks,
Ivan

Quoted 8 lines
Quoted 2 lines

[1] iio:inkern: fix overwritten -EPROBE_DEFER in of_iio_channel_get_by_name

Apologies on my part for fixing one problem and introducing another. Didn't see that in my testing, and missed that potential return value when examining the code. At the time It looked like the parent function would only expect NULL pointers for failure, especially given the non CONFIG_OF definitions of the functions. Should've delved further. :(

Quoted 8 lines

In testing patch code for one of our devices, I've verified what Guenter mentioned previously in this thread, in that iio_channel_get_sys() doesn't return -EPROBE_DEFER. This means that drivers using the default map approach of accessing IIO channels will fail to instantiate as they do not know they need to defer their probe (have seen this with my driver too).

Haven't looked in detail yet as to how, but I guess this is something that will also need to be addressed.

Yes, that stuff (I think) predates deferred probing and no one has gotten around to bringing it up to date as yet.

All contributions welcome!

J

Quoted 5 lines

Legal Disclaimer: This e-mail communication (and any attachment/s) is confidential and contains proprietary information, some or all of which may be legally privileged. It is intended solely for the use of the individual or entity to which it is addressed. Access to this email by anyone else is unauthorized. If you are not the intended recipient, any disclosure, copying, distribution or any action taken or omitted to be taken in reliance on it, is prohibited and may be unlawful.

Please consider the environment before printing this e-mail