public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Bartosz Golaszewski <brgl@bgdev.pl>
Cc: Linus Walleij <linus.walleij@linaro.org>,
	Kent Gibson <warthog618@gmail.com>,
	linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org,
	Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Subject: Re: [PATCH] gpiolib: notify user-space about line state changes triggered by kernel
Date: Mon, 21 Aug 2023 13:43:51 +0300	[thread overview]
Message-ID: <ZOM/59nLZwNWrha2@smile.fi.intel.com> (raw)
In-Reply-To: <20230818190944.22177-1-brgl@bgdev.pl>

On Fri, Aug 18, 2023 at 09:09:44PM +0200, Bartosz Golaszewski wrote:
> From: Bartosz Golaszewski <bartosz.golaszewski@linaro.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;

-- 
With Best Regards,
Andy Shevchenko



  reply	other threads:[~2023-08-21 10:43 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-18 19:09 [PATCH] gpiolib: notify user-space about line state changes triggered by kernel Bartosz Golaszewski
2023-08-21 10:43 ` Andy Shevchenko [this message]
2023-08-24  8:47   ` Bartosz Golaszewski

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=ZOM/59nLZwNWrha2@smile.fi.intel.com \
    --to=andriy.shevchenko@linux.intel.com \
    --cc=bartosz.golaszewski@linaro.org \
    --cc=brgl@bgdev.pl \
    --cc=linus.walleij@linaro.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.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