linux-usb.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [bug report] usb: dwc3: drd: Defer probe if extcon device is not found
@ 2022-10-14  9:36 Dan Carpenter
  2022-10-14 10:13 ` Andy Shevchenko
  2022-10-18 13:09 ` Andy Shevchenko
  0 siblings, 2 replies; 3+ messages in thread
From: Dan Carpenter @ 2022-10-14  9:36 UTC (permalink / raw)
  To: andriy.shevchenko; +Cc: linux-usb

Hello Andy Shevchenko,

The patch 98bba546e82d: "usb: dwc3: drd: Defer probe if extcon device
is not found" from Feb 18, 2019, leads to the following Smatch static
checker warning:

	drivers/usb/dwc3/drd.c:460 dwc3_get_extcon()
	warn: 'edev' is an error pointer or valid

drivers/usb/dwc3/drd.c
    442 static struct extcon_dev *dwc3_get_extcon(struct dwc3 *dwc)
    443 {
    444         struct device *dev = dwc->dev;
    445         struct device_node *np_phy;
    446         struct extcon_dev *edev = NULL;
    447         const char *name;
    448 
    449         if (device_property_read_bool(dev, "extcon"))
    450                 return extcon_get_edev_by_phandle(dev, 0);
    451 
    452         /*
    453          * Device tree platforms should get extcon via phandle.
    454          * On ACPI platforms, we get the name from a device property.
    455          * This device property is for kernel internal use only and
    456          * is expected to be set by the glue code.
    457          */
    458         if (device_property_read_string(dev, "linux,extcon-name", &name) == 0) {
    459                 edev = extcon_get_extcon_dev(name);
--> 460                 if (!edev)
    461                         return ERR_PTR(-EPROBE_DEFER);

This extcon_get_extcon_dev() returns NULL when CONFIG_EXTCON is disabled
otherwise it returns error pointers on error.  -EPROBE_DEFER does not
make sense for a .config issue.

    462 
    463                 return edev;
    464         }
    465 
    466         /*
    467          * Try to get an extcon device from the USB PHY controller's "port"
    468          * node. Check if it has the "port" node first, to avoid printing the
    469          * error message from underlying code, as it's a valid case: extcon
    470          * device (and "port" node) may be missing in case of "usb-role-switch"
    471          * or OTG mode.
    472          */
    473         np_phy = of_parse_phandle(dev->of_node, "phys", 0);
    474         if (of_graph_is_present(np_phy)) {
    475                 struct device_node *np_conn;
    476 
    477                 np_conn = of_graph_get_remote_node(np_phy, -1, -1);
    478                 if (np_conn)
    479                         edev = extcon_find_edev_by_node(np_conn);
    480                 of_node_put(np_conn);
    481         }
    482         of_node_put(np_phy);
    483 
    484         return edev;
    485 }

regards,
dan carpenter

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [bug report] usb: dwc3: drd: Defer probe if extcon device is not found
  2022-10-14  9:36 [bug report] usb: dwc3: drd: Defer probe if extcon device is not found Dan Carpenter
@ 2022-10-14 10:13 ` Andy Shevchenko
  2022-10-18 13:09 ` Andy Shevchenko
  1 sibling, 0 replies; 3+ messages in thread
From: Andy Shevchenko @ 2022-10-14 10:13 UTC (permalink / raw)
  To: Dan Carpenter; +Cc: linux-usb

On Fri, Oct 14, 2022 at 12:36:16PM +0300, Dan Carpenter wrote:
> Hello Andy Shevchenko,
> 
> The patch 98bba546e82d: "usb: dwc3: drd: Defer probe if extcon device
> is not found" from Feb 18, 2019, leads to the following Smatch static
> checker warning:
> 
> 	drivers/usb/dwc3/drd.c:460 dwc3_get_extcon()
> 	warn: 'edev' is an error pointer or valid

The culprit is wrong, but the rest seems correct.
Thank you.

-- 
With Best Regards,
Andy Shevchenko



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [bug report] usb: dwc3: drd: Defer probe if extcon device is not found
  2022-10-14  9:36 [bug report] usb: dwc3: drd: Defer probe if extcon device is not found Dan Carpenter
  2022-10-14 10:13 ` Andy Shevchenko
@ 2022-10-18 13:09 ` Andy Shevchenko
  1 sibling, 0 replies; 3+ messages in thread
From: Andy Shevchenko @ 2022-10-18 13:09 UTC (permalink / raw)
  To: Dan Carpenter; +Cc: linux-usb

On Fri, Oct 14, 2022 at 12:36:16PM +0300, Dan Carpenter wrote:
> Hello Andy Shevchenko,
> 
> The patch 98bba546e82d: "usb: dwc3: drd: Defer probe if extcon device
> is not found" from Feb 18, 2019, leads to the following Smatch static
> checker warning:
> 
> 	drivers/usb/dwc3/drd.c:460 dwc3_get_extcon()
> 	warn: 'edev' is an error pointer or valid

Should be fixed (as a side effect) by https://lore.kernel.org/r/20221017233510.53336-1-andriy.shevchenko@linux.intel.com

-- 
With Best Regards,
Andy Shevchenko



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-10-18 13:10 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-10-14  9:36 [bug report] usb: dwc3: drd: Defer probe if extcon device is not found Dan Carpenter
2022-10-14 10:13 ` Andy Shevchenko
2022-10-18 13:09 ` Andy Shevchenko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).