mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Anton Protopopov <a.s.protopopov@gmail.com>
To: "Jonathan Neuschäfer" <j.neuschaefer@gmx.net>,
	"Mark Brown" <broonie@kernel.org>,
	openbmc@lists.ozlabs.org, linux-spi@vger.kernel.org,
	linux-kernel@vger.kernel.org
Cc: Anton Protopopov <a.s.protopopov@gmail.com>,
	Bjorn Helgaas <bhelgaas@google.com>
Subject: [PATCH] spi: wpcm-fiu: Check the error of the SHM syscon lookup
Date: Tue,  1 Dec 2026 11:34:05 +0000	[thread overview]
Message-ID: <20261201113408.342584-1-a.s.protopopov@gmail.com> (raw)

The syscon_regmap_lookup_by_phandle_optional() function returns NULL
only when the property is missing (-ENODEV). On other errors it
returns an error pointer. The wpcm_fiu_probe() function stores it in
fiu->shm_regmap and wpcm_fiu_stall_host() checks only for NULL. It
passes the error pointer to regmap_update_bits(), which leads to an
oops on the first operation.

The lookup may fail with a correct device tree too: it returns
-EPROBE_DEFER when the hwspinlock of the syscon or the driver which
registers its regmap is not probed yet. Return the error from the
probe, so that it is retried.

Fixes: 1f8811a2613e ("spi: wpcm-fiu: Add driver for Nuvoton WPCM450 Flash Interface Unit (FIU)")
Suggested-by: Bjorn Helgaas <bhelgaas@google.com>
Signed-off-by: Anton Protopopov <a.s.protopopov@gmail.com>
---

It's one of three related changes, but for different trees.
See https://lore.kernel.org/linux-pci/20261127101915.1348807-1-a.s.protopopov@gmail.com/

This applies to the for-next and for-linus branches of
git://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git

 drivers/spi/spi-wpcm-fiu.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/spi/spi-wpcm-fiu.c b/drivers/spi/spi-wpcm-fiu.c
index 884e5042bad5..6dd77a8de00b 100644
--- a/drivers/spi/spi-wpcm-fiu.c
+++ b/drivers/spi/spi-wpcm-fiu.c
@@ -464,6 +464,9 @@ static int wpcm_fiu_probe(struct platform_device *pdev)
 
 	fiu->memory_size = min_t(size_t, resource_size(res), MAX_MEMORY_SIZE_TOTAL);
 	fiu->shm_regmap = syscon_regmap_lookup_by_phandle_optional(dev->of_node, "nuvoton,shm");
+	if (IS_ERR(fiu->shm_regmap))
+		return dev_err_probe(dev, PTR_ERR(fiu->shm_regmap),
+				     "Failed to look up SHM syscon\n");
 
 	wpcm_fiu_hw_init(fiu);
 

                 reply	other threads:[~2026-12-01 11:22 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=20261201113408.342584-1-a.s.protopopov@gmail.com \
    --to=a.s.protopopov@gmail.com \
    --cc=bhelgaas@google.com \
    --cc=broonie@kernel.org \
    --cc=j.neuschaefer@gmx.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-spi@vger.kernel.org \
    --cc=openbmc@lists.ozlabs.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®