Commit a2c12493 authored by Adam Thomson's avatar Adam Thomson Committed by Jonathan Cameron

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

Currently in the inkern.c code for IIO framework, the function
of_iio_channel_get_by_name() will return a non-NULL pointer when
it cannot find a channel using of_iio_channel_get() and when it
tries to search for 'io-channel-ranges' property and fails. This
is incorrect behaviour as the function which calls this expects
a NULL pointer for failure. This patch rectifies the issue.
Signed-off-by: default avatarAdam Thomson <Adam.Thomson.Opensource@diasemi.com>
Signed-off-by: default avatarJonathan Cameron <jic23@kernel.org>
Cc: Stable@vger.kernel.org
parent b70e19c2
...@@ -183,7 +183,7 @@ static struct iio_channel *of_iio_channel_get_by_name(struct device_node *np, ...@@ -183,7 +183,7 @@ static struct iio_channel *of_iio_channel_get_by_name(struct device_node *np,
else if (name && index >= 0) { else if (name && index >= 0) {
pr_err("ERROR: could not get IIO channel %s:%s(%i)\n", pr_err("ERROR: could not get IIO channel %s:%s(%i)\n",
np->full_name, name ? name : "", index); np->full_name, name ? name : "", index);
return chan; return NULL;
} }
/* /*
...@@ -193,8 +193,9 @@ static struct iio_channel *of_iio_channel_get_by_name(struct device_node *np, ...@@ -193,8 +193,9 @@ static struct iio_channel *of_iio_channel_get_by_name(struct device_node *np,
*/ */
np = np->parent; np = np->parent;
if (np && !of_get_property(np, "io-channel-ranges", NULL)) if (np && !of_get_property(np, "io-channel-ranges", NULL))
break; return NULL;
} }
return chan; return chan;
} }
...@@ -317,6 +318,7 @@ struct iio_channel *iio_channel_get(struct device *dev, ...@@ -317,6 +318,7 @@ struct iio_channel *iio_channel_get(struct device *dev,
if (channel != NULL) if (channel != NULL)
return channel; return channel;
} }
return iio_channel_get_sys(name, channel_name); return iio_channel_get_sys(name, channel_name);
} }
EXPORT_SYMBOL_GPL(iio_channel_get); EXPORT_SYMBOL_GPL(iio_channel_get);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment