Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

spi: lp-8841: return correct error code from probe

The spi_lp8841_rtc_probe() function misses an initialization of the
return code when it fails to get its memory resource, as gcc notices:

drivers/spi/spi-lp8841-rtc.c: In function 'spi_lp8841_rtc_probe':
drivers/spi/spi-lp8841-rtc.c:239:9: error: 'ret' may be used uninitialized in this function [-Werror=maybe-uninitialized]

This changes the code to propagate the error from devm_ioremap_resource().

Fixes: 7ecbfff6711f ("spi: master driver to enable RTC on ICPDAS LP-8841")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Tested-by: Sergei Ianovich <ynvich@gmail.com>
Signed-off-by: Mark Brown <broonie@kernel.org>

authored by

Arnd Bergmann and committed by
Mark Brown
14a20428 7ecbfff6

+3 -2
+3 -2
drivers/spi/spi-lp8841-rtc.c
··· 217 217 data = spi_master_get_devdata(master); 218 218 219 219 iomem = platform_get_resource(pdev, IORESOURCE_MEM, 0); 220 - data->iomem = devm_ioremap_resource(&pdev->dev, iomem); 221 - if (IS_ERR(data->iomem)) { 220 + data->iomem = devm_ioremap_resource(&pdev->dev, iomem); 221 + ret = PTR_ERR_OR_ZERO(data->iomem); 222 + if (ret) { 222 223 dev_err(&pdev->dev, "failed to get IO address\n"); 223 224 goto err_put_master; 224 225 }