From: Linus Walleij <linusw@kernel.org>
To: Stephan Gerhold <stephan@gerhold.net>,
Liam Girdwood <lgirdwood@gmail.com>,
Mark Brown <broonie@kernel.org>, Axel Lin <axel.lin@ingics.com>,
Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>, Lee Jones <lee@kernel.org>
Cc: devicetree@vger.kernel.org, mfd@lists.linux.dev,
Linus Walleij <linusw@kernel.org>
Subject: [PATCH v2 11/13] regulator: ab8500: Use scoped guard for shared mode mutex
Date: Tue, 01 Sep 2026 22:02:16 +0200 [thread overview]
Message-ID: <20260901-ux500-dts-snowball-regulator-v2-11-fe88b01829bf@kernel.org> (raw)
In-Reply-To: <20260901-ux500-dts-snowball-regulator-v2-0-fe88b01829bf@kernel.org>
Use a scoped mutex guard in ab8500_regulator_set_mode().
Assisted-by: LLM
Signed-off-by: Linus Walleij <linusw@kernel.org>
---
drivers/regulator/ab8500.c | 23 ++++++++---------------
1 file changed, 8 insertions(+), 15 deletions(-)
diff --git a/drivers/regulator/ab8500.c b/drivers/regulator/ab8500.c
index 57ef3d4610e6..3c1962ad85d4 100644
--- a/drivers/regulator/ab8500.c
+++ b/drivers/regulator/ab8500.c
@@ -20,6 +20,7 @@
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/err.h>
+#include <linux/mutex.h>
#include <linux/platform_device.h>
#include <linux/mfd/abx500.h>
#include <linux/mfd/abx500/ab8500.h>
@@ -542,6 +543,8 @@ static int ab8500_regulator_set_mode(struct regulator_dev *rdev,
return -EINVAL;
}
+ guard(mutex)(&shared_mode_mutex);
+
if (info->mode_mask) {
bank = info->mode_bank;
reg = info->mode_reg;
@@ -552,9 +555,6 @@ static int ab8500_regulator_set_mode(struct regulator_dev *rdev,
mask = info->update_mask;
}
- if (info->shared_mode)
- mutex_lock(&shared_mode_mutex);
-
switch (mode) {
case REGULATOR_MODE_NORMAL:
if (info->shared_mode)
@@ -573,7 +573,7 @@ static int ab8500_regulator_set_mode(struct regulator_dev *rdev,
if (!shared_regulator->shared_mode->lp_mode_req) {
/* Other regulator prevent LP mode */
info->shared_mode->lp_mode_req = true;
- goto out_unlock;
+ return 0;
}
lp_mode_req = true;
@@ -585,18 +585,15 @@ static int ab8500_regulator_set_mode(struct regulator_dev *rdev,
val = info->update_val_idle;
break;
default:
- ret = -EINVAL;
- goto out_unlock;
+ return -EINVAL;
}
if (info->mode_mask) {
enabled = 1;
} else {
enabled = ab8500_regulator_is_enabled(rdev);
- if (enabled < 0) {
- ret = enabled;
- goto out_unlock;
- }
+ if (enabled < 0)
+ return enabled;
}
if (enabled) {
@@ -605,7 +602,7 @@ static int ab8500_regulator_set_mode(struct regulator_dev *rdev,
if (ret < 0) {
dev_err(rdev_get_dev(rdev),
"couldn't set regulator mode\n");
- goto out_unlock;
+ return ret;
}
dev_vdbg(rdev_get_dev(rdev),
@@ -621,10 +618,6 @@ static int ab8500_regulator_set_mode(struct regulator_dev *rdev,
if (info->shared_mode)
info->shared_mode->lp_mode_req = lp_mode_req;
-out_unlock:
- if (info->shared_mode)
- mutex_unlock(&shared_mode_mutex);
-
return ret;
}
--
2.55.0
next prev parent reply other threads:[~2026-09-01 20:02 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-01 20:02 [PATCH v2 00/13] Add AB8500 buck regulators to the Ux500 device tree Linus Walleij
2026-09-01 20:02 ` [PATCH v2 01/13] regulator: ab8500: Fix AB8505 VANA voltage selectors Linus Walleij
2026-09-01 20:09 ` sashiko-bot
2026-09-01 20:02 ` [PATCH v2 02/13] regulator: ab8500: Add AB8505 VAUX3 3.05 V setting Linus Walleij
2026-09-01 20:08 ` sashiko-bot
2026-09-01 20:02 ` [PATCH v2 03/13] regulator: ab8500: Handle AB8505 VINTCORE selector 7 Linus Walleij
2026-09-01 20:15 ` sashiko-bot
2026-09-01 20:02 ` [PATCH v2 04/13] regulator: ab8500: Treat cut 1.0 VAUX3 as fixed Linus Walleij
2026-09-01 20:17 ` sashiko-bot
2026-09-01 20:02 ` [PATCH v2 05/13] regulator: ab8500: Test dedicated enable bits only Linus Walleij
2026-09-01 20:21 ` sashiko-bot
2026-09-01 20:02 ` [PATCH v2 06/13] regulator: ab8500: Propagate mode enable read errors Linus Walleij
2026-09-01 20:26 ` sashiko-bot
2026-09-01 20:02 ` [PATCH v2 07/13] regulator: ab8500: Use linear ranges for LDO voltages Linus Walleij
2026-09-01 20:27 ` sashiko-bot
2026-09-01 20:02 ` [PATCH v2 08/13] dt-bindings: mfd: ab8500: Add regulators Linus Walleij
2026-09-01 20:30 ` sashiko-bot
2026-09-01 20:02 ` [PATCH v2 09/13] regulator: ab8500: Add buck converter support Linus Walleij
2026-09-01 20:31 ` sashiko-bot
2026-09-01 20:02 ` [PATCH v2 10/13] regulator: ab8500: Preserve OTP-enabled buck regulators Linus Walleij
2026-09-01 20:38 ` sashiko-bot
2026-09-01 20:02 ` Linus Walleij [this message]
2026-09-01 20:37 ` [PATCH v2 11/13] regulator: ab8500: Use scoped guard for shared mode mutex sashiko-bot
2026-09-01 20:02 ` [PATCH v2 12/13] ARM: dts: ux500: Add new AB8500/AB8505 regulators Linus Walleij
2026-09-01 20:41 ` sashiko-bot
2026-09-01 20:02 ` [PATCH v2 13/13] ARM: dts: ux500: Fix up regulator assignments Linus Walleij
2026-09-01 20:45 ` sashiko-bot
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=20260901-ux500-dts-snowball-regulator-v2-11-fe88b01829bf@kernel.org \
--to=linusw@kernel.org \
--cc=axel.lin@ingics.com \
--cc=broonie@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=krzk+dt@kernel.org \
--cc=lee@kernel.org \
--cc=lgirdwood@gmail.com \
--cc=mfd@lists.linux.dev \
--cc=robh@kernel.org \
--cc=stephan@gerhold.net \
/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