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: provide and use gpiod_line_state_notify()
Date: Mon, 21 Aug 2023 18:33:56 +0300	[thread overview]
Message-ID: <ZOOD5BrhsX3O6TQG@smile.fi.intel.com> (raw)
In-Reply-To: <20230821141827.18061-1-brgl@bgdev.pl>

On Mon, Aug 21, 2023 at 04:18:27PM +0200, Bartosz Golaszewski wrote:
> From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
> 
> Wrap the calls to blocking_notifier_call_chain() for the line state
> notifier with a helper that allows us to use fewer lines of code and
> simpler syntax.

This change I like, no questions asked.
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

> Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
> ---
>  drivers/gpio/gpiolib-cdev.c | 17 +++++------------
>  drivers/gpio/gpiolib.c      | 12 ++++++++----
>  drivers/gpio/gpiolib.h      |  1 +
>  3 files changed, 14 insertions(+), 16 deletions(-)
> 
> diff --git a/drivers/gpio/gpiolib-cdev.c b/drivers/gpio/gpiolib-cdev.c
> index 35dcaf78aed6..e39d344feb28 100644
> --- a/drivers/gpio/gpiolib-cdev.c
> +++ b/drivers/gpio/gpiolib-cdev.c
> @@ -230,9 +230,7 @@ static long linehandle_set_config(struct linehandle_state *lh,
>  				return ret;
>  		}
>  
> -		blocking_notifier_call_chain(&desc->gdev->line_state_notifier,
> -					     GPIO_V2_LINE_CHANGED_CONFIG,
> -					     desc);
> +		gpiod_line_state_notify(desc, GPIO_V2_LINE_CHANGED_CONFIG);
>  	}
>  	return 0;
>  }
> @@ -414,8 +412,7 @@ static int linehandle_create(struct gpio_device *gdev, void __user *ip)
>  				goto out_free_lh;
>  		}
>  
> -		blocking_notifier_call_chain(&desc->gdev->line_state_notifier,
> -					     GPIO_V2_LINE_CHANGED_REQUESTED, desc);
> +		gpiod_line_state_notify(desc, GPIO_V2_LINE_CHANGED_REQUESTED);
>  
>  		dev_dbg(&gdev->dev, "registered chardev handle for line %d\n",
>  			offset);
> @@ -1420,9 +1417,7 @@ static long linereq_set_config_unlocked(struct linereq *lr,
>  
>  		WRITE_ONCE(line->edflags, edflags);
>  
> -		blocking_notifier_call_chain(&desc->gdev->line_state_notifier,
> -					     GPIO_V2_LINE_CHANGED_CONFIG,
> -					     desc);
> +		gpiod_line_state_notify(desc, GPIO_V2_LINE_CHANGED_CONFIG);
>  	}
>  	return 0;
>  }
> @@ -1737,8 +1732,7 @@ static int linereq_create(struct gpio_device *gdev, void __user *ip)
>  
>  		lr->lines[i].edflags = edflags;
>  
> -		blocking_notifier_call_chain(&desc->gdev->line_state_notifier,
> -					     GPIO_V2_LINE_CHANGED_REQUESTED, desc);
> +		gpiod_line_state_notify(desc, GPIO_V2_LINE_CHANGED_REQUESTED);
>  
>  		dev_dbg(&gdev->dev, "registered chardev handle for line %d\n",
>  			offset);
> @@ -2156,8 +2150,7 @@ static int lineevent_create(struct gpio_device *gdev, void __user *ip)
>  	if (ret)
>  		goto out_free_le;
>  
> -	blocking_notifier_call_chain(&desc->gdev->line_state_notifier,
> -				     GPIO_V2_LINE_CHANGED_REQUESTED, desc);
> +	gpiod_line_state_notify(desc, GPIO_V2_LINE_CHANGED_REQUESTED);
>  
>  	irq = gpiod_to_irq(desc);
>  	if (irq <= 0) {
> diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
> index 0737952882cd..43162fd71d92 100644
> --- a/drivers/gpio/gpiolib.c
> +++ b/drivers/gpio/gpiolib.c
> @@ -2160,8 +2160,7 @@ static bool gpiod_free_commit(struct gpio_desc *desc)
>  	}
>  
>  	spin_unlock_irqrestore(&gpio_lock, flags);
> -	blocking_notifier_call_chain(&desc->gdev->line_state_notifier,
> -				     GPIOLINE_CHANGED_RELEASED, desc);
> +	gpiod_line_state_notify(desc, GPIOLINE_CHANGED_RELEASED);
>  
>  	return ret;
>  }
> @@ -3729,6 +3728,12 @@ int gpiod_set_array_value_cansleep(unsigned int array_size,
>  }
>  EXPORT_SYMBOL_GPL(gpiod_set_array_value_cansleep);
>  
> +void gpiod_line_state_notify(struct gpio_desc *desc, unsigned long action)
> +{
> +	blocking_notifier_call_chain(&desc->gdev->line_state_notifier,
> +				     action, desc);

action can be on previous line, but this is the logical split, so fine as is.

> +}
> +
>  /**
>   * gpiod_add_lookup_table() - register GPIO device consumers
>   * @table: table of consumers to register
> @@ -3996,8 +4001,7 @@ static struct gpio_desc *gpiod_find_and_request(struct device *consumer,
>  		return ERR_PTR(ret);
>  	}
>  
> -	blocking_notifier_call_chain(&desc->gdev->line_state_notifier,
> -				     GPIOLINE_CHANGED_REQUESTED, desc);
> +	gpiod_line_state_notify(desc, GPIOLINE_CHANGED_REQUESTED);
>  
>  	return desc;
>  }
> diff --git a/drivers/gpio/gpiolib.h b/drivers/gpio/gpiolib.h
> index 54012605b4a4..0d81ac3bbb40 100644
> --- a/drivers/gpio/gpiolib.h
> +++ b/drivers/gpio/gpiolib.h
> @@ -146,6 +146,7 @@ int gpiod_set_array_value_complex(bool raw, bool can_sleep,
>  extern spinlock_t gpio_lock;
>  extern struct list_head gpio_devices;
>  
> +void gpiod_line_state_notify(struct gpio_desc *desc, unsigned long action);
>  
>  /**
>   * struct gpio_desc - Opaque descriptor for a GPIO
> -- 
> 2.39.2
> 

-- 
With Best Regards,
Andy Shevchenko



  reply	other threads:[~2023-08-21 15:34 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-21 14:18 [PATCH] gpiolib: provide and use gpiod_line_state_notify() Bartosz Golaszewski
2023-08-21 15:33 ` Andy Shevchenko [this message]
2023-08-23  8:30 ` Linus Walleij

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=ZOOD5BrhsX3O6TQG@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