Commit 9e878dbc authored by Nuno Sá's avatar Nuno Sá Committed by Jonathan Cameron

iio: inkern: fix return value in devm_of_iio_channel_get_by_name()

of_iio_channel_get_by_name() can either return NULL or an error pointer
so that only doing IS_ERR() is not enough. Fix it by checking the NULL
pointer case and return -ENODEV in that case. Note this is done like this
so that users of the function (which only check for error pointers) do
not need to be changed. This is not ideal since we are losing error codes
and as such, in a follow up change, things will be unified so that
of_iio_channel_get_by_name() only returns error codes.

Fixes: 6e39b145 ("iio: provide of_iio_channel_get_by_name() and devm_ version it")
Signed-off-by: default avatarNuno Sá <nuno.sa@analog.com>
Reviewed-by: default avatarAndy Shevchenko <andy.shevchenko@gmail.com>
Link: https://lore.kernel.org/r/20220715122903.332535-3-nuno.sa@analog.comSigned-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
parent 79c3e848
......@@ -412,6 +412,8 @@ struct iio_channel *devm_of_iio_channel_get_by_name(struct device *dev,
channel = of_iio_channel_get_by_name(np, channel_name);
if (IS_ERR(channel))
return channel;
if (!channel)
return ERR_PTR(-ENODEV);
ret = devm_add_action_or_reset(dev, devm_iio_channel_free, channel);
if (ret)
......
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