linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Mark Brown <broonie@kernel.org>
To: Andrew Murray <andrew.murray@arm.com>
Cc: Thierry Reding <thierry.reding@gmail.com>,
	Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>,
	Bjorn Helgaas <bhelgaas@google.com>,
	linux-pci@vger.kernel.org, Ray Jui <rjui@broadcom.com>,
	Scott Branden <sbranden@broadcom.com>,
	bcm-kernel-feedback-list@broadcom.com,
	Liam Girdwood <lgirdwood@gmail.com>
Subject: Re: [PATCH 5/5] PCI: iproc: Properly handle optional PHYs
Date: Thu, 29 Aug 2019 12:17:29 +0100	[thread overview]
Message-ID: <20190829111728.GC4118@sirena.co.uk> (raw)
In-Reply-To: <20190829100933.GH14582@e119886-lin.cambridge.arm.com>

[-- Attachment #1: Type: text/plain, Size: 1863 bytes --]

On Thu, Aug 29, 2019 at 11:09:34AM +0100, Andrew Murray wrote:

> But why do we return -ENODEV and not NULL for OPTIONAL_GET?

Why would we return NULL?  The caller is going to have to check the
error code anyway since they need to handle -EPROBE_DEFER and NULL is
never a valid thing to use with the regulator API.

> Looking at some of the consumer drivers I can see that lots of them don't
> correctly handle the return value of regulator_get_optional:

This API is *really* commonly abused, especially in the graphics
subsystem which for some reason has lots of users even though I don't
think I've ever seen a sensible use of the API there.  As far as I can
tell the graphics subsystem mostly suffers from people cut'n'pasting
from the Qualcomm BSP which is full of really bad practice.  It's really
frustrating since I will intermittently go through and clean things up
but the uses just keep coming back into the subsystem.

> Given that a common pattern is to set a consumer regulator pointer to NULL
> upon -ENODEV - if regulator_get_optional did this for them, then it would
> be more difficult for consumer drivers to get the error handling wrong and
> would remove some consumer boiler plate code.

No, they'd all still be broken for probe deferral (which is commonly
caused by off-chip devices) and they'd crash as soon as they try to call
any further regulator API functions.

> I guess I'm looking here for something that can simplify consumer error
> handling - it's easy to get wrong and it seems that many drivers may be wrong.

The overwhelming majority of the users just shouldn't be using this API.
If there weren't devices that absolutely *need* this API it wouldn't be
there in the first place since it seems like a magent for bad code, it's
so disappointing how bad the majority of the consumer code is.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

  parent reply	other threads:[~2019-08-29 11:17 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-28 16:36 [PATCH 1/5] PCI: exynos: Properly handle optional PHYs Thierry Reding
2019-08-28 16:36 ` [PATCH 2/5] PCI: imx6: Properly handle optional regulators Thierry Reding
2019-08-28 21:09   ` Andrew Murray
2019-08-28 16:36 ` [PATCH 3/5] PCI: armada8x: Properly handle optional PHYs Thierry Reding
2019-08-28 21:09   ` Andrew Murray
2019-08-28 16:36 ` [PATCH 4/5] PCI: histb: Properly handle optional regulators Thierry Reding
2019-08-28 21:09   ` Andrew Murray
2019-08-28 16:36 ` [PATCH 5/5] PCI: iproc: Properly handle optional PHYs Thierry Reding
2019-08-28 21:26   ` Andrew Murray
2019-08-28 21:49     ` Mark Brown
2019-08-29 10:09       ` Andrew Murray
2019-08-29 10:48         ` Thierry Reding
2019-08-29 12:13           ` Andrew Murray
2019-08-29 11:17         ` Mark Brown [this message]
2019-08-29 11:46           ` Thierry Reding
2019-08-29 12:08             ` Andrew Murray
2019-08-29 13:16               ` Mark Brown
2019-08-29 13:43                 ` Andrew Murray
2019-08-29 15:25                   ` Mark Brown
2019-08-29 13:03             ` Mark Brown
2019-08-29 14:58               ` Thierry Reding
2019-08-29 17:55                 ` Mark Brown
2019-08-28 17:54 ` [PATCH 1/5] PCI: exynos: " Bjorn Helgaas
2019-08-28 21:08 ` Andrew Murray

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=20190829111728.GC4118@sirena.co.uk \
    --to=broonie@kernel.org \
    --cc=andrew.murray@arm.com \
    --cc=bcm-kernel-feedback-list@broadcom.com \
    --cc=bhelgaas@google.com \
    --cc=lgirdwood@gmail.com \
    --cc=linux-pci@vger.kernel.org \
    --cc=lorenzo.pieralisi@arm.com \
    --cc=rjui@broadcom.com \
    --cc=sbranden@broadcom.com \
    --cc=thierry.reding@gmail.com \
    /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;
as well as URLs for NNTP newsgroup(s).