net: ethernet: ti: am65-cpsw: Fix error code in am65_cpsw_nuss_init_tx_chns()
Subsystems (6)
PATCH 1/3 net: ethernet: ti: am65-cpsw: Fix error code in am65_cpsw_nuss_init_tx_chns()
This accidentally returns success, but it should return a negative error code.
---
Sorry for the delay on this. I wrote this before traveling and meant to send it earlier but forgot.
drivers/net/ethernet/ti/am65-cpsw-nuss.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/ethernet/ti/am65-cpsw-nuss.c +1 -0
@@ -1750,6 +1750,7 @@ static int am65_cpsw_nuss_init_tx_chns(struct am65_cpsw_common *common)if (tx_chn->irq <=0 ) {dev_err (dev,"Failed to get tx dma irq %d\n" , tx_chn->irq); + ret = tx_chn->irq ?: -ENXIO ; goto err; }
Signature · 1 line
2.39.2
PATCH 2/3 net: ti: icssg-prueth: Fix signedness bug in prueth_init_tx_chns()
The "tx_chn->irq" variable is unsigned so the error checking does not work correctly.
--- drivers/net/ethernet/ti/icssg/icssg_prueth.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/net/ethernet/ti/icssg/icssg_prueth.c +5 -3
@@ -316,12 +316,14 @@ static int prueth_init_tx_chns(struct prueth_emac *emac) goto fail; } - tx_chn->irq =k3_udma_glue_tx_get_irq (tx_chn->tx_chn); -if (tx_chn->irq <=0 ) { - ret = -EINVAL ; + ret =k3_udma_glue_tx_get_irq (tx_chn->tx_chn); +if (ret <=0 ) { +if (!ret) + ret = -EINVAL ;netdev_err (ndev,"failed to get tx irq\n" ); goto fail; } + tx_chn->irq = ret;snprintf (tx_chn->name,sizeof (tx_chn->name),"%s-tx%d" ,dev_name (dev), tx_chn->id);
Signature · 1 line
2.39.2
Re: [PATCH 2/3 net] net: ti: icssg-prueth: Fix signedness bug in prueth_init_tx_chns()
Quoted 5 lines · Dan Carpenter
The "
tx_chn->irq" variable is unsigned so the error checking does not work correctly.Fixes 128d5874c082 ("net: ti: icssg-prueth: Add ICSSG ethernet driver")Signed-off-by Dan Carpenter <[email protected]>
PATCH 3/3 dmaengine: ti: k3-udma-glue: clean up k3_udma_glue_tx_get_irq() return
In reply to Dan CarpenterThe k3_udma_glue_tx_get_irq() function currently returns negative error codes on error, zero on error and positive values for success. This complicates life for the callers who need to propagate the error code. Also GCC will not warn about unsigned comparisons when you check:
if (unsigned_irq <= 0)
All the callers have been fixed now but let's just make this easy going forward.
--- drivers/dma/ti/k3-udma-glue.c | 3 +++ drivers/net/ethernet/ti/am65-cpsw-nuss.c | 4 ++-- drivers/net/ethernet/ti/icssg/icssg_prueth.c | 4 +--- 3 files changed, 6 insertions(+), 5 deletions(-)
drivers/dma/ti/k3-udma-glue.c +3 -0
@@ -558,6 +558,9 @@ int k3_udma_glue_tx_get_irq(struct k3_udma_glue_tx_channel *tx_chn) tx_chn->virq =k3_ringacc_get_ring_irq_num (tx_chn->ringtxcq); } +if (!tx_chn->virq) +return -ENXIO ; +return tx_chn->virq; }EXPORT_SYMBOL_GPL (k3_udma_glue_tx_get_irq);
drivers/net/ethernet/ti/am65-cpsw-nuss.c +2 -2
@@ -1747,10 +1747,10 @@ static int am65_cpsw_nuss_init_tx_chns(struct am65_cpsw_common *common) } tx_chn->irq =k3_udma_glue_tx_get_irq (tx_chn->tx_chn); -if (tx_chn->irq <=0 ) { +if (tx_chn->irq <0 ) {dev_err (dev,"Failed to get tx dma irq %d\n" , tx_chn->irq); - ret = tx_chn->irq ?: -ENXIO ; + ret = tx_chn->irq; goto err; }
drivers/net/ethernet/ti/icssg/icssg_prueth.c +1 -3
@@ -317,9 +317,7 @@ static int prueth_init_tx_chns(struct prueth_emac *emac) } ret =k3_udma_glue_tx_get_irq (tx_chn->tx_chn); -if (ret <=0 ) { -if (!ret) - ret = -EINVAL ; +if (ret <0 ) {netdev_err (ndev,"failed to get tx irq\n" ); goto fail; }
Signature · 1 line
2.39.2
Re: [PATCH 3/3 net] dmaengine: ti: k3-udma-glue: clean up k3_udma_glue_tx_get_irq() return
Quoted 11 lines · Dan Carpenter
The
k3_udma_glue_tx_get_irq()function currently returns negative error codes on error, zero on error and positive values for success. This complicates life for the callers who need to propagate the error code. Also GCC will not warn about unsigned comparisons when you check:if (unsigned_irq <= 0)All the callers have been fixed now but let's just make this easy going forward.
Signed-off-by Dan Carpenter <[email protected]>
Re: [PATCH 3/3 net] dmaengine: ti: k3-udma-glue: clean up k3_udma_glue_tx_get_irq() return
In reply to Dan CarpenterQuoted 9 lines · Dan Carpenter
The
k3_udma_glue_tx_get_irq()function currently returns negative error codes on error, zero on error and positive values for success. This complicates life for the callers who need to propagate the error code. Also GCC will not warn about unsigned comparisons when you check:if (unsigned_irq <= 0)All the callers have been fixed now but let's just make this easy going forward.
Signature · 1 line
~Vinod
Quoted 5 lines · Dan Carpenter
This accidentally returns success, but it should return a negative error code.
Fixes 93a76530316a ("net: ethernet: ti: introduce am65x/j721e gigabit eth subsystem driver")Signed-off-by Dan Carpenter <[email protected]>
This series was applied to netdev/net.git (main) by David S. Miller <[email protected]>:
Hello:
This series was applied to netdev/net.git (main)
by David S. Miller <[email protected]>:
Quoted 10 lines · On Tue, 26 Sep 2023 17:04:43 +0300 you wrote:
This accidentally returns success, but it should return a negative error code.
Fixes 93a76530316a ("net: ethernet: ti: introduce am65x/j721e gigabit eth subsystem driver")Signed-off-by Dan Carpenter <[email protected]>---
Sorry for the delay on this. I wrote this before traveling and meant to send it earlier but forgot.[...]
Here is the summary with links:
- [1/3,net] net: ethernet: ti: am65-cpsw: Fix error code in am65_cpsw_nuss_init_tx_chns()
https://git.kernel.org/netdev/net/c/37d4f5556798 - [2/3,net] net: ti: icssg-prueth: Fix signedness bug in prueth_init_tx_chns() https://git.kernel.org/netdev/net/c/a325f174d708 - [3/3,net] dmaengine: ti: k3-udma-glue: clean up k3_udma_glue_tx_get_irq() return https://git.kernel.org/netdev/net/c/f9a1d3216a49
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html