* [PATCH] pinctrl: aw9523: use devm_mutex_init
@ 2024-10-03 21:47 Rosen Penev
2024-10-04 7:44 ` Linus Walleij
0 siblings, 1 reply; 2+ messages in thread
From: Rosen Penev @ 2024-10-03 21:47 UTC (permalink / raw)
To: linux-gpio; +Cc: Linus Walleij, open list
Simplifies probe by removing all gotos and removing mutex_destroy from
_remove.
Signed-off-by: Rosen Penev <rosenp@gmail.com>
---
drivers/pinctrl/pinctrl-aw9523.c | 36 ++++++++++++--------------------
1 file changed, 13 insertions(+), 23 deletions(-)
diff --git a/drivers/pinctrl/pinctrl-aw9523.c b/drivers/pinctrl/pinctrl-aw9523.c
index f6df8d32225b..5cb24c1dcb0d 100644
--- a/drivers/pinctrl/pinctrl-aw9523.c
+++ b/drivers/pinctrl/pinctrl-aw9523.c
@@ -976,18 +976,19 @@ static int aw9523_probe(struct i2c_client *client)
if (awi->vio_vreg && awi->vio_vreg != -ENODEV)
return awi->vio_vreg;
- mutex_init(&awi->i2c_lock);
+ ret = devm_mutex_init(dev, &awi->i2c_lock);
+ if (ret)
+ return ret;
+
lockdep_set_subclass(&awi->i2c_lock, i2c_adapter_depth(client->adapter));
pdesc = devm_kzalloc(dev, sizeof(*pdesc), GFP_KERNEL);
- if (!pdesc) {
- ret = -ENOMEM;
- goto err_disable_vregs;
- }
+ if (!pdesc)
+ return -ENOMEM;
ret = aw9523_hw_init(awi);
if (ret)
- goto err_disable_vregs;
+ return ret;
pdesc->name = dev_name(dev);
pdesc->owner = THIS_MODULE;
@@ -999,29 +1000,20 @@ static int aw9523_probe(struct i2c_client *client)
ret = aw9523_init_gpiochip(awi, pdesc->npins);
if (ret)
- goto err_disable_vregs;
+ return ret;
if (client->irq) {
ret = aw9523_init_irq(awi, client->irq);
if (ret)
- goto err_disable_vregs;
+ return ret;
}
awi->pctl = devm_pinctrl_register(dev, pdesc, awi);
- if (IS_ERR(awi->pctl)) {
- ret = dev_err_probe(dev, PTR_ERR(awi->pctl), "Cannot register pinctrl");
- goto err_disable_vregs;
- }
-
- ret = devm_gpiochip_add_data(dev, &awi->gpio, awi);
- if (ret)
- goto err_disable_vregs;
+ if (IS_ERR(awi->pctl))
+ return dev_err_probe(dev, PTR_ERR(awi->pctl),
+ "Cannot register pinctrl");
- return ret;
-
-err_disable_vregs:
- mutex_destroy(&awi->i2c_lock);
- return ret;
+ return devm_gpiochip_add_data(dev, &awi->gpio, awi);
}
static void aw9523_remove(struct i2c_client *client)
@@ -1039,8 +1031,6 @@ static void aw9523_remove(struct i2c_client *client)
aw9523_hw_init(awi);
mutex_unlock(&awi->i2c_lock);
}
-
- mutex_destroy(&awi->i2c_lock);
}
static const struct i2c_device_id aw9523_i2c_id_table[] = {
--
2.46.2
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] pinctrl: aw9523: use devm_mutex_init
2024-10-03 21:47 [PATCH] pinctrl: aw9523: use devm_mutex_init Rosen Penev
@ 2024-10-04 7:44 ` Linus Walleij
0 siblings, 0 replies; 2+ messages in thread
From: Linus Walleij @ 2024-10-04 7:44 UTC (permalink / raw)
To: Rosen Penev; +Cc: linux-gpio, open list
On Thu, Oct 3, 2024 at 11:47 PM Rosen Penev <rosenp@gmail.com> wrote:
> Simplifies probe by removing all gotos and removing mutex_destroy from
> _remove.
>
> Signed-off-by: Rosen Penev <rosenp@gmail.com>
Patch applied!
As it depended on the patch already in fixes I first cherry-picked
that patch, I suppose this is one of these few occasions where
we can allow ourselves to apply the same patch in fixes
and -next, as it is so small.
Git will figure it out textually anyway.
Yours,
Linus Walleij
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-10-04 7:45 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-03 21:47 [PATCH] pinctrl: aw9523: use devm_mutex_init Rosen Penev
2024-10-04 7:44 ` Linus Walleij
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).