Skip to contentSkip to conversation

spi: wpcm-fiu: Check the error of the SHM syscon lookup

PATCH New Anton Protopopov 1 participant 1 message Dec 1

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 spi: wpcm-fiu: Check the error of the SHM syscon lookup

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)")

---

It's one of three related changes, but for different trees.
See https://lore.kernel.org/linux-pci/[email protected]/

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(+)
drivers/spi/spi-wpcm-fiu.c +3 -0
index 884e5042bad5..6dd77a8de00b 100644
@@ -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);