Re: [PATCH 7/9] regulator: da9121: add current support

From: Mark Brown
Date: Fri Nov 20 2020 - 08:17:36 EST


On Fri, Nov 20, 2020 at 12:14:57PM +0000, Adam Ward wrote:

> +static bool da9121_rdev_to_buck_reg_mask(struct regulator_dev *rdev, bool mode,
> + unsigned int *reg, unsigned int *msk)
> +{
> + struct da9121 *chip = rdev_get_drvdata(rdev);
> + int id = rdev_get_id(rdev);
> +
> + switch (id) {
> + case DA9121_IDX_BUCK1:
> + if (mode) {
> + *reg = DA9121_REG_BUCK_BUCK1_4;
> + *msk = DA9121_MASK_BUCK_BUCKx_4_CHx_A_MODE;
> + } else {
> + *reg = DA9121_REG_BUCK_BUCK1_2;
> + *msk = DA9121_MASK_BUCK_BUCKx_2_CHx_ILIM;
> + }
> + break;

This is really not an easy interface to understand, the boolean flag
saying which register set to pick is not particularly obvious to read
and won't scale. The usual pattern with things like this is to store
information in driver data at probe time.

Attachment: signature.asc
Description: PGP signature