[PATCH] spi: spi-nxp-fspi: Fix error checks

Sascha Hauer s.hauer at pengutronix.de
Tue Nov 7 06:15:59 PST 2023


We have to check dev_request_mem_resource() for errors, not the resource
address it returns.

Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
 drivers/spi/spi-nxp-fspi.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/drivers/spi/spi-nxp-fspi.c b/drivers/spi/spi-nxp-fspi.c
index 1d6604fee3..d8675779da 100644
--- a/drivers/spi/spi-nxp-fspi.c
+++ b/drivers/spi/spi-nxp-fspi.c
@@ -993,18 +993,19 @@ static int nxp_fspi_probe(struct device *dev)
 
 	/* find the resources */
 	res = dev_request_mem_resource(dev, 0);
-	f->iobase = IOMEM(res->start);
-	if (IS_ERR(f->iobase)) {
-		ret = PTR_ERR(f->iobase);
+	if (IS_ERR(res)) {
+		ret = PTR_ERR(res);
 		goto err_put_ctrl;
 	}
 
+	f->iobase = IOMEM(res->start);
+
 	res = dev_request_mem_resource(dev, 1);
-	f->ahb_addr = IOMEM(res->start);
-	if (IS_ERR(f->ahb_addr)) {
-		ret = PTR_ERR(f->ahb_addr);
+	if (IS_ERR(res)) {
+		ret = PTR_ERR(res);
 		goto err_put_ctrl;
 	}
+	f->ahb_addr = IOMEM(res->start);
 
 	/* assign memory mapped starting address and mapped size. */
 	f->memmap_phy = res->start;
-- 
2.39.2




More information about the barebox mailing list