]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
mdio_bus: Fix PTR_ERR() usage after initialization to constant
authorYueHaibing <yuehaibing@huawei.com>
Sat, 16 Feb 2019 02:59:35 +0000 (10:59 +0800)
committerDavid S. Miller <davem@davemloft.net>
Tue, 19 Feb 2019 00:34:20 +0000 (16:34 -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>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/phy/mdio_bus.c

index 3d313585c9c1c694b086722097550cb7fb77832d..debc74c903071b924a9b65b424acaa99087c4ea2 100644 (file)
@@ -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;