2021-06-15 10:41:58

by Axel Lin

[permalink] [raw]
Subject: [PATCH] regulator: rt6160: Remove vsel_active_low from struct rt6160_priv

Use a local variable instead is enough, this simplifies the code.

Signed-off-by: Axel Lin <[email protected]>
---
drivers/regulator/rt6160-regulator.c | 20 +++++++++-----------
1 file changed, 9 insertions(+), 11 deletions(-)

diff --git a/drivers/regulator/rt6160-regulator.c b/drivers/regulator/rt6160-regulator.c
index b6b53868050f..ccd023da4318 100644
--- a/drivers/regulator/rt6160-regulator.c
+++ b/drivers/regulator/rt6160-regulator.c
@@ -42,7 +42,6 @@ struct rt6160_priv {
struct regulator_desc desc;
struct gpio_desc *enable_gpio;
struct regmap *regmap;
- bool vsel_active_low;
bool enable_state;
};

@@ -128,19 +127,15 @@ static unsigned int rt6160_get_mode(struct regulator_dev *rdev)

static int rt6160_set_suspend_voltage(struct regulator_dev *rdev, int uV)
{
- struct rt6160_priv *priv = rdev_get_drvdata(rdev);
struct regmap *regmap = rdev_get_regmap(rdev);
- unsigned int reg = RT6160_REG_VSELH;
int vsel;

vsel = regulator_map_voltage_linear(rdev, uV, uV);
if (vsel < 0)
return vsel;

- if (priv->vsel_active_low)
- reg = RT6160_REG_VSELL;
-
- return regmap_update_bits(regmap, reg, RT6160_VSEL_MASK, vsel);
+ return regmap_update_bits(regmap, rdev->desc->vsel_reg,
+ RT6160_VSEL_MASK, vsel);
}

static int rt6160_get_error_flags(struct regulator_dev *rdev, unsigned int *flags)
@@ -228,6 +223,7 @@ static int rt6160_probe(struct i2c_client *i2c)
struct rt6160_priv *priv;
struct regulator_config regulator_cfg = {};
struct regulator_dev *rdev;
+ bool vsel_active_low;
unsigned int devid;
int ret;

@@ -235,7 +231,8 @@ static int rt6160_probe(struct i2c_client *i2c)
if (!priv)
return -ENOMEM;

- priv->vsel_active_low = device_property_present(&i2c->dev, "richtek,vsel-active-low");
+ vsel_active_low =
+ device_property_present(&i2c->dev, "richtek,vsel-active-low");

priv->enable_gpio = devm_gpiod_get_optional(&i2c->dev, "enable", GPIOD_OUT_HIGH);
if (IS_ERR(priv->enable_gpio)) {
@@ -267,7 +264,10 @@ static int rt6160_probe(struct i2c_client *i2c)
priv->desc.owner = THIS_MODULE;
priv->desc.min_uV = RT6160_VOUT_MINUV;
priv->desc.uV_step = RT6160_VOUT_STPUV;
- priv->desc.vsel_reg = RT6160_REG_VSELH;
+ if (vsel_active_low)
+ priv->desc.vsel_reg = RT6160_REG_VSELL;
+ else
+ priv->desc.vsel_reg = RT6160_REG_VSELH;
priv->desc.vsel_mask = RT6160_VSEL_MASK;
priv->desc.n_voltages = RT6160_N_VOUTS;
priv->desc.ramp_reg = RT6160_REG_CNTL;
@@ -276,8 +276,6 @@ static int rt6160_probe(struct i2c_client *i2c)
priv->desc.n_ramp_values = ARRAY_SIZE(rt6160_ramp_tables);
priv->desc.of_map_mode = rt6160_of_map_mode;
priv->desc.ops = &rt6160_regulator_ops;
- if (priv->vsel_active_low)
- priv->desc.vsel_reg = RT6160_REG_VSELL;

regulator_cfg.dev = &i2c->dev;
regulator_cfg.of_node = i2c->dev.of_node;
--
2.25.1


2021-06-15 15:17:41

by Mark Brown

[permalink] [raw]
Subject: Re: [PATCH] regulator: rt6160: Remove vsel_active_low from struct rt6160_priv

On Tue, 15 Jun 2021 18:39:47 +0800, Axel Lin wrote:
> Use a local variable instead is enough, this simplifies the code.

Applied to

https://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator.git for-next

Thanks!

[1/1] regulator: rt6160: Remove vsel_active_low from struct rt6160_priv
commit: f3f4f37d53be578c65dd32a1ffad432b33aef236

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark

2021-06-15 15:36:51

by ChiYuan Huang

[permalink] [raw]
Subject: Re: [PATCH] regulator: rt6160: Remove vsel_active_low from struct rt6160_priv

Hi, Mark/Axel:
No, you may misunderstand it.
If vsel active is high, the normal voltage output register is vselh register,
and the suspend voltage is vsell register. Else, reverse.

Axel's change will cause the normal/suspend voltage be configured for the same
register. It's not for our reference usage.
> On Tue, 15 Jun 2021 18:39:47 +0800, Axel Lin wrote:
> >
> > Use a local variable instead is enough, this simplifies the code.
> Applied to
>
> https://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator.git for-
> next
>
> Thanks!
>
> [1/1] regulator: rt6160: Remove vsel_active_low from struct rt6160_priv
> commit: f3f4f37d53be578c65dd32a1ffad432b33aef236
>
> All being well this means that it will be integrated into the linux-next
> tree (usually sometime in the next 24 hours) and sent to Linus during
> the next merge window (or sooner if it is a bug fix), however if
> problems are discovered then the patch may be dropped or reverted.
>
> You may get further e-mails resulting from automated or manual testing
> and review of the tree, please engage with people reporting problems and
> send followup patches addressing any issues that are reported if needed.
>
> If any updates are required or you are submitting further changes they
> should be sent as incremental updates against current git, existing
> patches will not be replaced.
>
> Please add any relevant lists and maintainers to the CCs when replying
> to this mail.
>
> Thanks,
> Mark
************* Email Confidentiality Notice ********************

The information contained in this e-mail message (including any attachments) may be confidential, proprietary, privileged, or otherwise exempt from disclosure under applicable laws. It is intended to be conveyed only to the designated recipient(s). Any use, dissemination, distribution, printing, retaining or copying of this e-mail (including its attachments) by unintended recipient(s) is strictly prohibited and may be unlawful. If you are not an intended recipient of this e-mail, or believe that you have received this e-mail in error, please notify the sender immediately (by replying to this e-mail), delete any and all copies of this e-mail (including any attachments) from your system, and do not disclose the content of this e-mail to any other person. Thank you!

2021-06-15 15:37:05

by Mark Brown

[permalink] [raw]
Subject: Re: [PATCH] regulator: rt6160: Remove vsel_active_low from struct rt6160_priv

On Tue, Jun 15, 2021 at 03:24:27PM +0000, cy_huang(黃啟原) wrote:

> No, you may misunderstand it.
> If vsel active is high, the normal voltage output register is vselh register,
> and the suspend voltage is vsell register. Else, reverse.
>
> Axel's change will cause the normal/suspend voltage be configured for the same
> register. It's not for our reference usage.

OK, can you please send a patch fixing this and explaining what the
problem was?


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

2021-06-15 16:10:06

by Mark Brown

[permalink] [raw]
Subject: Re: [PATCH] regulator: rt6160: Remove vsel_active_low from struct rt6160_priv

On Tue, Jun 15, 2021 at 04:04:57PM +0000, cy_huang(黃啟原) wrote:
> Hi, Mark:
>
> OK. Later I'll send one to fix it.
> But based on regulator-next branch?

Yes, please.

Please don't top post, reply in line with needed context. This allows
readers to readily follow the flow of conversation and understand what
you are talking about and also helps ensure that everything in the
discussion is being addressed.


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

2021-06-15 16:17:04

by ChiYuan Huang

[permalink] [raw]
Subject: Re: [PATCH] regulator: rt6160: Remove vsel_active_low from struct rt6160_priv

Hi, Mark:

OK. Later I'll send one to fix it.
But based on regulator-next branch?
************* Email Confidentiality Notice ********************

The information contained in this e-mail message (including any attachments) may be confidential, proprietary, privileged, or otherwise exempt from disclosure under applicable laws. It is intended to be conveyed only to the designated recipient(s). Any use, dissemination, distribution, printing, retaining or copying of this e-mail (including its attachments) by unintended recipient(s) is strictly prohibited and may be unlawful. If you are not an intended recipient of this e-mail, or believe that you have received this e-mail in error, please notify the sender immediately (by replying to this e-mail), delete any and all copies of this e-mail (including any attachments) from your system, and do not disclose the content of this e-mail to any other person. Thank you!