From: Patrick Rudolph <patrick.rudolph@9elements.com>
To: Patrick Rudolph <patrick.rudolph@9elements.com>,
Linus Walleij <linus.walleij@linaro.org>
Cc: naresh.solanki@9elements.com, andy.shevchenko@gmail.com,
broonie@kernel.org, linux-gpio@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: [PATCH 1/2] pinctrl: cy8c95x0: Use cleanup.h
Date: Wed, 26 Jun 2024 10:45:22 +0200 [thread overview]
Message-ID: <20240626084525.787298-1-patrick.rudolph@9elements.com> (raw)
Use the guard mutex from cleanup.h to make the code more readable.
Signed-off-by: Patrick Rudolph <patrick.rudolph@9elements.com>
---
drivers/pinctrl/pinctrl-cy8c95x0.c | 13 ++++---------
1 file changed, 4 insertions(+), 9 deletions(-)
diff --git a/drivers/pinctrl/pinctrl-cy8c95x0.c b/drivers/pinctrl/pinctrl-cy8c95x0.c
index 4efb8b5cc2d3..781949e0e09e 100644
--- a/drivers/pinctrl/pinctrl-cy8c95x0.c
+++ b/drivers/pinctrl/pinctrl-cy8c95x0.c
@@ -9,6 +9,7 @@
#include <linux/acpi.h>
#include <linux/bitmap.h>
+#include <linux/cleanup.h>
#include <linux/dmi.h>
#include <linux/gpio/driver.h>
#include <linux/gpio/consumer.h>
@@ -480,8 +481,6 @@ static inline int cy8c95x0_regmap_update_bits_base(struct cy8c95x0_pinctrl *chip
if (reg == CY8C95X0_PORTSEL)
return -EINVAL;
- mutex_lock(&chip->i2c_lock);
-
/* Registers behind the PORTSEL mux have their own range in regmap */
if (cy8c95x0_muxed_register(reg)) {
off = CY8C95X0_MUX_REGMAP_TO_OFFSET(reg, port);
@@ -492,10 +491,11 @@ static inline int cy8c95x0_regmap_update_bits_base(struct cy8c95x0_pinctrl *chip
else
off = reg;
}
+ guard(mutex)(&chip->i2c_lock);
ret = regmap_update_bits_base(chip->regmap, off, mask, val, change, async, force);
if (ret < 0)
- goto out;
+ return ret;
/* Update the cache when a WC bit is written */
if (cy8c95x0_wc_register(reg) && (mask & val)) {
@@ -516,8 +516,6 @@ static inline int cy8c95x0_regmap_update_bits_base(struct cy8c95x0_pinctrl *chip
regcache_cache_only(chip->regmap, false);
}
}
-out:
- mutex_unlock(&chip->i2c_lock);
return ret;
}
@@ -591,8 +589,6 @@ static int cy8c95x0_regmap_read(struct cy8c95x0_pinctrl *chip, unsigned int reg,
{
int off, ret;
- mutex_lock(&chip->i2c_lock);
-
/* Registers behind the PORTSEL mux have their own range in regmap */
if (cy8c95x0_muxed_register(reg)) {
off = CY8C95X0_MUX_REGMAP_TO_OFFSET(reg, port);
@@ -603,11 +599,10 @@ static int cy8c95x0_regmap_read(struct cy8c95x0_pinctrl *chip, unsigned int reg,
else
off = reg;
}
+ guard(mutex)(&chip->i2c_lock);
ret = regmap_read(chip->regmap, off, read_val);
- mutex_unlock(&chip->i2c_lock);
-
return ret;
}
--
2.44.0
next reply other threads:[~2024-06-26 8:45 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-26 8:45 Patrick Rudolph [this message]
2024-06-26 8:45 ` [PATCH 2/2] pinctrl: cy8c95x0: Update cache modification Patrick Rudolph
2024-07-03 11:15 ` Linus Walleij
2024-07-03 11:14 ` [PATCH 1/2] pinctrl: cy8c95x0: Use cleanup.h 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=20240626084525.787298-1-patrick.rudolph@9elements.com \
--to=patrick.rudolph@9elements.com \
--cc=andy.shevchenko@gmail.com \
--cc=broonie@kernel.org \
--cc=linus.walleij@linaro.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=naresh.solanki@9elements.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