2024-02-26 13:19:55

by Julien Panis

[permalink] [raw]
Subject: Re: [PATCH v2 08/14] misc: tps6594-pfsm: Add TI TPS65224 PMIC PFSM

On 2/23/24 10:36, Bhargav Raviprakash wrote:
> Add support for TPS65224 PFSM in the TPS6594 PFSM driver
> as they share significant functionality.
>
> Signed-off-by: Bhargav Raviprakash <[email protected]>
> ---
> drivers/misc/tps6594-pfsm.c | 55 +++++++++++++++++++++++++++----------
> 1 file changed, 40 insertions(+), 15 deletions(-)
>
> diff --git a/drivers/misc/tps6594-pfsm.c b/drivers/misc/tps6594-pfsm.c
> index 88dcac814..4fa071093 100644
> --- a/drivers/misc/tps6594-pfsm.c
> +++ b/drivers/misc/tps6594-pfsm.c
> @@ -1,6 +1,6 @@
> // SPDX-License-Identifier: GPL-2.0
> /*
> - * PFSM (Pre-configurable Finite State Machine) driver for TI TPS6594/TPS6593/LP8764 PMICs
> + * PFSM (Pre-configurable Finite State Machine) driver for TI TPS65224/TPS6594/TPS6593/LP8764 PMICs
> *
> * Copyright (C) 2023 BayLibre Incorporated - https://www.baylibre.com/
> */
> @@ -34,15 +34,17 @@
>
> #define TPS6594_FILE_TO_PFSM(f) container_of((f)->private_data, struct tps6594_pfsm, miscdev)
>
> -/**
> +/*

Here it should be /** for the structure documentation, I think.
Please check in kernel doc.

[...]

> @@ -210,8 +230,12 @@ static long tps6594_pfsm_ioctl(struct file *f, unsigned int cmd, unsigned long a
> return ret;
>
> /* Modify NSLEEP1-2 bits */
> - ret = regmap_clear_bits(pfsm->regmap, TPS6594_REG_FSM_NSLEEP_TRIGGERS,
> - TPS6594_BIT_NSLEEP2B);
> + if (pfsm->chip_id == TPS65224)
> + ret = regmap_clear_bits(pfsm->regmap, TPS6594_REG_FSM_NSLEEP_TRIGGERS,
> + TPS6594_BIT_NSLEEP1B);
> + else
> + ret = regmap_clear_bits(pfsm->regmap, TPS6594_REG_FSM_NSLEEP_TRIGGERS,
> + TPS6594_BIT_NSLEEP2B);

Instead of this if/else, a ternary operator might do the trick here:
regmap_clear_bits(pfsm->regmap, TPS6594_REG_FSM_NSLEEP_TRIGGERS,
                              pfsm->chip_id == TPS65224 ? TPS6594_BIT_NSLEEP1B : TPS6594_BIT_NSLEEP2B)

Julien



2024-03-07 09:18:44

by Bhargav Raviprakash

[permalink] [raw]
Subject: Re: [PATCH v2 08/14] misc: tps6594-pfsm: Add TI TPS65224 PMIC PFSM

Hi,

On Mon, 26 Feb 2024 13:43:51 +0100, Julien Panis wrote:
> On 2/23/24 10:36, Bhargav Raviprakash wrote:
> > Add support for TPS65224 PFSM in the TPS6594 PFSM driver
> > as they share significant functionality.
> >
> > Signed-off-by: Bhargav Raviprakash <[email protected]>
> > ---
> > drivers/misc/tps6594-pfsm.c | 55 +++++++++++++++++++++++++++----------
> > 1 file changed, 40 insertions(+), 15 deletions(-)
> >
> > diff --git a/drivers/misc/tps6594-pfsm.c b/drivers/misc/tps6594-pfsm.c
> > index 88dcac814..4fa071093 100644
> > --- a/drivers/misc/tps6594-pfsm.c
> > +++ b/drivers/misc/tps6594-pfsm.c
> > @@ -1,6 +1,6 @@
> > // SPDX-License-Identifier: GPL-2.0
> > /*
> > - * PFSM (Pre-configurable Finite State Machine) driver for TI TPS6594/TPS6593/LP8764 PMICs
> > + * PFSM (Pre-configurable Finite State Machine) driver for TI TPS65224/TPS6594/TPS6593/LP8764 PMICs
> > *
> > * Copyright (C) 2023 BayLibre Incorporated - https://www.baylibre.com/
> > */
> > @@ -34,15 +34,17 @@
> >
> > #define TPS6594_FILE_TO_PFSM(f) container_of((f)->private_data, struct tps6594_pfsm, miscdev)
> >
> > -/**
> > +/*
>
> Here it should be /** for the structure documentation, I think.
> Please check in kernel doc.
>

Thanks for pointing it out! Will fix it in the next version.

> [...]
>
> > @@ -210,8 +230,12 @@ static long tps6594_pfsm_ioctl(struct file *f, unsigned int cmd, unsigned long a
> > return ret;
> >
> > /* Modify NSLEEP1-2 bits */
> > - ret = regmap_clear_bits(pfsm->regmap, TPS6594_REG_FSM_NSLEEP_TRIGGERS,
> > - TPS6594_BIT_NSLEEP2B);
> > + if (pfsm->chip_id == TPS65224)
> > + ret = regmap_clear_bits(pfsm->regmap, TPS6594_REG_FSM_NSLEEP_TRIGGERS,
> > + TPS6594_BIT_NSLEEP1B);
> > + else
> > + ret = regmap_clear_bits(pfsm->regmap, TPS6594_REG_FSM_NSLEEP_TRIGGERS,
> > + TPS6594_BIT_NSLEEP2B);
>
> Instead of this if/else, a ternary operator might do the trick here:
> regmap_clear_bits(pfsm->regmap, TPS6594_REG_FSM_NSLEEP_TRIGGERS,
> pfsm->chip_id == TPS65224 ? TPS6594_BIT_NSLEEP1B : TPS6594_BIT_NSLEEP2B)
>
> Julien

Sure, this looks neat :-). We will use ternary operator here in the next version.
Thanks!

Regards,
Bhargav