linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Bartosz Golaszewski <brgl@bgdev.pl>
To: Liam Girdwood <lgirdwood@gmail.com>,
	Mark Brown <broonie@kernel.org>,
	 Jaroslav Kysela <perex@perex.cz>, Takashi Iwai <tiwai@suse.com>,
	 Linus Walleij <linus.walleij@linaro.org>,
	 Bartosz Golaszewski <brgl@bgdev.pl>,
	 Peter Ujfalusi <peter.ujfalusi@gmail.com>,
	 Oder Chiou <oder_chiou@realtek.com>,
	Shenghao Ding <shenghao-ding@ti.com>,  Kevin Lu <kevin-lu@ti.com>,
	Baojun Xu <baojun.xu@ti.com>,
	 Herve Codina <herve.codina@bootlin.com>,
	 David Rhodes <david.rhodes@cirrus.com>,
	 Richard Fitzgerald <rf@opensource.cirrus.com>
Cc: linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org,
	 linux-gpio@vger.kernel.org, patches@opensource.cirrus.com,
	 Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Subject: [PATCH 08/12] ASoC: codecs: idt821034: use new GPIO line value setter callbacks
Date: Tue, 08 Apr 2025 09:38:26 +0200	[thread overview]
Message-ID: <20250408-gpiochip-set-rv-sound-v1-8-dd54b6ca1ef9@linaro.org> (raw)
In-Reply-To: <20250408-gpiochip-set-rv-sound-v1-0-dd54b6ca1ef9@linaro.org>

From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>

struct gpio_chip now has callbacks for setting line values that return
an integer, allowing to indicate failures. Convert the driver to using
them.

Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
---
 sound/soc/codecs/idt821034.c | 19 ++++++++++++-------
 1 file changed, 12 insertions(+), 7 deletions(-)

