On 10/26/2015 03:28 AM, Alexander Aring wrote: > This patch changes devm_phy_get to devm_phy_optional_get. Which fixes the > error handling when trying to get the phy. Currently on all errors we > try to look for an old style USB PHY. With this patch we try to look for > an old USB PHY when devm_phy_get returns -ENOENT only. Other values like > -EPROBE_DEFER need to be returned from the probe function, because it > could be that a phy is specified but not probed before. > diff --git a/drivers/usb/dwc2/platform.c b/drivers/usb/dwc2/platform.c > @@ -222,12 +222,15 @@ static int dwc2_driver_probe(struct platform_device *dev) > > hsotg->dr_mode = of_usb_get_dr_mode(dev->dev.of_node); > > + phy = devm_phy_optional_get(&dev->dev, "usb2-phy"); > + if (IS_ERR(phy)) > + return PTR_ERR(phy); Here, phy is checked using IS_ERR(), ... > /* > * Attempt to find a generic PHY, then look for an old style > * USB PHY > */ > - phy = devm_phy_get(&dev->dev, "usb2-phy"); > - if (IS_ERR(phy)) { > + if (!phy) { ... and here the same phy value is checked against NULL. Hopefully, devm_phy_get() doesn't actually return either an ERR value or a NULL pointer as errors, but restricts itself to either an ERR value or returning NULL. In other words, it's bad form to check a value using both IS_ERR and comparison against NULL. -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html