* [PATCH] gpio: ljca: use devm_mutex_init() to simplify the error path and remove()
@ 2024-10-08 16:24 Bartosz Golaszewski
2024-10-11 19:49 ` Linus Walleij
2024-10-14 8:31 ` Bartosz Golaszewski
0 siblings, 2 replies; 3+ messages in thread
From: Bartosz Golaszewski @ 2024-10-08 16:24 UTC (permalink / raw)
To: Linus Walleij; +Cc: linux-gpio, linux-kernel, Bartosz Golaszewski
From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Destroying the mutexes is done at the end of remove() so switching to
devres does not constitute a functional change. Use devm_mutex_init()
and remove repetitions of mutex_destroy().
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
---
drivers/gpio/gpio-ljca.c | 17 +++++++++--------
1 file changed, 9 insertions(+), 8 deletions(-)
diff --git a/drivers/gpio/gpio-ljca.c b/drivers/gpio/gpio-ljca.c
index dfec9fbfc7a9..d67b912d884d 100644
--- a/drivers/gpio/gpio-ljca.c
+++ b/drivers/gpio/gpio-ljca.c
@@ -420,8 +420,14 @@ static int ljca_gpio_probe(struct auxiliary_device *auxdev,
if (!ljca_gpio->connect_mode)
return -ENOMEM;
- mutex_init(&ljca_gpio->irq_lock);
- mutex_init(&ljca_gpio->trans_lock);
+ ret = devm_mutex_init(&auxdev->dev, &ljca_gpio->irq_lock);
+ if (ret)
+ return ret;
+
+ ret = devm_mutex_init(&auxdev->dev, &ljca_gpio->trans_lock);
+ if (ret)
+ return ret;
+
ljca_gpio->gc.direction_input = ljca_gpio_direction_input;
ljca_gpio->gc.direction_output = ljca_gpio_direction_output;
ljca_gpio->gc.get_direction = ljca_gpio_get_direction;
@@ -453,11 +459,8 @@ static int ljca_gpio_probe(struct auxiliary_device *auxdev,
INIT_WORK(&ljca_gpio->work, ljca_gpio_async);
ret = gpiochip_add_data(&ljca_gpio->gc, ljca_gpio);
- if (ret) {
+ if (ret)
ljca_unregister_event_cb(ljca);
- mutex_destroy(&ljca_gpio->irq_lock);
- mutex_destroy(&ljca_gpio->trans_lock);
- }
return ret;
}
@@ -469,8 +472,6 @@ static void ljca_gpio_remove(struct auxiliary_device *auxdev)
gpiochip_remove(&ljca_gpio->gc);
ljca_unregister_event_cb(ljca_gpio->ljca);
cancel_work_sync(&ljca_gpio->work);
- mutex_destroy(&ljca_gpio->irq_lock);
- mutex_destroy(&ljca_gpio->trans_lock);
}
static const struct auxiliary_device_id ljca_gpio_id_table[] = {
--
2.43.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] gpio: ljca: use devm_mutex_init() to simplify the error path and remove()
2024-10-08 16:24 [PATCH] gpio: ljca: use devm_mutex_init() to simplify the error path and remove() Bartosz Golaszewski
@ 2024-10-11 19:49 ` Linus Walleij
2024-10-14 8:31 ` Bartosz Golaszewski
1 sibling, 0 replies; 3+ messages in thread
From: Linus Walleij @ 2024-10-11 19:49 UTC (permalink / raw)
To: Bartosz Golaszewski; +Cc: linux-gpio, linux-kernel, Bartosz Golaszewski
On Tue, Oct 8, 2024 at 6:24 PM Bartosz Golaszewski <brgl@bgdev.pl> wrote:
> From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
>
> Destroying the mutexes is done at the end of remove() so switching to
> devres does not constitute a functional change. Use devm_mutex_init()
> and remove repetitions of mutex_destroy().
>
> Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Yours,
Linus Walleij
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] gpio: ljca: use devm_mutex_init() to simplify the error path and remove()
2024-10-08 16:24 [PATCH] gpio: ljca: use devm_mutex_init() to simplify the error path and remove() Bartosz Golaszewski
2024-10-11 19:49 ` Linus Walleij
@ 2024-10-14 8:31 ` Bartosz Golaszewski
1 sibling, 0 replies; 3+ messages in thread
From: Bartosz Golaszewski @ 2024-10-14 8:31 UTC (permalink / raw)
To: Linus Walleij, Bartosz Golaszewski
Cc: Bartosz Golaszewski, linux-gpio, linux-kernel
From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
On Tue, 08 Oct 2024 18:24:16 +0200, Bartosz Golaszewski wrote:
> Destroying the mutexes is done at the end of remove() so switching to
> devres does not constitute a functional change. Use devm_mutex_init()
> and remove repetitions of mutex_destroy().
>
>
Applied, thanks!
[1/1] gpio: ljca: use devm_mutex_init() to simplify the error path and remove()
commit: 476f18c0895df7b281eb84b3e687e6101c844338
Best regards,
--
Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-10-14 8:31 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-08 16:24 [PATCH] gpio: ljca: use devm_mutex_init() to simplify the error path and remove() Bartosz Golaszewski
2024-10-11 19:49 ` Linus Walleij
2024-10-14 8:31 ` Bartosz Golaszewski
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.