Re: [PATCH] usb: phy: return -ENXIO when PHY layer isn't enabled

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Mar 14, 2013 at 06:04:53PM +0200, Felipe Balbi wrote:
> in cases where PHY layer isn't enabled, we want
> to still return an error code (actually an error
> pointer) so that our users don't need to cope with
> either error pointer of NULL.
> 
> This will simplify users as below:
> 
> -	return IS_ERR(phy) ? PTR_ERR(phy) : -ENODEV;
> +	return PTR_ERR(phy);
> 
> Reported-by: Alan Stern <stern@xxxxxxxxxxxxxxxxxxx>
> Signed-off-by: Felipe Balbi <balbi@xxxxxx>
> ---
> 
> Kishon, what do you think of this patch ?
> 
> I'm planning to send it on v3.10 together with some
> other patches cleaning the users of the API.

users would have to look like so:

diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
index c845e70..cd15c20 100644
--- a/drivers/usb/dwc3/core.c
+++ b/drivers/usb/dwc3/core.c
@@ -434,12 +434,30 @@ static int dwc3_probe(struct platform_device *pdev)
 		dwc->usb3_phy = devm_usb_get_phy(dev, USB_PHY_TYPE_USB3);
 	}
 
-	if (IS_ERR_OR_NULL(dwc->usb2_phy)) {
+	if (IS_ERR(dwc->usb2_phy)) {
+		ret = PTR_ERR(dwc->usb2_phy);
+
+		/*
+		 * if return is -ENXIO, we need to bail out, since PHY layer
+		 * hasn't been enabled at all
+		 */
+		if (ret == -ENXIO)
+			return ret;
+
 		dev_err(dev, "no usb2 phy configured\n");
 		return -EPROBE_DEFER;
 	}
 
-	if (IS_ERR_OR_NULL(dwc->usb3_phy)) {
+	if (IS_ERR(dwc->usb3_phy)) {
+		ret = PTR_ERR(dwc->usb3_phy);
+
+		/*
+		 * if return is -ENXIO, we need to bail out, since PHY layer
+		 * hasn't been enabled at all
+		 */
+		if (ret == -ENXIO)
+			return ret;
+
 		dev_err(dev, "no usb3 phy configured\n");
 		return -EPROBE_DEFER;
 	}

I was also considering we should add generic error messages so drivers
don't need to care about printing anything.

-- 
balbi

Attachment: signature.asc
Description: Digital signature


[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux