mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [RFC] spi: spi-fsl-qspi: fix dev_request_mem_resource() usage
@ 2024-06-18 21:33 Antony Pavlov
  2024-07-01 13:18 ` Sascha Hauer
  0 siblings, 1 reply; 2+ messages in thread
From: Antony Pavlov @ 2024-06-18 21:33 UTC (permalink / raw)
  To: barebox; +Cc: Steffen Trumtrar, Ahmad Fatoum

Here is the code from drivers/spi/spi-fsl-qspi.c:

> res = dev_request_mem_resource(dev, 0);
> q->iobase = IOMEM(res->start);
> if (IS_ERR(q->iobase)) {
>         ret = PTR_ERR(q->iobase);
>         goto err_put_ctrl;
> }

res can contain error code (not a pointer)
so we can't use IOMEM(res->start) just after
res = dev_request_mem_resource(dev, 0) call.

Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
---
 drivers/spi/spi-fsl-qspi.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/spi/spi-fsl-qspi.c b/drivers/spi/spi-fsl-qspi.c
index 17e6d1df867..d242035ee00 100644
--- a/drivers/spi/spi-fsl-qspi.c
+++ b/drivers/spi/spi-fsl-qspi.c
@@ -800,15 +800,13 @@ static int fsl_qspi_probe(struct device *dev)
 	spi_controller_set_devdata(ctlr, q);
 
 	/* find the resources */
-	res = dev_request_mem_resource(dev, 0);
-	q->iobase = IOMEM(res->start);
+	q->iobase = dev_request_mem_region(dev, 0);
 	if (IS_ERR(q->iobase)) {
 		ret = PTR_ERR(q->iobase);
 		goto err_put_ctrl;
 	}
 
-	res = dev_request_mem_resource(dev, 1);
-	q->ahb_addr = IOMEM(res->start);
+	q->ahb_addr = dev_platform_get_and_ioremap_resource(dev, 1, &res);
 	if (IS_ERR(q->ahb_addr)) {
 		ret = PTR_ERR(q->ahb_addr);
 		goto err_put_ctrl;
-- 
2.39.0




^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-07-01 13:20 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-06-18 21:33 [RFC] spi: spi-fsl-qspi: fix dev_request_mem_resource() usage Antony Pavlov
2024-07-01 13:18 ` Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox