[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <YxCZUGPVQwrefLJi@sirena.org.uk>
Date: Thu, 1 Sep 2022 12:36:48 +0100
From: Mark Brown <broonie@...nel.org>
To: Sebastian Reichel <sebastian.reichel@...labora.com>
Cc: Heiko Stuebner <heiko@...ech.de>, Rob Herring <robh+dt@...nel.org>,
Krzysztof Kozlowski <krzysztof.kozlowski+dt@...aro.org>,
Lee Jones <lee@...nel.org>,
Michael Turquette <mturquette@...libre.com>,
Stephen Boyd <sboyd@...nel.org>,
Linus Walleij <linus.walleij@...aro.org>,
Liam Girdwood <lgirdwood@...il.com>,
Alexandre Belloni <alexandre.belloni@...tlin.com>,
Alessandro Zummo <a.zummo@...ertech.it>,
linux-rockchip@...ts.infradead.org, devicetree@...r.kernel.org,
linux-kernel@...r.kernel.org, kernel@...labora.com,
shengfei Xu <xsf@...k-chips.com>
Subject: Re: [PATCH 12/13] regulator: rk808: add rk806 support
On Wed, Aug 31, 2022 at 11:54:36PM +0200, Sebastian Reichel wrote:
> +static int rk806_get_reg_offset(int id)
> +{
> + int reg_offset = 0;
> +
> + if (id >= RK806_ID_DCDC1 && id <= RK806_ID_DCDC10)
> + reg_offset = RK806_DCDC_SLP_REG_OFFSET;
> + else if ((id >= RK806_ID_NLDO1 && id <= RK806_ID_NLDO4) ||
> + (id == RK806_ID_NLDO5))
> + reg_offset = RK806_NLDO_SLP_REG_OFFSET;
> + else if (id >= RK806_ID_PLDO1 && id <= RK806_ID_PLDO6)
> + reg_offset = RK806_PLDO_SLP_REG_OFFSET;
> +
> + return reg_offset;
> +}
Use separate operations and/or separate data and decide at probe time
which data to use for which regulator, don't have a switch statement at
runtime like this. This reduces the amount of open coding in the driver
and opens up more opportinuties for improving things in the framework.
Download attachment "signature.asc" of type "application/pgp-signature" (489 bytes)
Powered by blists - more mailing lists