* [PATCH v2 net-next] mdio_bus: Fix PTR_ERR() usage after initialization to constant
@ 2019-02-16 2:59 YueHaibing
2019-02-19 0:36 ` David Miller
0 siblings, 1 reply; 2+ messages in thread
From: YueHaibing @ 2019-02-16 2:59 UTC (permalink / raw)
To: davem, andrew, f.fainelli, hkallweit1; +Cc: linux-kernel, netdev, YueHaibing
Fix coccinelle warning:
./drivers/net/phy/mdio_bus.c:51:5-12: ERROR: PTR_ERR applied after initialization to constant on line 44
./drivers/net/phy/mdio_bus.c:52:5-12: ERROR: PTR_ERR applied after initialization to constant on line 44
fix this by using IS_ERR before PTR_ERR
Fixes: bafbdd527d56 ("phylib: Add device reset GPIO support")
Signed-off-by: YueHaibing <yuehaibing@huawei.com>
---
v2: remove variable 'ret'
---
drivers/net/phy/mdio_bus.c | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/drivers/net/phy/mdio_bus.c b/drivers/net/phy/mdio_bus.c
index 3d31358..debc74c 100644
--- a/drivers/net/phy/mdio_bus.c
+++ b/drivers/net/phy/mdio_bus.c
@@ -48,11 +48,12 @@ static int mdiobus_register_gpiod(struct mdio_device *mdiodev)
gpiod = fwnode_get_named_gpiod(&mdiodev->dev.of_node->fwnode,
"reset-gpios", 0, GPIOD_OUT_LOW,
"PHY reset");
- if (PTR_ERR(gpiod) == -ENOENT ||
- PTR_ERR(gpiod) == -ENOSYS)
- gpiod = NULL;
- else if (IS_ERR(gpiod))
- return PTR_ERR(gpiod);
+ if (IS_ERR(gpiod)) {
+ if (PTR_ERR(gpiod) == -ENOENT || PTR_ERR(gpiod) == -ENOSYS)
+ gpiod = NULL;
+ else
+ return PTR_ERR(gpiod);
+ }
mdiodev->reset = gpiod;
--
2.7.4
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v2 net-next] mdio_bus: Fix PTR_ERR() usage after initialization to constant
2019-02-16 2:59 [PATCH v2 net-next] mdio_bus: Fix PTR_ERR() usage after initialization to constant YueHaibing
@ 2019-02-19 0:36 ` David Miller
0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2019-02-19 0:36 UTC (permalink / raw)
To: yuehaibing; +Cc: andrew, f.fainelli, hkallweit1, linux-kernel, netdev
From: YueHaibing <yuehaibing@huawei.com>
Date: Sat, 16 Feb 2019 10:59:35 +0800
> Fix coccinelle warning:
>
> ./drivers/net/phy/mdio_bus.c:51:5-12: ERROR: PTR_ERR applied after initialization to constant on line 44
> ./drivers/net/phy/mdio_bus.c:52:5-12: ERROR: PTR_ERR applied after initialization to constant on line 44
>
> fix this by using IS_ERR before PTR_ERR
>
> Fixes: bafbdd527d56 ("phylib: Add device reset GPIO support")
> Signed-off-by: YueHaibing <yuehaibing@huawei.com>
> ---
> v2: remove variable 'ret'
Applied.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-02-19 0:36 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-02-16 2:59 [PATCH v2 net-next] mdio_bus: Fix PTR_ERR() usage after initialization to constant YueHaibing
2019-02-19 0:36 ` David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).