dma: ti: k3-udma: Fix error handling for setup_resources() in udma_probe()
Subsystems (2)
PATCH 1/1 dma: ti: k3-udma: Fix error handling for setup_resources() in udma_probe()
In udma_probe() the return value of setup_resources() is stored in the u32 "ch_count" member of "struct udma_dev", due to which any negative return value which indicates an error is masked.
Fix this by storing the return value of setup_resources() in the already declared integer variable "ret", followed by assigning it to the "ch_count" member of "struct udma_dev" in case of no error.
While at it, change the "return ret" at the end of udma_probe() to a "return 0", to explicitly indicate that probe was successful.
---
Hello,
This patch is based on commit9e00b6993f Merge tag 'u-boot-dfu-20240215' of https://source.denx.de/u-boot/custodians/u-boot-dfu
of the master branch of U-Boot.
Regards,
Siddharth.
drivers/dma/ti/k3-udma.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
drivers/dma/ti/k3-udma.c +6 -4
@@ -1770,9 +1770,11 @@ static int udma_probe(struct udevice *dev)return PTR_ERR (ud->ringacc); ud->dev = dev; - ud->ch_count =setup_resources (ud); -if (ud->ch_count <=0 ) -return ud->ch_count; + ret =setup_resources (ud); +if (ret <=0 ) +return ret; + + ud->ch_count = ret;for (i =0 ; i < ud->bchan_cnt; i++) {struct udma_bchan *bchan = &ud->bchans[i];
@@ -1831,7 +1833,7 @@ static int udma_probe(struct udevice *dev) uc_priv->supported =DMA_SUPPORTS_MEM_TO_MEM |DMA_SUPPORTS_MEM_TO_DEV ; -return ret; +return 0 ; }static int udma_push_to_ring (struct k3_nav_ring *ring,void *elem)
Signature · 1 line
2.34.1
Quoted 5 lines · Siddharth Vadapalli
drivers/dma/ti/k3-udma.c +0
-0
drivers/dma/ti/k3-udma.c static int udma_probe(struct udevice *dev) · line 1775
Quoted 9 lines
drivers/dma/ti/k3-udma.c +3
-3@@ -1770,9 +1770,11 @@ static int udma_probe(struct udevice *dev)return PTR_ERR (ud->ringacc); ud->dev = dev; - ud->ch_count =setup_resources (ud); -if (ud->ch_count <=0 ) -return ud->ch_count; + ret =setup_resources (ud); +if (ret <=0 ) +return ret;
The code was like this originally, but setup_resources() can't actually return zero so it would be nicer to say:
ret = setup_resources(ud); if (ret < 0) return ret;
regards,
dan carpenter
Quoted 3 lines
drivers/dma/ti/k3-udma.c +2
-0+ + ud->ch_count = ret;
Quoted 18 lines · Dan Carpenter
Quoted 5 lines · Siddharth Vadapalli
drivers/dma/ti/k3-udma.c +0
-0drivers/dma/ti/k3-udma.c static int udma_probe(struct udevice *dev) · line 1775
Quoted 9 lines
drivers/dma/ti/k3-udma.c +3
-3@@ -1770,9 +1770,11 @@ static int udma_probe(struct udevice *dev)return PTR_ERR (ud->ringacc); ud->dev = dev; - ud->ch_count =setup_resources (ud); -if (ud->ch_count <=0 ) -return ud->ch_count; + ret =setup_resources (ud); +if (ret <=0 ) +return ret;The code was like this originally, but
setup_resources()can't actually return zero so it would be nicer to say:
Quoted 3 lines
ret = setup_resources(ud); if (ret < 0) return ret;
Thank you for reviewing the patch and pointing this out. I will fix it and post the v2 patch.
Regards,
Siddharth.
Quoted 23 lines · Siddharth Vadapalli
Quoted 18 lines · Dan Carpenter
Quoted 5 lines · Siddharth Vadapalli
drivers/dma/ti/k3-udma.c +0
-0drivers/dma/ti/k3-udma.c static int udma_probe(struct udevice *dev) · line 1775
Quoted 9 lines
drivers/dma/ti/k3-udma.c +3
-3@@ -1770,9 +1770,11 @@ static int udma_probe(struct udevice *dev)return PTR_ERR (ud->ringacc); ud->dev = dev; - ud->ch_count =setup_resources (ud); -if (ud->ch_count <=0 ) -return ud->ch_count; + ret =setup_resources (ud); +if (ret <=0 ) +return ret;The code was like this originally, but
setup_resources()can't actually return zero so it would be nicer to say:Quoted 3 lines
ret = setup_resources(ud); if (ret < 0) return ret;
Quoted 2 lines
Thank you for reviewing the patch and pointing this out. I will fix it and post the v2 patch.
I have posted the v2 patch at:
https://patchwork.ozlabs.org/project/uboot/patch/[email protected]/
Regards,
Siddharth.