From: Matti Vaittinen <mazziesaccount@gmail.com>
To: Matti Vaittinen <mazziesaccount@gmail.com>,
Matti Vaittinen <matti.vaittinen@fi.rohmeurope.com>
Cc: Matti Vaittinen <mazziesaccount@gmail.com>,
Jonathan Cameron <jic23@kernel.org>,
Lars-Peter Clausen <lars@metafoo.de>,
linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH] iio: bd79124: Use set_rv and set_multiple_rv
Date: Mon, 7 Apr 2025 10:30:47 +0300 [thread overview]
Message-ID: <Z_N_J52IZ2IaWawl@mva-rohm> (raw)
[-- Attachment #1: Type: text/plain, Size: 2635 bytes --]
The new GPIO callbacks 'set_rv' and 'set_multiple_rv' allow returning a
success code to indicate failures when setting GPIO status. Use them to
allow callers to know when things go south.
Signed-off-by: Matti Vaittinen <mazziesaccount@gmail.com>
---
drivers/iio/adc/rohm-bd79124.c | 23 +++++++++++------------
1 file changed, 11 insertions(+), 12 deletions(-)
diff --git a/drivers/iio/adc/rohm-bd79124.c b/drivers/iio/adc/rohm-bd79124.c
index 13673f4347d4..bb7c93ae4055 100644
--- a/drivers/iio/adc/rohm-bd79124.c
+++ b/drivers/iio/adc/rohm-bd79124.c
@@ -196,17 +196,18 @@ static int bd79124gpo_direction_get(struct gpio_chip *gc, unsigned int offset)
return GPIO_LINE_DIRECTION_OUT;
}
-static void bd79124gpo_set(struct gpio_chip *gc, unsigned int offset, int value)
+static int bd79124gpo_set(struct gpio_chip *gc, unsigned int offset, int value)
{
struct bd79124_data *data = gpiochip_get_data(gc);
- regmap_assign_bits(data->map, BD79124_REG_GPO_VAL, BIT(offset), value);
+ return regmap_assign_bits(data->map, BD79124_REG_GPO_VAL, BIT(offset),
+ value);
}
-static void bd79124gpo_set_multiple(struct gpio_chip *gc, unsigned long *mask,
+static int bd79124gpo_set_multiple(struct gpio_chip *gc, unsigned long *mask,
unsigned long *bits)
{
- unsigned int all_gpos, set_gpos;
+ unsigned int all_gpos;
int ret;
struct bd79124_data *data = gpiochip_get_data(gc);
@@ -219,17 +220,15 @@ static void bd79124gpo_set_multiple(struct gpio_chip *gc, unsigned long *mask,
*/
ret = regmap_read(data->map, BD79124_REG_PINCFG, &all_gpos);
if (ret)
- return;
+ return ret;
if (all_gpos ^ *mask) {
dev_dbg(data->dev, "Invalid mux config. Can't set value.\n");
- /* Do not set value for pins configured as ADC inputs */
- set_gpos = *mask & all_gpos;
- } else {
- set_gpos = *mask;
+
+ return -EINVAL;
}
- regmap_update_bits(data->map, BD79124_REG_GPO_VAL, set_gpos, *bits);
+ return regmap_update_bits(data->map, BD79124_REG_GPO_VAL, *mask, *bits);
}
static int bd79124_init_valid_mask(struct gpio_chip *gc,
@@ -247,8 +246,8 @@ static int bd79124_init_valid_mask(struct gpio_chip *gc,
static const struct gpio_chip bd79124gpo_chip = {
.label = "bd79124-gpo",
.get_direction = bd79124gpo_direction_get,
- .set = bd79124gpo_set,
- .set_multiple = bd79124gpo_set_multiple,
+ .set_rv = bd79124gpo_set,
+ .set_multiple_rv = bd79124gpo_set_multiple,
.init_valid_mask = bd79124_init_valid_mask,
.can_sleep = true,
.ngpio = 8,
base-commit: e3ee177e2a3e21ef4502f68336023154049d2acd
--
2.49.0
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
reply other threads:[~2025-04-07 7:30 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=Z_N_J52IZ2IaWawl@mva-rohm \
--to=mazziesaccount@gmail.com \
--cc=jic23@kernel.org \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=matti.vaittinen@fi.rohmeurope.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