From: Arnd Bergmann <arnd@arndb.de>
To: Ben Dooks <ben.dooks@codethink.co.uk>
Cc: Mike Looijmans <mike.looijmans@topic.nl>,
linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org,
cjb@laptop.org, gdjakov@mm-sol.com
Subject: Re: [PATCH] sdhci: Forward EPROBE_DEFER on vmmc and vqmmc regulators
Date: Mon, 07 Apr 2014 14:25:23 +0200 [thread overview]
Message-ID: <10471336.Pb8zVvW3Hp@wuerfel> (raw)
In-Reply-To: <534297AE.1020907@codethink.co.uk>
On Monday 07 April 2014 13:18:54 Ben Dooks wrote:
> On 07/04/14 13:16, Ben Dooks wrote:
> > On 07/04/14 13:09, Mike Looijmans wrote:
> >> On 04/07/2014 10:11 AM, Arnd Bergmann wrote:
> >>> On Monday 07 April 2014 08:38:28 Mike Looijmans wrote:
> >>>> index 34aef81..43b90c1 100644
> >>>> --- a/drivers/mmc/host/sdhci.c
> >>>> +++ b/drivers/mmc/host/sdhci.c
> >>>> @@ -2972,6 +2972,8 @@ int sdhci_add_host(struct sdhci_host *host)
> >>>> host->vqmmc = regulator_get_optional(mmc_dev(mmc), "vqmmc");
> >>>> if (IS_ERR_OR_NULL(host->vqmmc)) {
> >>>> if (PTR_ERR(host->vqmmc) < 0) {
> >>>> + if (PTR_ERR(host->vqmmc) == -EPROBE_DEFER)
> >>>> + return -EPROBE_DEFER;
> >>>> pr_info("%s: no vqmmc regulator found\n",
> >>>> mmc_hostname(mmc));
> >>>> host->vqmmc = NULL;
> >>>> @@ -3048,8 +3050,10 @@ int sdhci_add_host(struct sdhci_host *host)
> >>>> host->vmmc = regulator_get_optional(mmc_dev(mmc), "vmmc");
> >>>> if (IS_ERR_OR_NULL(host->vmmc)) {
> >>>> if (PTR_ERR(host->vmmc) < 0) {
> >>>> - pr_info("%s: no vmmc regulator found\n",
> >>>> - mmc_hostname(mmc));
> >>>> + if (PTR_ERR(host->vmmc) == -EPROBE_DEFER)
> >>>> + return -EPROBE_DEFER;
> >>>> + pr_info("%s: no vmmc regulator found (%d)\n",
> >>>> + mmc_hostname(mmc),
> >>>> PTR_ERR(host->vmmc));
> >>>> host->vmmc = NULL;
> >>>> }
> >>>
> >>> Please change the code to not use IS_ERR_OR_NULL() instead, getting
> >>> a NULL return value from regulator_get_optional() should not be
> >>> considered a bug, while getting an error return should always
> >>> cause the probe function to fail.
> >
> > Surely it needs to be changed to IS_ERR(), nor IS_ERR_OR_NULL()?
>
>
> And by that, I mean the use of "PTR_ERR(host->vmmc) < 0" to be
> changed to IS_ERR(), which I think Arnd was originally complaining
> about.
I mean something like
host->vqmmc = regulator_get_optional(mmc_dev(mmc), "vqmmc");
if (IS_ERR(host->vqmmc)) {
if (PTR_ERR(host->vqmmc) != -EPROBE_DEFER)
complain(); /* only print a message if we won't retry */
return ERR_PTR(host->vqmmc); /* never ignore an error */
}
/* silently continue if no regulator is defined */
regulator_get_optional() means we can continue if it's not there, but
we should not continue if there is a regulator that we fail to use
for some reason.
As has been found a number of times, any use of IS_ERR_OR_NULL()
means that the person responsible for the code is confused about
what the API is supposed to be.
Arnd
next prev parent reply other threads:[~2014-04-07 12:25 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-03-07 14:18 [PATCH] sdhci: Forward EPROBE_DEFER on vmmc and vqmmc regulators Mike Looijmans
2014-03-26 15:09 ` Georgi Djakov
2014-03-27 17:47 ` Mike Looijmans
2014-03-27 21:13 ` Georgi Djakov
2014-03-28 7:30 ` Mike Looijmans
2014-03-28 10:20 ` Ulf Hansson
2014-04-07 6:38 ` Mike Looijmans
2014-04-07 6:45 ` Mike Looijmans
2014-04-07 8:11 ` Arnd Bergmann
2014-04-07 12:09 ` Mike Looijmans
2014-04-07 12:16 ` Ben Dooks
2014-04-07 12:18 ` Ben Dooks
2014-04-07 12:25 ` Arnd Bergmann [this message]
2014-04-07 12:32 ` Mike Looijmans
2014-04-07 12:51 ` Arnd Bergmann
2014-04-07 13:11 ` Mike Looijmans
2014-04-16 20:15 ` Andrew Bresticker
2014-04-16 20:47 ` Mark Brown
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=10471336.Pb8zVvW3Hp@wuerfel \
--to=arnd@arndb.de \
--cc=ben.dooks@codethink.co.uk \
--cc=cjb@laptop.org \
--cc=gdjakov@mm-sol.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mmc@vger.kernel.org \
--cc=mike.looijmans@topic.nl \
/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