Skip to content

Commit 780feae

Browse files
YueHaibingdavem330
authored andcommitted
mdio_bus: Fix PTR_ERR() usage after initialization to constant
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: bafbdd5 ("phylib: Add device reset GPIO support") Signed-off-by: YueHaibing <yuehaibing@huawei.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 31ef5b0 commit 780feae

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

drivers/net/phy/mdio_bus.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,12 @@ static int mdiobus_register_gpiod(struct mdio_device *mdiodev)
4848
gpiod = fwnode_get_named_gpiod(&mdiodev->dev.of_node->fwnode,
4949
"reset-gpios", 0, GPIOD_OUT_LOW,
5050
"PHY reset");
51-
if (PTR_ERR(gpiod) == -ENOENT ||
52-
PTR_ERR(gpiod) == -ENOSYS)
53-
gpiod = NULL;
54-
else if (IS_ERR(gpiod))
55-
return PTR_ERR(gpiod);
51+
if (IS_ERR(gpiod)) {
52+
if (PTR_ERR(gpiod) == -ENOENT || PTR_ERR(gpiod) == -ENOSYS)
53+
gpiod = NULL;
54+
else
55+
return PTR_ERR(gpiod);
56+
}
5657

5758
mdiodev->reset = gpiod;
5859

0 commit comments

Comments
 (0)