Skip to content

Commit 9b4aea5

Browse files
andy-shevchanwoochoi
authored andcommitted
extcon: Use dev_of_node(dev) instead of dev->of_node
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>
1 parent 0146f56 commit 9b4aea5

1 file changed

Lines changed: 4 additions & 8 deletions

File tree

drivers/extcon/extcon.c

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1423,21 +1423,17 @@ struct extcon_dev *extcon_find_edev_by_node(struct device_node *node)
14231423
*/
14241424
struct extcon_dev *extcon_get_edev_by_phandle(struct device *dev, int index)
14251425
{
1426-
struct device_node *node;
1426+
struct device_node *node, *np = dev_of_node(dev);
14271427
struct extcon_dev *edev;
14281428

1429-
if (!dev)
1430-
return ERR_PTR(-EINVAL);
1431-
1432-
if (!dev->of_node) {
1429+
if (!np) {
14331430
dev_dbg(dev, "device does not have a device node entry\n");
14341431
return ERR_PTR(-EINVAL);
14351432
}
14361433

1437-
node = of_parse_phandle(dev->of_node, "extcon", index);
1434+
node = of_parse_phandle(np, "extcon", index);
14381435
if (!node) {
1439-
dev_dbg(dev, "failed to get phandle in %pOF node\n",
1440-
dev->of_node);
1436+
dev_dbg(dev, "failed to get phandle in %pOF node\n", np);
14411437
return ERR_PTR(-ENODEV);
14421438
}
14431439

0 commit comments

Comments
 (0)