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

From: Mark Brown
Date: Thu Sep 01 2022 - 07:37:00 EST


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.

Attachment: signature.asc
Description: PGP signature