Skip to content

Commit cb4d9b5

Browse files
Sam Protsenkogregkh
authored andcommitted
usb: dwc3: drd: Improve dwc3_get_extcon() style
The previous change ("usb: dwc3: drd: Avoid error when extcon is missing") changed the code flow in dwc3_get_extcon() function, leading to unnecessary if-branch. This patch does housekeeping by reworking the code for obtaining an extcon device from the "port" node. Cc: Andy Shevchenko <[email protected]> Signed-off-by: Sam Protsenko <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent c824c73 commit cb4d9b5

File tree

1 file changed

+9
-12
lines changed

1 file changed

+9
-12
lines changed

drivers/usb/dwc3/drd.c

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -441,8 +441,8 @@ static int dwc3_drd_notifier(struct notifier_block *nb,
441441
static struct extcon_dev *dwc3_get_extcon(struct dwc3 *dwc)
442442
{
443443
struct device *dev = dwc->dev;
444-
struct device_node *np_phy, *np_conn;
445-
struct extcon_dev *edev;
444+
struct device_node *np_phy;
445+
struct extcon_dev *edev = NULL;
446446
const char *name;
447447

448448
if (device_property_read_bool(dev, "extcon"))
@@ -470,17 +470,14 @@ static struct extcon_dev *dwc3_get_extcon(struct dwc3 *dwc)
470470
* or OTG mode.
471471
*/
472472
np_phy = of_parse_phandle(dev->of_node, "phys", 0);
473-
if (of_graph_is_present(np_phy))
474-
np_conn = of_graph_get_remote_node(np_phy, -1, -1);
475-
else
476-
np_conn = NULL;
477-
478-
if (np_conn)
479-
edev = extcon_find_edev_by_node(np_conn);
480-
else
481-
edev = NULL;
473+
if (of_graph_is_present(np_phy)) {
474+
struct device_node *np_conn;
482475

483-
of_node_put(np_conn);
476+
np_conn = of_graph_get_remote_node(np_phy, -1, -1);
477+
if (np_conn)
478+
edev = extcon_find_edev_by_node(np_conn);
479+
of_node_put(np_conn);
480+
}
484481
of_node_put(np_phy);
485482

486483
return edev;

0 commit comments

Comments
 (0)