From: Bartosz Golaszewski <brgl@bgdev.pl>
To: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: Linus Walleij <linus.walleij@linaro.org>,
Kent Gibson <warthog618@gmail.com>,
Viresh Kumar <viresh.kumar@linaro.org>,
Geert Uytterhoeven <geert@linux-m68k.org>,
linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org,
Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Subject: Re: [RFC PATCH] gpio: consumer: new virtual driver
Date: Mon, 7 Aug 2023 21:46:35 +0200 [thread overview]
Message-ID: <CAMRc=MebFDbkLLucmL_7dHBDOyRh3nQ1w3nLtsV8fVAQjaG_wQ@mail.gmail.com> (raw)
In-Reply-To: <ZM1YW025tD6S/y+Q@smile.fi.intel.com>
On Fri, Aug 4, 2023 at 9:58 PM Andy Shevchenko
<andriy.shevchenko@linux.intel.com> wrote:
>
> On Fri, Aug 04, 2023 at 06:03:47PM +0200, Bartosz Golaszewski wrote:
> > On Thu, Aug 3, 2023 at 1:39 PM Andy Shevchenko
> > <andriy.shevchenko@linux.intel.com> wrote:
>
> ...
>
> > > > + if (list_empty(&dev->lookup_list))
> > > > + return -ENODATA;
> > >
> > > Instead you may count nodes here and if 0, return an error, otherwise pass it
> > > to the callee.
> >
> > I'm not following, please rephrase.
>
> The below call calls list_count_nodes(), you may simply join these two checks
> by calling list_count_nodes() and return -ENODATA in case it's 0.
>
We don't gain anything by doing that: list_empty() doesn't count
nodes, it just checks the head pointer. We would decrease readability
(more arguments!) for no reason.
Bart
> > > > + swnode = gpio_consumer_make_device_swnode(dev);
> > > > + if (IS_ERR(swnode))
> > > > + return PTR_ERR(swnode);
>
> ...
>
> > > > + if ((!live && !gpio_consumer_device_is_live_unlocked(dev)) ||
> > > > + (live && gpio_consumer_device_is_live_unlocked(dev)))
> > >
> > > if (live ^ gpio_consumer_device_is_live_unlocked(dev))
> > >
> > > ?
> >
> > Nah, let's not use bitwise operators for boolean logic.
>
> Then it's even simpler:
>
> if (live == gpio_consumer_device_is_live_unlocked(dev))
>
> --
> With Best Regards,
> Andy Shevchenko
>
>
prev parent reply other threads:[~2023-08-07 19:47 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-02 15:28 [RFC PATCH] gpio: consumer: new virtual driver Bartosz Golaszewski
2023-08-02 22:51 ` Linus Walleij
2023-08-03 11:38 ` Andy Shevchenko
2023-08-04 16:03 ` Bartosz Golaszewski
2023-08-04 19:58 ` Andy Shevchenko
2023-08-07 19:46 ` Bartosz Golaszewski [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAMRc=MebFDbkLLucmL_7dHBDOyRh3nQ1w3nLtsV8fVAQjaG_wQ@mail.gmail.com' \
--to=brgl@bgdev.pl \
--cc=andriy.shevchenko@linux.intel.com \
--cc=bartosz.golaszewski@linaro.org \
--cc=geert@linux-m68k.org \
--cc=linus.walleij@linaro.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=viresh.kumar@linaro.org \
--cc=warthog618@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).