Message ID | 20220711123835.811358-1-nuno.sa@analog.com (mailing list archive) |
---|---|
Headers | show |
Series | make iio inkern interface firmware agnostic | expand |
On Mon, 2022-07-11 at 15:22 +0200, Andy Shevchenko wrote: > On Mon, Jul 11, 2022 at 2:38 PM Nuno Sá <nuno.sa@analog.com> wrote: > > > > First version of the series can be found here: > > > > https://lore.kernel.org/linux-iio/20220610084545.547700-1-nuno.sa@analog.com/ > > I'm under the impression that I gave tags for some of these patches > when they were the part of the bigger series. Am I wrong? > In any case for patch 6-14, > Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com> Yes, you're right. Should I have dropped them? - Nuno Sá
On Mon, 2022-07-11 at 15:29 +0200, Andy Shevchenko wrote: > On Mon, Jul 11, 2022 at 2:38 PM Nuno Sá <nuno.sa@analog.com> wrote: > > > > APIs like of_iio_channel_get_by_name() and of_iio_channel_get_all() > > were > > returning a mix of NULL and pointers with NULL being the way to > > "notify" that we should do a "system" lookup for channels. This > > make > > it very confusing and prone to errors as commit 9f63cc0921ec > > ("iio: inkern: fix return value in > > devm_of_iio_channel_get_by_name()") > > proves. On top of this, patterns like 'if (channel != NULL) return > > channel' were being used where channel could actually be an error > > code > > which makes the code hard to read. > > > > This change also makes some functional changes on how errors were > > being > > handled. In the original behavior, even if we get an error like '- > > ENOMEM', > > we still continue with the search. We should only continue to > > lookup for > > the channel when it makes sense to do so. Hence, the main error > > handling > > in 'of_iio_channel_get_by_name()' is changed to the following > > logic: > > > > * If a channel 'name' is provided and we do find it via > > 'io-channel-names', we should be able to get it. If we get any > > error, > > we should not proceed with the lookup. Moreover, we should return > > an error > > so that callers won't proceed with a system lookup. > > * If a channel 'name' is provided and we cannot find it ('index < > > 0'), > > 'of_parse_phandle_with_args()' is expected to fail with '-EINVAL'. > > Hence, > > we should only continue if we get that error. > > * If a channel 'name' is not provided we should only carry on with > > the > > search if 'of_parse_phandle_with_args()' returns '-ENOENT'. > > > > Also note that a system channel lookup is only done if the returned > > error code (from 'of_iio_channel_get_by_name()' or > > 'of_iio_channel_get_all()' is -ENODEV. > > LGTM (but I might miss something, it's a bit too many conditionals), > Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com> > Agreed. It ended up being more complicated than I thought... - Nuno Sá