lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAL_JsqJWEzb_hxi0_sSj-5F0q4A9UcJEhwcSArWT6eAffpeqHA@mail.gmail.com>
Date:   Wed, 18 Jan 2023 13:49:10 -0600
From:   Rob Herring <robh@...nel.org>
To:     Geert Uytterhoeven <geert@...ux-m68k.org>
Cc:     Madalin Bucur <madalin.bucur@....com>,
        "David S . Miller" <davem@...emloft.net>,
        Eric Dumazet <edumazet@...gle.com>,
        Jakub Kicinski <kuba@...nel.org>,
        Paolo Abeni <pabeni@...hat.com>,
        Horatiu Vultur <horatiu.vultur@...rochip.com>,
        UNGLinuxDriver@...rochip.com,
        Thierry Reding <thierry.reding@...il.com>,
        Lorenzo Pieralisi <lpieralisi@...nel.org>,
        Krzysztof WilczyƄski <kw@...ux.com>,
        Bjorn Helgaas <bhelgaas@...gle.com>,
        Jonathan Hunter <jonathanh@...dia.com>,
        Vinod Koul <vkoul@...nel.org>,
        Kishon Vijay Abraham I <kishon@...nel.org>,
        Alan Stern <stern@...land.harvard.edu>,
        Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
        Krzysztof Kozlowski <krzysztof.kozlowski@...aro.org>,
        Alim Akhtar <alim.akhtar@...sung.com>,
        Siddharth Vadapalli <s-vadapalli@...com>,
        Russell King <linux@...linux.org.uk>, netdev@...r.kernel.org,
        linux-tegra@...r.kernel.org, linux-pci@...r.kernel.org,
        linux-phy@...ts.infradead.org, linux-usb@...r.kernel.org,
        linux-arm-kernel@...ts.infradead.org,
        linux-samsung-soc@...r.kernel.org
Subject: Re: [PATCH 7/7] usb: host: ohci-exynos: Convert to devm_of_phy_optional_get()

On Wed, Jan 18, 2023 at 12:28 PM Geert Uytterhoeven
<geert@...ux-m68k.org> wrote:
>
> Hi Rob,
>
> On Wed, Jan 18, 2023 at 6:30 PM Rob Herring <robh@...nel.org> wrote:
> > On Wed, Jan 18, 2023 at 4:15 AM Geert Uytterhoeven
> > <geert+renesas@...der.be> wrote:
> > > Use the new devm_of_phy_optional_get() helper instead of open-coding the
> > > same operation.
> > >
> > > This lets us drop several checks for IS_ERR(), as phy_power_{on,off}()
> > > handle NULL parameters fine.
> > >
> > > Signed-off-by: Geert Uytterhoeven <geert+renesas@...der.be>
> > > ---
> > >  drivers/usb/host/ohci-exynos.c | 24 +++++++-----------------
> > >  1 file changed, 7 insertions(+), 17 deletions(-)
> > >
> > > diff --git a/drivers/usb/host/ohci-exynos.c b/drivers/usb/host/ohci-exynos.c
> > > index 8d7977fd5d3bd502..8dd9c3b2411c383f 100644
> > > --- a/drivers/usb/host/ohci-exynos.c
> > > +++ b/drivers/usb/host/ohci-exynos.c
> > > @@ -69,19 +69,12 @@ static int exynos_ohci_get_phy(struct device *dev,
> > >                         return -EINVAL;
> > >                 }
> > >
> > > -               phy = devm_of_phy_get(dev, child, NULL);
> > > +               phy = devm_of_phy_optional_get(dev, child, NULL);
> > >                 exynos_ohci->phy[phy_number] = phy;
> > >                 if (IS_ERR(phy)) {
> > > -                       ret = PTR_ERR(phy);
> > > -                       if (ret == -EPROBE_DEFER) {
> > > -                               of_node_put(child);
> > > -                               return ret;
> > > -                       } else if (ret != -ENOSYS && ret != -ENODEV) {
> > > -                               dev_err(dev,
> > > -                                       "Error retrieving usb2 phy: %d\n", ret);
> > > -                               of_node_put(child);
> > > -                               return ret;
> > > -                       }
> > > +                       of_node_put(child);
> > > +                       return dev_err_probe(dev, PTR_ERR(phy),
> > > +                                            "Error retrieving usb2 phy\n");
> >
> > Optional is really the only reason for the caller to decide whether to
> > print an error message or not. If we have both flavors of 'get', then
> > really the 'get' functions should print an error message.
>
> In case of a real error, both should print an error message, right?
>
> Anyway, I understand that's a three step operation:
>   1. Introduce and convert to the _optional variant,
>   2. Add error printing to callees.
>   3. Remove error printing from callers.

I think you only need 2 out of 3 steps depending on the situation. In
this case, you can add error printing in the _optional variant when
you introduce it and then convert callers to it.

Where we already have an optional variant, then you need steps 2 and 3.

Rob

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