LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH] regulator: rtq6752: Enclose 'enable' gpio control by enable flag
@ 2021-09-14 13:58 cy_huang
2021-09-14 14:07 ` Mark Brown
0 siblings, 1 reply; 3+ messages in thread
From: cy_huang @ 2021-09-14 13:58 UTC (permalink / raw)
To: broonie; +Cc: lgirdwood, linux-kernel, cy_huang
From: ChiYuan Huang <cy_huang@richtek.com>
Fix 'enable' gpio control logic if it's specified.
Signed-off-by: ChiYuan Huang <cy_huang@richtek.com>
---
This patch is to prevent the logic error from the below cases.
1. All off and both are sequentially controlled to be on.
The 'enable' gpio control block to be called twice including the delay time.
2. Both are on and one is preparing to be off.
The 'enable' gpio control low before register cache is configured to be true.
---
drivers/regulator/rtq6752-regulator.c | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
diff --git a/drivers/regulator/rtq6752-regulator.c b/drivers/regulator/rtq6752-regulator.c
index 609d3fc..dfe45fb 100644
--- a/drivers/regulator/rtq6752-regulator.c
+++ b/drivers/regulator/rtq6752-regulator.c
@@ -54,14 +54,14 @@ static int rtq6752_set_vdd_enable(struct regulator_dev *rdev)
int rid = rdev_get_id(rdev), ret;
mutex_lock(&priv->lock);
- if (priv->enable_gpio) {
- gpiod_set_value(priv->enable_gpio, 1);
+ if (!priv->enable_flag) {
+ if (priv->enable_gpio) {
+ gpiod_set_value(priv->enable_gpio, 1);
- usleep_range(RTQ6752_I2CRDY_TIMEUS,
- RTQ6752_I2CRDY_TIMEUS + 100);
- }
+ usleep_range(RTQ6752_I2CRDY_TIMEUS,
+ RTQ6752_I2CRDY_TIMEUS + 100);
+ }
- if (!priv->enable_flag) {
regcache_cache_only(priv->regmap, false);
ret = regcache_sync(priv->regmap);
if (ret) {
@@ -91,11 +91,11 @@ static int rtq6752_set_vdd_disable(struct regulator_dev *rdev)
if (!priv->enable_flag) {
regcache_cache_only(priv->regmap, true);
regcache_mark_dirty(priv->regmap);
- }
- if (priv->enable_gpio)
- gpiod_set_value(priv->enable_gpio, 0);
+ if (priv->enable_gpio)
+ gpiod_set_value(priv->enable_gpio, 0);
+ }
mutex_unlock(&priv->lock);
return 0;
--
2.7.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] regulator: rtq6752: Enclose 'enable' gpio control by enable flag
2021-09-14 13:58 [PATCH] regulator: rtq6752: Enclose 'enable' gpio control by enable flag cy_huang
@ 2021-09-14 14:07 ` Mark Brown
2021-09-14 14:11 ` ChiYuan Huang
0 siblings, 1 reply; 3+ messages in thread
From: Mark Brown @ 2021-09-14 14:07 UTC (permalink / raw)
To: cy_huang; +Cc: lgirdwood, linux-kernel, cy_huang
[-- Attachment #1: Type: text/plain, Size: 623 bytes --]
On Tue, Sep 14, 2021 at 09:58:32PM +0800, cy_huang wrote:
> From: ChiYuan Huang <cy_huang@richtek.com>
>
> Fix 'enable' gpio control logic if it's specified.
>
> Signed-off-by: ChiYuan Huang <cy_huang@richtek.com>
> ---
> This patch is to prevent the logic error from the below cases.
>
> 1. All off and both are sequentially controlled to be on.
> The 'enable' gpio control block to be called twice including the delay time.
>
> 2. Both are on and one is preparing to be off.
> The 'enable' gpio control low before register cache is configured to be true.
This should be in the actual commit message.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] regulator: rtq6752: Enclose 'enable' gpio control by enable flag
2021-09-14 14:07 ` Mark Brown
@ 2021-09-14 14:11 ` ChiYuan Huang
0 siblings, 0 replies; 3+ messages in thread
From: ChiYuan Huang @ 2021-09-14 14:11 UTC (permalink / raw)
To: Mark Brown; +Cc: Liam Girdwood, lkml, cy_huang
Hi,
Mark Brown <broonie@kernel.org> 於 2021年9月14日 週二 下午10:08寫道:
>
> On Tue, Sep 14, 2021 at 09:58:32PM +0800, cy_huang wrote:
> > From: ChiYuan Huang <cy_huang@richtek.com>
> >
> > Fix 'enable' gpio control logic if it's specified.
> >
> > Signed-off-by: ChiYuan Huang <cy_huang@richtek.com>
> > ---
> > This patch is to prevent the logic error from the below cases.
> >
> > 1. All off and both are sequentially controlled to be on.
> > The 'enable' gpio control block to be called twice including the delay time.
> >
> > 2. Both are on and one is preparing to be off.
> > The 'enable' gpio control low before register cache is configured to be true.
>
> This should be in the actual commit message.
OK, I'll send the v2 and add all comments into the commit message.
Thx.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-09-14 14:11 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-14 13:58 [PATCH] regulator: rtq6752: Enclose 'enable' gpio control by enable flag cy_huang
2021-09-14 14:07 ` Mark Brown
2021-09-14 14:11 ` ChiYuan Huang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).