linux-usb.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: andriy.shevchenko@linux.intel.com
Cc: linux-usb@vger.kernel.org
Subject: [bug report] usb: dwc3: drd: Defer probe if extcon device is not found
Date: Fri, 14 Oct 2022 12:36:16 +0300	[thread overview]
Message-ID: <Y0ktkKfTgISmLogV@kili> (raw)

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

             reply	other threads:[~2022-10-14  9:36 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-14  9:36 Dan Carpenter [this message]
2022-10-14 10:13 ` [bug report] usb: dwc3: drd: Defer probe if extcon device is not found Andy Shevchenko
2022-10-18 13:09 ` Andy Shevchenko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Y0ktkKfTgISmLogV@kili \
    --to=dan.carpenter@oracle.com \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=linux-usb@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).