Skip to content

Commit

Permalink
extcon: Use dev_of_node(dev) instead of dev->of_node
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: Chanwoo Choi <[email protected]>
  • Loading branch information
andy-shev authored and chanwoochoi committed May 29, 2023
1 parent 0146f56 commit 9b4aea5
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions drivers/extcon/extcon.c
Original file line number Diff line number Diff line change
Expand Up @@ -1423,21 +1423,17 @@ struct extcon_dev *extcon_find_edev_by_node(struct device_node *node)
*/
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);
}

Expand Down

0 comments on commit 9b4aea5

Please sign in to comment.