diff --git a/sound/soc/codecs/idt821034.c b/sound/soc/codecs/idt821034.c
index cb7a68c799f8..55e90604bbaa 100644
--- a/sound/soc/codecs/idt821034.c
+++ b/sound/soc/codecs/idt821034.c
@@ -957,7 +957,8 @@ static const struct snd_soc_component_driver idt821034_component_driver = {
 #define IDT821034_GPIO_OFFSET_TO_SLIC_CHANNEL(_offset) (((_offset) / 5) % 4)
 #define IDT821034_GPIO_OFFSET_TO_SLIC_MASK(_offset)    BIT((_offset) % 5)
 
-static void idt821034_chip_gpio_set(struct gpio_chip *c, unsigned int offset, int val)
+static int idt821034_chip_gpio_set(struct gpio_chip *c, unsigned int offset,
+				   int val)
 {
 	u8 ch = IDT821034_GPIO_OFFSET_TO_SLIC_CHANNEL(offset);
 	u8 mask = IDT821034_GPIO_OFFSET_TO_SLIC_MASK(offset);
@@ -973,12 +974,14 @@ static void idt821034_chip_gpio_set(struct gpio_chip *c, unsigned int offset, in
 	else
 		slic_raw &= ~mask;
 	ret = idt821034_write_slic_raw(idt821034, ch, slic_raw);
-	if (ret) {
-		dev_err(&idt821034->spi->dev, "set gpio %d (%u, 0x%x) failed (%d)\n",
-			offset, ch, mask, ret);
-	}
 
 	mutex_unlock(&idt821034->mutex);
+
+	if (ret)
+		dev_err(&idt821034->spi->dev, "set gpio %d (%u, 0x%x) failed (%d)\n",
+			offset, ch, mask, ret);
+
+	return ret;
 }
 
 static int idt821034_chip_gpio_get(struct gpio_chip *c, unsigned int offset)
@@ -1054,7 +1057,9 @@ static int idt821034_chip_direction_output(struct gpio_chip *c, unsigned int off
 	u8 slic_conf;
 	int ret;
 
-	idt821034_chip_gpio_set(c, offset, val);
+	ret = idt821034_chip_gpio_set(c, offset, val);
+	if (ret)
+		return ret;
 
 	mutex_lock(&idt821034->mutex);
 
@@ -1112,7 +1117,7 @@ static int idt821034_gpio_init(struct idt821034 *idt821034)
 	idt821034->gpio_chip.direction_input = idt821034_chip_direction_input;
 	idt821034->gpio_chip.direction_output = idt821034_chip_direction_output;
 	idt821034->gpio_chip.get = idt821034_chip_gpio_get;
-	idt821034->gpio_chip.set = idt821034_chip_gpio_set;
+	idt821034->gpio_chip.set_rv = idt821034_chip_gpio_set;
 	idt821034->gpio_chip.can_sleep = true;
 
 	return devm_gpiochip_add_data(&idt821034->spi->dev, &idt821034->gpio_chip,

-- 
2.45.2


  parent reply	other threads:[~2025-04-08  7:38 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-08  7:38 [PATCH 00/12] ASoC: convert GPIO chips to using new value setters Bartosz Golaszewski
2025-04-08  7:38 ` [PATCH 01/12] ASoC: soc-ac97: use new GPIO line value setter callbacks Bartosz Golaszewski
2025-04-08  7:38 ` [PATCH 02/12] ASoC: ti: davinci-mcasp:: " Bartosz Golaszewski
2025-04-08  7:38 ` [PATCH 03/12] ASoC: codecs: wm8962: " Bartosz Golaszewski
2025-04-08  7:38 ` [PATCH 04/12] ASoC: codecs: wm5100: " Bartosz Golaszewski
2025-04-08  7:38 ` [PATCH 05/12] ASoC: codecs: rt5677: " Bartosz Golaszewski
2025-04-08  7:38 ` [PATCH 06/12] ASoC: codecs: wm8996: " Bartosz Golaszewski
2025-04-08  7:38 ` [PATCH 07/12] ASoC: codecs: tlv320adc3xxx: " Bartosz Golaszewski
2025-04-08  7:38 ` Bartosz Golaszewski [this message]
2025-04-08  8:16   ` [PATCH 08/12] ASoC: codecs: idt821034: " Herve Codina
2025-04-08  7:38 ` [PATCH 09/12] ASoC: codecs: peb2466: " Bartosz Golaszewski
2025-04-08  8:18   ` Herve Codina
2025-04-08  7:38 ` [PATCH 10/12] ASoC: codecs: wm8903: " Bartosz Golaszewski
2025-04-08  7:38 ` [PATCH 11/12] ASoC: codecs: zl38060: " Bartosz Golaszewski
2025-04-08  7:38 ` [PATCH 12/12] ALSA: hda: cirrus_scodec_test: " Bartosz Golaszewski
2025-04-08 12:25 ` [PATCH 00/12] ASoC: convert GPIO chips to using new value setters Charles Keepax
2025-04-14 13:56 ` Mark Brown

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=20250408-gpiochip-set-rv-sound-v1-8-dd54b6ca1ef9@linaro.org \
    --to=brgl@bgdev.pl \
    --cc=baojun.xu@ti.com \
    --cc=bartosz.golaszewski@linaro.org \
    --cc=broonie@kernel.org \
    --cc=david.rhodes@cirrus.com \
    --cc=herve.codina@bootlin.com \
    --cc=kevin-lu@ti.com \
    --cc=lgirdwood@gmail.com \
    --cc=linus.walleij@linaro.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-sound@vger.kernel.org \
    --cc=oder_chiou@realtek.com \
    --cc=patches@opensource.cirrus.com \
    --cc=perex@perex.cz \
    --cc=peter.ujfalusi@gmail.com \
    --cc=rf@opensource.cirrus.com \
    --cc=shenghao-ding@ti.com \
    --cc=tiwai@suse.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;
as well as URLs for NNTP newsgroup(s).