spi: wpcm-fiu: Check the error of the SHM syscon lookup
Subsystems (2)
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.
---
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 ofgit://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
@@ -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);