mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] gpio: pisosr: Use devm_mutex_init()
@ 2025-09-07 13:25 Christophe JAILLET
  2025-09-07 14:09 ` Andrew Davis
  2025-09-08  7:38 ` Bartosz Golaszewski
  0 siblings, 2 replies; 3+ messages in thread
From: Christophe JAILLET @ 2025-09-07 13:25 UTC (permalink / raw)
  To: Linus Walleij, Bartosz Golaszewski
  Cc: linux-kernel, kernel-janitors, Christophe JAILLET, linux-gpio

Use devm_mutex_init() instead of hand-writing it.

This saves some LoC, improves readability and saves some space in the
generated .o file.

Before:
======
   text	   data	    bss	    dec	    hex	filename
   8431	   1808	    192	  10431	   28bf	drivers/gpio/gpio-pisosr.o

After:
=====
   text	   data	    bss	    dec	    hex	filename
   8112	   1736	    192	  10040	   2738	drivers/gpio/gpio-pisosr.o

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
 drivers/gpio/gpio-pisosr.c | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/drivers/gpio/gpio-pisosr.c b/drivers/gpio/gpio-pisosr.c
index a69b74866a13..7ec6a46ed600 100644
--- a/drivers/gpio/gpio-pisosr.c
+++ b/drivers/gpio/gpio-pisosr.c
@@ -108,11 +108,6 @@ static const struct gpio_chip template_chip = {
 	.can_sleep		= true,
 };
 
-static void pisosr_mutex_destroy(void *lock)
-{
-	mutex_destroy(lock);
-}
-
 static int pisosr_gpio_probe(struct spi_device *spi)
 {
 	struct device *dev = &spi->dev;
@@ -139,8 +134,7 @@ static int pisosr_gpio_probe(struct spi_device *spi)
 		return dev_err_probe(dev, PTR_ERR(gpio->load_gpio),
 				     "Unable to allocate load GPIO\n");
 
-	mutex_init(&gpio->lock);
-	ret = devm_add_action_or_reset(dev, pisosr_mutex_destroy, &gpio->lock);
+	ret = devm_mutex_init(dev, &gpio->lock);
 	if (ret)
 		return ret;
 
-- 
2.51.0


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] gpio: pisosr: Use devm_mutex_init()
  2025-09-07 13:25 [PATCH] gpio: pisosr: Use devm_mutex_init() Christophe JAILLET
@ 2025-09-07 14:09 ` Andrew Davis
  2025-09-08  7:38 ` Bartosz Golaszewski
  1 sibling, 0 replies; 3+ messages in thread
From: Andrew Davis @ 2025-09-07 14:09 UTC (permalink / raw)
  To: Christophe JAILLET, Linus Walleij, Bartosz Golaszewski
  Cc: linux-kernel, kernel-janitors, linux-gpio

On 9/7/25 8:25 AM, Christophe JAILLET wrote:
> Use devm_mutex_init() instead of hand-writing it.
> 
> This saves some LoC, improves readability and saves some space in the
> generated .o file.
> 
> Before:
> ======
>     text	   data	    bss	    dec	    hex	filename
>     8431	   1808	    192	  10431	   28bf	drivers/gpio/gpio-pisosr.o
> 
> After:
> =====
>     text	   data	    bss	    dec	    hex	filename
>     8112	   1736	    192	  10040	   2738	drivers/gpio/gpio-pisosr.o
> 
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> ---

Acked-by: Andrew Davis <afd@ti.com>

>   drivers/gpio/gpio-pisosr.c | 8 +-------
>   1 file changed, 1 insertion(+), 7 deletions(-)
> 
> diff --git a/drivers/gpio/gpio-pisosr.c b/drivers/gpio/gpio-pisosr.c
> index a69b74866a13..7ec6a46ed600 100644
> --- a/drivers/gpio/gpio-pisosr.c
> +++ b/drivers/gpio/gpio-pisosr.c
> @@ -108,11 +108,6 @@ static const struct gpio_chip template_chip = {
>   	.can_sleep		= true,
>   };
>   
> -static void pisosr_mutex_destroy(void *lock)
> -{
> -	mutex_destroy(lock);
> -}
> -
>   static int pisosr_gpio_probe(struct spi_device *spi)
>   {
>   	struct device *dev = &spi->dev;
> @@ -139,8 +134,7 @@ static int pisosr_gpio_probe(struct spi_device *spi)
>   		return dev_err_probe(dev, PTR_ERR(gpio->load_gpio),
>   				     "Unable to allocate load GPIO\n");
>   
> -	mutex_init(&gpio->lock);
> -	ret = devm_add_action_or_reset(dev, pisosr_mutex_destroy, &gpio->lock);
> +	ret = devm_mutex_init(dev, &gpio->lock);
>   	if (ret)
>   		return ret;
>   


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] gpio: pisosr: Use devm_mutex_init()
  2025-09-07 13:25 [PATCH] gpio: pisosr: Use devm_mutex_init() Christophe JAILLET
  2025-09-07 14:09 ` Andrew Davis
@ 2025-09-08  7:38 ` Bartosz Golaszewski
  1 sibling, 0 replies; 3+ messages in thread
From: Bartosz Golaszewski @ 2025-09-08  7:38 UTC (permalink / raw)
  To: Linus Walleij, Bartosz Golaszewski, Christophe JAILLET
  Cc: Bartosz Golaszewski, linux-kernel, kernel-janitors, linux-gpio

From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>


On Sun, 07 Sep 2025 15:25:38 +0200, Christophe JAILLET wrote:
> Use devm_mutex_init() instead of hand-writing it.
> 
> This saves some LoC, improves readability and saves some space in the
> generated .o file.
> 
> Before:
> ======
>    text	   data	    bss	    dec	    hex	filename
>    8431	   1808	    192	  10431	   28bf	drivers/gpio/gpio-pisosr.o
> 
> [...]

Applied, thanks!

[1/1] gpio: pisosr: Use devm_mutex_init()
      https://git.kernel.org/brgl/linux/c/474014cdec1758e1802082b94043189e198c58a4

Best regards,
-- 
Bartosz Golaszewski <bartosz.golaszewski@linaro.org>

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-09-08  7:39 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-09-07 13:25 [PATCH] gpio: pisosr: Use devm_mutex_init() Christophe JAILLET
2025-09-07 14:09 ` Andrew Davis
2025-09-08  7:38 ` Bartosz Golaszewski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®