Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Andy Shevchenko and committed by
Chanwoo Choi
9b4aea51 0146f56b

+4 -8
+4 -8
drivers/extcon/extcon.c
··· 1423 1423 */ 1424 1424 struct extcon_dev *extcon_get_edev_by_phandle(struct device *dev, int index) 1425 1425 { 1426 - struct device_node *node; 1426 + struct device_node *node, *np = dev_of_node(dev); 1427 1427 struct extcon_dev *edev; 1428 1428 1429 - if (!dev) 1430 - return ERR_PTR(-EINVAL); 1431 - 1432 - if (!dev->of_node) { 1429 + if (!np) { 1433 1430 dev_dbg(dev, "device does not have a device node entry\n"); 1434 1431 return ERR_PTR(-EINVAL); 1435 1432 } 1436 1433 1437 - node = of_parse_phandle(dev->of_node, "extcon", index); 1434 + node = of_parse_phandle(np, "extcon", index); 1438 1435 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); 1441 1437 return ERR_PTR(-ENODEV); 1442 1438 } 1443 1439