mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
To: Srinivas Kandagatla <srini@kernel.org>,
	Bartosz Golaszewski <brgl@kernel.org>
Cc: linux-kernel@vger.kernel.org,
	Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
Subject: [PATCH 3/7] nvmem: check the return value of gpiod_set_value_cansleep()
Date: Fri, 16 Jan 2026 12:01:10 +0100	[thread overview]
Message-ID: <20260116-nvmem-unbind-v1-3-7bb401ab19a8@oss.qualcomm.com> (raw)
In-Reply-To: <20260116-nvmem-unbind-v1-0-7bb401ab19a8@oss.qualcomm.com>

GPIO setters now return integer values and can indicate failures in
lower abstraction layers. Check the return values of
gpiod_set_value_cansleep() calls in nvmem core.

Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
---
 drivers/nvmem/core.c | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c
index c4a5f8ef65164ef6994343e6d26d3d302c9b00c3..454e0645d1545602cd193f66b54bd5c5811ca5ed 100644
--- a/drivers/nvmem/core.c
+++ b/drivers/nvmem/core.c
@@ -64,16 +64,22 @@ static int __nvmem_reg_read(struct nvmem_device *nvmem, unsigned int offset,
 static int __nvmem_reg_write(struct nvmem_device *nvmem, unsigned int offset,
 			     void *val, size_t bytes)
 {
-	int ret;
+	int ret, written;
 
 	if (!nvmem->reg_write)
 		return -EOPNOTSUPP;
 
-	gpiod_set_value_cansleep(nvmem->wp_gpio, 0);
-	ret = nvmem->reg_write(nvmem->priv, offset, val, bytes);
-	gpiod_set_value_cansleep(nvmem->wp_gpio, 1);
+	ret = gpiod_set_value_cansleep(nvmem->wp_gpio, 0);
+	if (ret)
+		return ret;
 
-	return ret;
+	written = nvmem->reg_write(nvmem->priv, offset, val, bytes);
+
+	ret = gpiod_set_value_cansleep(nvmem->wp_gpio, 1);
+	if (ret)
+		return ret;
+
+	return written;
 }
 
 static int nvmem_access_with_keepouts(struct nvmem_device *nvmem,

-- 
2.47.3


  parent reply	other threads:[~2026-01-16 11:01 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-16 11:01 [PATCH 0/7] nvmem: survive unbind with active consumers Bartosz Golaszewski
2026-01-16 11:01 ` [PATCH 1/7] nvmem: remove unused field from struct nvmem_device Bartosz Golaszewski
2026-01-16 11:01 ` [PATCH 2/7] nvmem: return -EOPNOTSUPP to in-kernel users on missing callbacks Bartosz Golaszewski
2026-01-16 11:01 ` Bartosz Golaszewski [this message]
2026-01-16 11:01 ` [PATCH 4/7] nvmem: simplify locking with guard() Bartosz Golaszewski
2026-01-16 11:01 ` [PATCH 5/7] nvmem: remove unneeded __nvmem_device_put() Bartosz Golaszewski
2026-01-16 11:01 ` [PATCH 6/7] nvmem: split struct nvmem_device into refcounted and provider-owned data Bartosz Golaszewski
2026-01-16 11:01 ` [PATCH 7/7] nvmem: synchronize nvmem device unregistering with SRCU Bartosz Golaszewski
2026-01-21  9:18   ` Bartosz Golaszewski
2026-01-19 11:22 ` [PATCH 0/7] nvmem: survive unbind with active consumers Johan Hovold
2026-01-19 12:43   ` Bartosz Golaszewski
2026-01-20 10:18     ` Johan Hovold
2026-01-20 19:57       ` Bartosz Golaszewski
2026-01-21 15:42         ` Johan Hovold

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=20260116-nvmem-unbind-v1-3-7bb401ab19a8@oss.qualcomm.com \
    --to=bartosz.golaszewski@oss.qualcomm.com \
    --cc=brgl@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=srini@kernel.org \
    /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

all inboxes | Powered by JetHome®