public inbox for devicetree@vger.kernel.org
 help / color / mirror / Atom feed
From: Arnd Bergmann <arnd@arndb.de>
To: Alan Stern <stern@rowland.harvard.edu>
Cc: Rob Herring <robh@kernel.org>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Kishon Vijay Abraham I <kishon@ti.com>,
	linux-kernel@vger.kernel.org, devicetree@vger.kernel.org,
	linux-usb@vger.kernel.org
Subject: Re: [PATCH 5/5] usb: add pxa1928 ehci support
Date: Fri, 15 May 2015 11:32:12 +0200	[thread overview]
Message-ID: <4475721.5hJuZmGMm7@wuerfel> (raw)
In-Reply-To: <Pine.LNX.4.44L0.1505141152300.1107-100000@iolanthe.rowland.org>

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

  reply	other threads:[~2015-05-15  9:32 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-13 22:48 [PATCH 0/5] Marvell PXA1928 USB support Rob Herring
2015-05-13 22:48 ` [PATCH 2/5] dt-bindings: Add Marvell PXA1928 USB EHCI controller binding Rob Herring
2015-05-13 22:48 ` [PATCH 4/5] phy: add Marvell HSIC 28nm PHY Rob Herring
2015-05-21 12:45   ` Kishon Vijay Abraham I
2015-05-21 12:51     ` Kishon Vijay Abraham I
     [not found]       ` <555DD4C2.80406-l0cyMroinI0@public.gmane.org>
2015-05-22 19:54         ` Rob Herring
2015-05-26  6:06           ` Kishon Vijay Abraham I
2015-05-13 22:49 ` [PATCH 5/5] usb: add pxa1928 ehci support Rob Herring
2015-05-14  8:24   ` Paul Bolle
2015-05-14 10:42     ` Arnd Bergmann
2015-05-14 13:25       ` Rob Herring
2015-05-14 10:43   ` Arnd Bergmann
     [not found]   ` <1431557340-5421-6-git-send-email-robh-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2015-05-14 14:56     ` Alan Stern
     [not found]       ` <Pine.LNX.4.44L0.1505141025280.1582-100000-IYeN2dnnYyZXsRXLowluHWD2FQJk+8+b@public.gmane.org>
2015-05-14 16:36         ` Rob Herring
     [not found]           ` <CAL_JsqLq0x47O4gSs_vnfNkaUsE9bp9M9W5SV0c7vJ6X6b5cdA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-05-14 17:06             ` Alan Stern
2015-05-14 15:55   ` Alan Stern
2015-05-15  9:32     ` Arnd Bergmann [this message]
     [not found] ` <1431557340-5421-1-git-send-email-robh-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2015-05-13 22:48   ` [PATCH 1/5] dt-bindings: Add Marvell PXA1928 USB and HSIC PHY bindings Rob Herring
2015-05-13 22:48   ` [PATCH 3/5] phy: Add Marvell USB 2.0 OTG 28nm PHY Rob Herring
     [not found]     ` <1431557340-5421-4-git-send-email-robh-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2015-05-21 12:33       ` Kishon Vijay Abraham I
2015-05-15  9:55   ` [PATCH 0/5] Marvell PXA1928 USB support Sebastian Hesselbarth
     [not found]     ` <5555C2A5.8010509-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2015-05-15 12:48       ` Rob Herring
2015-05-15 14:11         ` Arnd Bergmann
2015-05-15 16:04           ` Rob Herring

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=4475721.5hJuZmGMm7@wuerfel \
    --to=arnd@arndb.de \
    --cc=devicetree@vger.kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=kishon@ti.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=robh@kernel.org \
    --cc=stern@rowland.harvard.edu \
    /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