sfp: Fix error handing in sfp_probe()
diff mbox series

Message ID 20201031031053.25264-1-yuehaibing@huawei.com
State Accepted
Commit 9621618130bf7e83635367c13b9a6ee53935bb37
Headers show
Series
  • sfp: Fix error handing in sfp_probe()
Related show

Commit Message

YueHaibing Oct. 31, 2020, 3:10 a.m. UTC
gpiod_to_irq() never return 0, but returns negative in
case of error, check it and set gpio_irq to 0.

Fixes: 73970055450e ("sfp: add SFP module support")
Signed-off-by: YueHaibing <yuehaibing@huawei.com>
---
 drivers/net/phy/sfp.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Andrew Lunn Oct. 31, 2020, 6:56 p.m. UTC | #1
On Sat, Oct 31, 2020 at 11:10:53AM +0800, YueHaibing wrote:
> gpiod_to_irq() never return 0, but returns negative in
> case of error, check it and set gpio_irq to 0.
> 
> Fixes: 73970055450e ("sfp: add SFP module support")
> Signed-off-by: YueHaibing <yuehaibing@huawei.com>

Reviewed-by: Andrew Lunn <andrew@lunn.ch>

    Andrew
Jakub Kicinski Nov. 3, 2020, 1:23 a.m. UTC | #2
On Sat, 31 Oct 2020 19:56:05 +0100 Andrew Lunn wrote:
> On Sat, Oct 31, 2020 at 11:10:53AM +0800, YueHaibing wrote:
> > gpiod_to_irq() never return 0, but returns negative in
> > case of error, check it and set gpio_irq to 0.
> > 
> > Fixes: 73970055450e ("sfp: add SFP module support")
> > Signed-off-by: YueHaibing <yuehaibing@huawei.com>  
> 
> Reviewed-by: Andrew Lunn <andrew@lunn.ch>

Applied, thanks!

Patch
diff mbox series

diff --git a/drivers/net/phy/sfp.c b/drivers/net/phy/sfp.c
index 1d18c10e8f82..34aa196b7465 100644
--- a/drivers/net/phy/sfp.c
+++ b/drivers/net/phy/sfp.c
@@ -2389,7 +2389,8 @@  static int sfp_probe(struct platform_device *pdev)
 			continue;
 
 		sfp->gpio_irq[i] = gpiod_to_irq(sfp->gpio[i]);
-		if (!sfp->gpio_irq[i]) {
+		if (sfp->gpio_irq[i] < 0) {
+			sfp->gpio_irq[i] = 0;
 			sfp->need_poll = true;
 			continue;
 		}