From: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
To: Bjorn Helgaas <helgaas@kernel.org>
Cc: Mark Brown <broonie@kernel.org>,
Robin Murphy <robin.murphy@arm.com>,
shawn.lin@rock-chips.com, andrew.murray@arm.com, heiko@sntech.de,
lgirdwood@gmail.com, linux-pci@vger.kernel.org,
linux-rockchip@lists.infradead.org,
linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH 2/2] PCI: rockchip: Simplify optional regulator handling
Date: Mon, 18 Nov 2019 18:15:38 +0000 [thread overview]
Message-ID: <20191118181538.GA2261@e121166-lin.cambridge.arm.com> (raw)
In-Reply-To: <20191118142428.GA27459@google.com>
On Mon, Nov 18, 2019 at 08:24:28AM -0600, Bjorn Helgaas wrote:
> On Mon, Nov 18, 2019 at 11:59:30AM +0000, Mark Brown wrote:
> > On Sat, Nov 16, 2019 at 12:54:20PM +0000, Robin Murphy wrote:
> > > Null checks are both cheaper and more readable than having !IS_ERR()
> > > splattered everywhere.
> >
> > > - if (IS_ERR(rockchip->vpcie3v3))
> > > + if (!rockchip->vpcie3v3)
> > > return;
> > >
> > > /*
> > > @@ -611,6 +611,7 @@ static int rockchip_pcie_parse_host_dt(struct rockchip_pcie *rockchip)
> > > if (PTR_ERR(rockchip->vpcie12v) != -ENODEV)
> > > return PTR_ERR(rockchip->vpcie12v);
> > > dev_info(dev, "no vpcie12v regulator found\n");
> > > + rockchip->vpcie12v = NULL;
> >
> > According to the API NULL is a valid regulator. We don't currently
> > actually do this but it's storing up surprises if you treat it as
> > invalid.
>
> I don't know anything about the regulator API, but the fact that NULL
> can be a valid regulator is itself a little surprising :)
if (rockchip->vpcie3v3 == NULL) is true the driver would currently
panic the kernel AFAICS.
rockchip_pcie_set_power_limit()
->regulator_get_current_limit(NULL)
-> _regulator_get_current_limit(NULL)
-> regulator_lock(NULL)
-> regulator_lock_nested(NULL, NULL)
-> ww_mutex_trylock(&NULL->mutex)
Also, by making NULL a valid regulator, it means that regulators
(ie pointers) with default values are valid whether we call
devm_regulator_get* or not. I understand this patch can be dropped
but that per-se does not make this driver code any more robust AFAICS.
Lorenzo
next prev parent reply other threads:[~2019-11-18 18:15 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-11-16 12:54 [PATCH 1/2] PCI: rockchip: Make some regulators non-optional Robin Murphy
2019-11-16 12:54 ` [PATCH 2/2] PCI: rockchip: Simplify optional regulator handling Robin Murphy
2019-11-18 11:59 ` Mark Brown
2019-11-18 12:20 ` Robin Murphy
2019-11-18 12:39 ` Andrew Murray
2019-11-18 13:10 ` Robin Murphy
2019-11-18 13:17 ` Andrew Murray
2019-11-18 14:24 ` Bjorn Helgaas
2019-11-18 18:15 ` Lorenzo Pieralisi [this message]
2019-11-18 18:38 ` Mark Brown
2019-11-18 11:57 ` [PATCH 1/2] PCI: rockchip: Make some regulators non-optional Mark Brown
2019-11-18 12:28 ` Andrew Murray
2019-11-20 17:05 ` Lorenzo Pieralisi
2020-11-07 11:36 ` Qu Wenruo
2020-11-07 11:57 ` Qu Wenruo
2020-11-07 12:47 ` Robin Murphy
2020-11-07 12:54 ` Qu Wenruo
2020-11-07 13:30 ` Qu Wenruo
2020-11-09 12:00 ` Robin Murphy
2020-11-09 12:38 ` Qu Wenruo
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=20191118181538.GA2261@e121166-lin.cambridge.arm.com \
--to=lorenzo.pieralisi@arm.com \
--cc=andrew.murray@arm.com \
--cc=broonie@kernel.org \
--cc=heiko@sntech.de \
--cc=helgaas@kernel.org \
--cc=lgirdwood@gmail.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-pci@vger.kernel.org \
--cc=linux-rockchip@lists.infradead.org \
--cc=robin.murphy@arm.com \
--cc=shawn.lin@rock-chips.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).