lkml.org 
[lkml]   [2022]   [Sep]   [1]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [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.
[unhandled content-type:application/pgp-signature]
\
 
 \ /
  Last update: 2022-09-01 13:37    [W:0.086 / U:2.476 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site