Message ID | 20201031031053.25264-1-yuehaibing@huawei.com (mailing list archive) |
---|---|
State | Not Applicable |
Delegated to: | Netdev Maintainers |
Headers | show |
Series | sfp: Fix error handing in sfp_probe() | expand |
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
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!
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; }
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(-)