From mboxrd@z Thu Jan 1 00:00:00 1970 From: Bjorn Helgaas Subject: Re: [PATCH 2/2] PCI: rockchip: Simplify optional regulator handling Date: Mon, 18 Nov 2019 08:24:28 -0600 Message-ID: <20191118142428.GA27459@google.com> References: <20191118115930.GC9761@sirena.org.uk> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Content-Disposition: inline In-Reply-To: <20191118115930.GC9761@sirena.org.uk> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=m.gmane.org@lists.infradead.org To: Mark Brown Cc: lorenzo.pieralisi@arm.com, heiko@sntech.de, linux-pci@vger.kernel.org, shawn.lin@rock-chips.com, lgirdwood@gmail.com, linux-rockchip@lists.infradead.org, andrew.murray@arm.com, Robin Murphy , linux-arm-kernel@lists.infradead.org List-Id: linux-rockchip.vger.kernel.org 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 :)