Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1334898
| Path | csiph.com!news.freedyn.net!aioe.org!bofh.it!news.nic.it!robomod |
|---|---|
| From | Viresh Kumar <viresh.kumar@linaro.org> |
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH] PM / OPP: Initialize regulator pointer to an error value |
| Date | Tue, 16 Feb 2016 02:10:02 +0100 |
| Message-ID | <r2Cjo-wW-11@gated-at.bofh.it> (permalink) |
| References | <r2ucb-3qG-61@gated-at.bofh.it> <r2ucb-3qG-59@gated-at.bofh.it> <r2y66-68b-15@gated-at.bofh.it> |
| X-Original-To | Arnd Bergmann <arnd@arndb.de> |
| Dkim-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-type:content-disposition:in-reply-to:user-agent; bh=RsBrrOvVTVQqXABlDq36FKTjaBzYa6JVutxyRbXHXVI=; b=bQvBrxn5jZd0idB1n1W2eH2D3OQhM6RZu+vz+9KwTj1oX15JW/uqT+RdvVJ4O9Bmy8 bZExrxHV37ivqFxT0XsQ5hcZAio+yJzKc4+X/KLKvszcWlLXGvaPLlTJgrwYBdTAWJSB q/+feYKwLbMFz01wZAdSYfcPWisJPMa7plKSg= |
| X-Google-Dkim-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-type:content-disposition:in-reply-to :user-agent; bh=RsBrrOvVTVQqXABlDq36FKTjaBzYa6JVutxyRbXHXVI=; b=JF8eyBCac28REqfODhaDZlUl1Xemz992zWfWk3ZRJSufxuoxZUkbCKCdsKvHpwMkBQ QsK0w9F6PO8tUFC53gReBS9BtD1gOog/af+zbXsBnRNPnBRgbvcKx59prgzNgwRjTDW3 BIXfbOw7Y4JYAPEpM9b0e4/SURtU/eb7waziW95SK5yJuO42tvzronig5lJ3r1mj7jlQ HHu1dbRJHw1iHHZfnsSE18/EgrugP7p2Edg1eTk73gxmF0CHDngEJXgbaqSpPBSdS1Rh 09zOmeJ/psl41E1JgEmcKLNI3t8kj0XJmkj25taISsQ2Wgfw/b21e3TOg5+qc4KP0qkr nrDA== |
| X-Gm-Message-State | AG10YOS4kuAFnAULktM/kCHQqF49SprA0Ueyz32yIDf6ONI9pfFSFEj+UUepDANVQD8qaGIi |
| X-Received | by 10.67.12.175 with SMTP id er15mr27248277pad.70.1455584468872; Mon, 15 Feb 2016 17:01:08 -0800 (PST) |
| MIME-Version | 1.0 |
| Content-Type | text/plain; charset=us-ascii |
| Content-Disposition | inline |
| User-Agent | Mutt/1.5.23 (2014-03-12) |
| Sender | robomod@news.nic.it |
| List-ID | <linux-kernel.vger.kernel.org> |
| X-Mailing-List | linux-kernel@vger.kernel.org |
| Approved | robomod@news.nic.it |
| Lines | 58 |
| Organization | linux.* mail to news gateway |
| X-Original-Cc | linaro-kernel@lists.linaro.org, Rafael Wysocki <rjw@rjwysocki.net>, Viresh Kumar <vireshk@kernel.org>, Nishanth Menon <nm@ti.com>, Stephen Boyd <sboyd@codeaurora.org>, Jon Hunter <jonathanh@nvidia.com>, linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, Mark Brown <broonie@kernel.org> |
| X-Original-Date | Tue, 16 Feb 2016 06:30:59 +0530 |
| X-Original-Message-ID | <20160216010059.GH6334@vireshk-i7> |
| X-Original-References | <1455544758-7718-1-git-send-email-jonathanh@nvidia.com> <743509d913cbc0e725bea52281be03b009e02bb5.1455553501.git.viresh.kumar@linaro.org> <17646703.2nZXD4icYj@wuerfel> |
| X-Original-Sender | linux-kernel-owner@vger.kernel.org |
| Xref | csiph.com linux.kernel:1334898 |
Show key headers only | View raw
Cc'ing Mark as well.
On 15-02-16, 21:38, Arnd Bergmann wrote:
> There is usually something else wrong if you have to check for both.
> Why exactly do you need to check for both IS_ERR and NULL?
And here is the reasoning behind it:
- It is normally said that 'NULL' is a valid clk. The same is
applicable to regulators as well, right? At least, that is what
below says:
commit 4a511de96d69 ("cpufreq: cpufreq-cpu0: NULL is a valid
regulator")
- And so I left the regulator pointer to NULL in OPP core.
- But then I realized that its not safe to call many regulator core
APIs with NULL regulator, as those caused the crashes reported by
multiple people now.
- clk APIs guarantee that they return early when NULL clk is passed to
them.
- Do we need to do the same for regulator core as well ?
- And so I initialized the pointer to an error value now, as
initializing it to NULL (possibly a valid regulator, in theory)
isn't the right thing to do.
> > diff --git a/drivers/base/power/opp/core.c b/drivers/base/power/opp/core.c
> > index d7cd4e265766..146b6197d598 100644
> > --- a/drivers/base/power/opp/core.c
> > +++ b/drivers/base/power/opp/core.c
> > @@ -257,7 +257,7 @@ unsigned long dev_pm_opp_get_max_volt_latency(struct device *dev)
> > }
> >
> > reg = dev_opp->regulator;
> > - if (IS_ERR_OR_NULL(reg)) {
> > + if (IS_ERR(reg)) {
> > /* Regulator may not be required for device */
> > if (reg)
> > dev_err(dev, "%s: Invalid regulator (%ld)\n", __func__,
> > @@ -798,6 +798,9 @@ static struct device_opp *_add_device_opp(struct device *dev)
> > of_node_put(np);
> > }
> >
> > + /* Set regulator to a non-NULL error value */
> > + dev_opp->regulator = ERR_PTR(-EFAULT);
> > +
> > /* Find clk for the device */
> > dev_opp->clk = clk_get(dev, NULL);
> > if (IS_ERR(dev_opp->clk)) {
>
> -EFAULT has a very specific meaning (accessing an invalid pointer from
> user space), I don't think you want that one.
Sorry, wasn't aware of those requirements. What Rafael suggested is
the right thing to do then.
--
viresh
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH] PM / OPP: Initialize regulator pointer to an error value Viresh Kumar <viresh.kumar@linaro.org> - 2016-02-15 17:30 +0100
Re: [PATCH] PM / OPP: Initialize regulator pointer to an error value Viresh Kumar <viresh.kumar@linaro.org> - 2016-02-15 17:50 +0100
Re: [PATCH] PM / OPP: Initialize regulator pointer to an error value Jon Hunter <jonathanh@nvidia.com> - 2016-02-15 17:50 +0100
Re: [PATCH] PM / OPP: Initialize regulator pointer to an error value Arnd Bergmann <arnd@arndb.de> - 2016-02-15 21:40 +0100
Re: [PATCH] PM / OPP: Initialize regulator pointer to an error value "Rafael J. Wysocki" <rafael@kernel.org> - 2016-02-15 22:20 +0100
Re: [PATCH] PM / OPP: Initialize regulator pointer to an error value Viresh Kumar <viresh.kumar@linaro.org> - 2016-02-16 01:50 +0100
Re: [PATCH] PM / OPP: Initialize regulator pointer to an error value "Rafael J. Wysocki" <rjw@rjwysocki.net> - 2016-02-16 01:50 +0100
Re: [PATCH] PM / OPP: Initialize regulator pointer to an error value Viresh Kumar <viresh.kumar@linaro.org> - 2016-02-16 02:10 +0100
Re: [PATCH] PM / OPP: Initialize regulator pointer to an error value Mark Brown <broonie@kernel.org> - 2016-02-16 03:00 +0100
Re: [PATCH] PM / OPP: Initialize regulator pointer to an error value Arnd Bergmann <arnd@arndb.de> - 2016-02-16 10:20 +0100
Re: [PATCH] PM / OPP: Initialize regulator pointer to an error value Mark Brown <broonie@kernel.org> - 2016-02-16 14:20 +0100
Re: [PATCH] PM / OPP: Initialize regulator pointer to an error value Arnd Bergmann <arnd@arndb.de> - 2016-02-16 16:20 +0100
Re: [PATCH] PM / OPP: Initialize regulator pointer to an error value Mark Brown <broonie@kernel.org> - 2016-02-16 18:00 +0100
csiph-web