extcon: Use dev_of_node(dev) instead of dev->of_node
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Wed, 22 Mar 2023 14:40:01 +0000 (16:40 +0200)
committerChanwoo Choi <cw00.choi@samsung.com>
Mon, 29 May 2023 14:41:29 +0000 (23:41 +0900)
The dev_of_node function should be preferred.
In the result we may drop unneeded NULL check
of the pointer to the device object.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
drivers/extcon/extcon.c

index 588c552b95254e2ba08ffe6ed0f53235fcf751dc..89b3946b31232f1cb4809fc10f8e447830651dc7 100644 (file)
@@ -1423,21 +1423,17 @@ out:
  */
 struct extcon_dev *extcon_get_edev_by_phandle(struct device *dev, int index)
 {
-       struct device_node *node;
+       struct device_node *node, *np = dev_of_node(dev);
        struct extcon_dev *edev;
 
-       if (!dev)
-               return ERR_PTR(-EINVAL);
-
-       if (!dev->of_node) {
+       if (!np) {
                dev_dbg(dev, "device does not have a device node entry\n");
                return ERR_PTR(-EINVAL);
        }
 
-       node = of_parse_phandle(dev->of_node, "extcon", index);
+       node = of_parse_phandle(np, "extcon", index);
        if (!node) {
-               dev_dbg(dev, "failed to get phandle in %pOF node\n",
-                       dev->of_node);
+               dev_dbg(dev, "failed to get phandle in %pOF node\n", np);
                return ERR_PTR(-ENODEV);
        }