lkml.org 
[lkml]   [2015]   [May]   [15]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: [PATCH 5/5] usb: add pxa1928 ehci support
Date
On Thursday 14 May 2015 11:55:36 Alan Stern wrote:
>
> > + hcd->phy = devm_of_phy_get(&pdev->dev, pdev->dev.of_node, NULL);
> > + if (IS_ERR_OR_NULL(hcd->phy)) {
> > + retval = PTR_ERR(hcd->phy);
> > + if (retval != -EPROBE_DEFER && retval != -ENODEV)
> > + dev_err(&pdev->dev, "failed to get the phy\n");
> > + else
> > + return -EPROBE_DEFER;
> > + goto err_put_hcd;
> > + }
>
> Please straighten out this convoluted logic. It should go like this:
>
> hcd->phy = devm_of_phy_get(&pdev->dev, pdev->dev.of_node, NULL);
> if (IS_ERR_OR_NULL(hcd->phy)) {
> retval = PTR_ERR(hcd->phy);
> if (retval == -EPROBE_DEFER || retval == -ENODEV)
> return -EPROBE_DEFER;
> dev_err(&pdev->dev, "failed to get the phy\n");
> goto err_put_hcd;
> }
>

IS_ERR_OR_NULL is almost always wrong. Kernel interfaces that can return
an error pointer should never return a NULL pointer, and I'm pretty sure
that is also the case for the phy subsystem (or else it should be fixed).

In some cases, we have interfaces that return NULL pointers or error pointers,
but those are designed to treat NULL as success.

Arnd


\
 
 \ /
  Last update: 2015-05-15 11:41    [W:0.130 / U:0.140 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site