2024-02-29 14:43:08

by Esteban Blanc

[permalink] [raw]
Subject: Re: [PATCH v2 12/14] regulator: tps6594-regulator: Add TI TPS65224 PMIC regulators

On Fri Feb 23, 2024 at 10:36 AM CET, Bhargav Raviprakash wrote:
> From: Nirmala Devi Mal Nadar <[email protected]>

> @@ -122,6 +131,27 @@ static const struct linear_range ldos_4_ranges[] = {
> REGULATOR_LINEAR_RANGE(1200000, 0x20, 0x74, 25000),
> };
>
> +/* Voltage range for TPS65224 Bucks and LDOs */
> +static const struct linear_range tps65224_bucks_1_ranges[] = {

You prefixed your arrays with `tps65224` and that makes sense. However
you should also prefix the old ones with `tps6594` then.
This applies to the whole driver.

> @@ -374,11 +518,17 @@ static int tps6594_request_reg_irqs(struct platform_device *pdev,
> {
> struct tps6594_regulator_irq_type *irq_type;
> struct tps6594 *tps = dev_get_drvdata(pdev->dev.parent);
> - int j;
> + size_t j;
> int irq;
> int error;
> + size_t interrupt_cnt;
>
> - for (j = 0; j < REGS_INT_NB; j++) {
> + /* Number of interrupts supported by each voltage source */
> + interrupt_cnt = (tps->chip_id == TPS6594) ?
> + ARRAY_SIZE(tps6594_buck1_irq_types) :
> + ARRAY_SIZE(tps65224_buck1_irq_types);

The comment is not adding anything, the name is clear and ARRAY_SIZE is
quite explicit.

> + for (i = 0; i < LDO_NB; i++) {
> + if (ldo_configured[i] == 1)
> + continue;
>
> - error = tps6594_request_reg_irqs(pdev, rdev, irq_data,
> - tps6594_ldos_irq_types[i],
> - &irq_idx);
> - if (error)
> - return error;
> + struct tps6594_regulator_irq_type **ldos_irq_types = (tps->chip_id == TPS65224) ?
> + tps65224_ldos_irq_types :
> + tps6594_ldos_irq_types;
> +
> + const struct regulator_desc *ldo_regs = (tps->chip_id == TPS65224) ?
> + tps65224_ldo_regs :
> + tps6594_ldo_regs;
> +
> + rdev = devm_regulator_register(&pdev->dev, &ldo_regs[i], &config);
> + if (IS_ERR(rdev))
> + return dev_err_probe(tps->dev, PTR_ERR(rdev),
> + "failed to register %s regulator\n", pdev->name);
> +
> + error = tps6594_request_reg_irqs(pdev, rdev, irq_data, ldos_irq_types[i], &irq_idx);
> + if (error)
> + return error;

There is an indentation missing on the content of the `for` loop.

Best regards,

--
Esteban "Skallwar" Blanc
BayLibre


2024-02-29 14:50:13

by Mark Brown

[permalink] [raw]
Subject: Re: [PATCH v2 12/14] regulator: tps6594-regulator: Add TI TPS65224 PMIC regulators

On Thu, Feb 29, 2024 at 03:42:50PM +0100, Esteban Blanc wrote:
> On Fri Feb 23, 2024 at 10:36 AM CET, Bhargav Raviprakash wrote:

> > + /* Number of interrupts supported by each voltage source */
> > + interrupt_cnt = (tps->chip_id == TPS6594) ?
> > + ARRAY_SIZE(tps6594_buck1_irq_types) :
> > + ARRAY_SIZE(tps65224_buck1_irq_types);

> The comment is not adding anything, the name is clear and ARRAY_SIZE is
> quite explicit.

Also please don't abuse the ternery operator like this, write normal
conditionals or for a case like this where we may get more options in
future use switch statements.


Attachments:
(No filename) (617.00 B)
signature.asc (499.00 B)
Download all attachments

2024-03-07 09:19:12

by Bhargav Raviprakash

[permalink] [raw]
Subject: Re: [PATCH v2 12/14] regulator: tps6594-regulator: Add TI TPS65224 PMIC regulators

Hello,

On Thu, 29 Feb 2024 15:42:50 +0100, Esteban Blanc wrote:
> On Fri Feb 23, 2024 at 10:36 AM CET, Bhargav Raviprakash wrote:
> > From: Nirmala Devi Mal Nadar <[email protected]>
>
> > @@ -122,6 +131,27 @@ static const struct linear_range ldos_4_ranges[] = {
> > REGULATOR_LINEAR_RANGE(1200000, 0x20, 0x74, 25000),
> > };
> >
> > +/* Voltage range for TPS65224 Bucks and LDOs */
> > +static const struct linear_range tps65224_bucks_1_ranges[] = {
>
> You prefixed your arrays with `tps65224` and that makes sense. However
> you should also prefix the old ones with `tps6594` then.
> This applies to the whole driver.
>

Thnaks for the feedback! We will work on it.

> > @@ -374,11 +518,17 @@ static int tps6594_request_reg_irqs(struct platform_device *pdev,
> > {
> > struct tps6594_regulator_irq_type *irq_type;
> > struct tps6594 *tps = dev_get_drvdata(pdev->dev.parent);
> > - int j;
> > + size_t j;
> > int irq;
> > int error;
> > + size_t interrupt_cnt;
> >
> > - for (j = 0; j < REGS_INT_NB; j++) {
> > + /* Number of interrupts supported by each voltage source */
> > + interrupt_cnt = (tps->chip_id == TPS6594) ?
> > + ARRAY_SIZE(tps6594_buck1_irq_types) :
> > + ARRAY_SIZE(tps65224_buck1_irq_types);
>
> The comment is not adding anything, the name is clear and ARRAY_SIZE is
> quite explicit.
>

Sure, will remove it.

> > + for (i = 0; i < LDO_NB; i++) {
> > + if (ldo_configured[i] == 1)
> > + continue;
> >
> > - error = tps6594_request_reg_irqs(pdev, rdev, irq_data,
> > - tps6594_ldos_irq_types[i],
> > - &irq_idx);
> > - if (error)
> > - return error;
> > + struct tps6594_regulator_irq_type **ldos_irq_types = (tps->chip_id == TPS65224) ?
> > + tps65224_ldos_irq_types :
> > + tps6594_ldos_irq_types;
> > +
> > + const struct regulator_desc *ldo_regs = (tps->chip_id == TPS65224) ?
> > + tps65224_ldo_regs :
> > + tps6594_ldo_regs;
> > +
> > + rdev = devm_regulator_register(&pdev->dev, &ldo_regs[i], &config);
> > + if (IS_ERR(rdev))
> > + return dev_err_probe(tps->dev, PTR_ERR(rdev),
> > + "failed to register %s regulator\n", pdev->name);
> > +
> > + error = tps6594_request_reg_irqs(pdev, rdev, irq_data, ldos_irq_types[i], &irq_idx);
> > + if (error)
> > + return error;
>
> There is an indentation missing on the content of the `for` loop.
>

Thanks for pointing it out.
It will be fixed in the next version.

> Best regards,
>
> --
> Esteban "Skallwar" Blanc
> BayLibre

Regards,
Bhargav

2024-03-07 09:20:32

by Bhargav Raviprakash

[permalink] [raw]
Subject: Re: [PATCH v2 12/14] regulator: tps6594-regulator: Add TI TPS65224 PMIC regulators

Hi,
On Thu, 29 Feb 2024 14:49:16 +0000, Mark Brown wrote:
> On Thu, Feb 29, 2024 at 03:42:50PM +0100, Esteban Blanc wrote:
> > On Fri Feb 23, 2024 at 10:36 AM CET, Bhargav Raviprakash wrote:
>
> > > + /* Number of interrupts supported by each voltage source */
> > > + interrupt_cnt = (tps->chip_id == TPS6594) ?
> > > + ARRAY_SIZE(tps6594_buck1_irq_types) :
> > > + ARRAY_SIZE(tps65224_buck1_irq_types);
>
> > The comment is not adding anything, the name is clear and ARRAY_SIZE is
> > quite explicit.
>
> Also please don't abuse the ternery operator like this, write normal
> conditionals or for a case like this where we may get more options in
> future use switch statements.

Got it! will fix it in the next version.

Regards,
Bhargav