[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAMRc=McqgWLxDWG5AveDzTabHhaLnF2f36iAyzAx8ktVUMJj+Q@mail.gmail.com>
Date: Thu, 24 Aug 2023 10:47:13 +0200
From: Bartosz Golaszewski <brgl@...ev.pl>
To: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
Cc: Linus Walleij <linus.walleij@...aro.org>,
Kent Gibson <warthog618@...il.com>, linux-gpio@...r.kernel.org,
linux-kernel@...r.kernel.org,
Bartosz Golaszewski <bartosz.golaszewski@...aro.org>
Subject: Re: [PATCH] gpiolib: notify user-space about line state changes
triggered by kernel
On Mon, Aug 21, 2023 at 12:43 PM Andy Shevchenko
<andriy.shevchenko@...ux.intel.com> wrote:
>
> On Fri, Aug 18, 2023 at 09:09:44PM +0200, Bartosz Golaszewski wrote:
> > From: Bartosz Golaszewski <bartosz.golaszewski@...aro.org>
>
> Interestingly why you keep submitter and author different...
>
> > We currently only emit CHANGED_CONFIG events when the user-space changes
> > GPIO config. We won't be notified if changes come from in-kernel. Let's
> > call the notifier chain whenever kernel users change direction or any of
> > the active-low, debounce or consumer name settings. We don't notify the
> > user-space about the persistence as the uAPI has no notion of it.
>
> ...
>
> > - if (!ret)
> > + if (!ret) {
> > set_bit(FLAG_IS_OUT, &desc->flags);
> > + blocking_notifier_call_chain(&desc->gdev->notifier,
> > + GPIO_V2_LINE_CHANGED_CONFIG,
> > + desc);
> > + }
> > trace_gpio_value(desc_to_gpio(desc), 0, val);
> > trace_gpio_direction(desc_to_gpio(desc), 0, ret);
> > return ret;
>
> The if (!ret) makes me a bit slower to understand as usual pattern to test
> for the errors first.
>
> That said, perhaps
>
> if (ret)
> goto out_trace_event;
>
> set_bit(FLAG_IS_OUT, &desc->flags);
> blocking_notifier_call_chain(&desc->gdev->notifier,
> GPIO_V2_LINE_CHANGED_CONFIG, desc);
>
> out_trace_event:
> trace_gpio_value(desc_to_gpio(desc), 0, val);
> trace_gpio_direction(desc_to_gpio(desc), 0, ret);
> return ret;
>
> ...
>
> > + ret = gpiod_set_config(desc, config);
> > + if (!ret)
> > + blocking_notifier_call_chain(&desc->gdev->notifier,
> > + GPIO_V2_LINE_CHANGED_CONFIG,
> > + desc);
> > + return ret;
>
> Ditto.
>
> ret = gpiod_set_config(desc, config);
> if (ret)
> return ret;
>
> blocking_notifier_call_chain(&desc->gdev->notifier,
> GPIO_V2_LINE_CHANGED_CONFIG, desc);
> return 0;
>
I agree with the latter but the former introduces an unnecessary goto
and looks worse IMO.
Bart
> --
> With Best Regards,
> Andy Shevchenko
>
>
Powered by blists - more mailing lists