[PATCH 12/13] regulator: rk808: add rk806 support

Mark Brown broonie at kernel.org
Thu Sep 1 04:36:48 PDT 2022


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.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-rockchip/attachments/20220901/2baa79ee/attachment.sig>


More information about the Linux-rockchip mailing list