linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] iio: core: Propagate error codes from OF layer to client drivers
@ 2014-08-25 12:57 Ivan T. Ivanov
  2014-08-25 16:10 ` Jonathan Cameron
  0 siblings, 1 reply; 9+ messages in thread
From: Ivan T. Ivanov @ 2014-08-25 12:57 UTC (permalink / raw)
  To: Jonathan Cameron
  Cc: Ivan T. Ivanov, Adam.Thomson.Opensource, knaack.h, lars, pmeerw,
	linux-iio, linux-kernel

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.

Signed-off-by: Ivan T. Ivanov <iivanov@mm-sol.com>
---
 drivers/iio/inkern.c | 24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/drivers/iio/inkern.c b/drivers/iio/inkern.c
index c749700..66a6cde 100644
--- a/drivers/iio/inkern.c
+++ b/drivers/iio/inkern.c
@@ -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);
 
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2014-08-27 17:41 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-08-25 12:57 [PATCH] iio: core: Propagate error codes from OF layer to client drivers Ivan T. Ivanov
2014-08-25 16:10 ` Jonathan Cameron
2014-08-25 16:54   ` Guenter Roeck
2014-08-26  7:51     ` Ivan T. Ivanov
2014-08-26 13:25       ` Guenter Roeck
2014-08-26 13:48         ` Ivan T. Ivanov
2014-08-26 14:35           ` Opensource [Adam Thomson]
2014-08-27 15:59           ` Adam Thomson
2014-08-27 17:41             ` Jonathan Cameron

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).