Re: [PATCH v2 5/6] regulator: bcm590xx: Add support for BCM59054

From: Mark Brown
Date: Tue Oct 31 2023 - 08:41:53 EST


On Mon, Oct 30, 2023 at 08:41:47PM +0100, Artur Weber wrote:
> The BCM59054 is fairly similar in terms of regulators to the already
> supported BCM59056, as included in the BCM590XX driver.

> Add support for the BCM59054's regulators to the BCM590XX driver.
> Switch from using defines for common checks to using functions which
> return different values depending on the identified MFD model.

> While we're at it, fix a bug where the enable/vsel register
> offsets for GPLDO and LDO regulators were calculated incorrectly.

> Also, change the regulator enable bitmask to cover the entire PMMODE
> register.

As is very clear from the commit log this is a whole bunch of changes
which really should be split out into multiple patches. There's the
bug fix, there's the multiple refactorings to support the new device and
the new device itself. As covered in submitting-patches.rst you should
do one change per patch, this makes things much easier to follow.

> + if (pmu->mfd->device_type == BCM59054_TYPE) {
> + info = bcm59054_regs;
> + n_regulators = BCM59054_NUM_REGS;
> + } else if (pmu->mfd->device_type == BCM59056_TYPE) {
> + info = bcm59056_regs;
> + n_regulators = BCM59056_NUM_REGS;
> + }

There's no error handling here if there's an unknown type.

> - if ((BCM590XX_REG_IS_LDO(i)) || (BCM590XX_REG_IS_GPLDO(i))) {
> + if (bcm590xx_reg_is_ldo(pmu, i) || \
> + bcm590xx_reg_is_gpldo(pmu, i)) {
> pmu->desc[i].ops = &bcm590xx_ops_ldo;
> pmu->desc[i].vsel_mask = BCM590XX_LDO_VSEL_MASK;
> - } else if (BCM590XX_REG_IS_VBUS(i))
> - pmu->desc[i].ops = &bcm590xx_ops_vbus;
> - else {
> + } else if (bcm590xx_reg_is_static(pmu, i)) {
> + pmu->desc[i].ops = &bcm590xx_ops_static;
> + } else {
> pmu->desc[i].ops = &bcm590xx_ops_dcdc;
> pmu->desc[i].vsel_mask = BCM590XX_SR_VSEL_MASK;
> }

It seems like everything would be a lot simpler and clearer to just have
tables of regulators per device rather than have all these conditionals.

Attachment: signature.asc
Description: PGP signature