linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ASoC: tlv320aic31xx: Remove regulator notification handling
@ 2018-08-31 18:17 Andrew F. Davis
  2018-09-03 11:30 ` Mark Brown
  0 siblings, 1 reply; 7+ messages in thread
From: Andrew F. Davis @ 2018-08-31 18:17 UTC (permalink / raw)
  To: Liam Girdwood, Mark Brown; +Cc: alsa-devel, linux-kernel, Andrew F . Davis

The notification handler sets the reset line but never re-enables it
as no one is listening for an enable event, this is certainly broken
and was most likely just copied from other CODECs, remove this code.

Signed-off-by: Andrew F. Davis <afd@ti.com>
---
 sound/soc/codecs/tlv320aic31xx.c | 55 +-------------------------------
 1 file changed, 1 insertion(+), 54 deletions(-)

diff --git a/sound/soc/codecs/tlv320aic31xx.c b/sound/soc/codecs/tlv320aic31xx.c
index 7d87df518fed..f8d0f3ebed9c 100644
--- a/sound/soc/codecs/tlv320aic31xx.c
+++ b/sound/soc/codecs/tlv320aic31xx.c
@@ -147,11 +147,6 @@ static const char * const aic31xx_supply_names[] = {
 
 #define AIC31XX_NUM_SUPPLIES ARRAY_SIZE(aic31xx_supply_names)
 
-struct aic31xx_disable_nb {
-	struct notifier_block nb;
-	struct aic31xx_priv *aic31xx;
-};
-
 struct aic31xx_priv {
 	struct snd_soc_component *component;
 	u8 i2c_regs_status;
@@ -162,7 +157,6 @@ struct aic31xx_priv {
 	int micbias_vg;
 	struct aic31xx_pdata pdata;
 	struct regulator_bulk_data supplies[AIC31XX_NUM_SUPPLIES];
-	struct aic31xx_disable_nb disable_nb[AIC31XX_NUM_SUPPLIES];
 	unsigned int sysclk;
 	u8 p_div;
 	int rate_div_line;
@@ -1116,28 +1110,6 @@ static int aic31xx_set_dai_sysclk(struct snd_soc_dai *codec_dai,
 	return 0;
 }
 
-static int aic31xx_regulator_event(struct notifier_block *nb,
-				   unsigned long event, void *data)
-{
-	struct aic31xx_disable_nb *disable_nb =
-		container_of(nb, struct aic31xx_disable_nb, nb);
-	struct aic31xx_priv *aic31xx = disable_nb->aic31xx;
-
-	if (event & REGULATOR_EVENT_DISABLE) {
-		/*
-		 * Put codec to reset and as at least one of the
-		 * supplies was disabled.
-		 */
-		if (aic31xx->gpio_reset)
-			gpiod_set_value(aic31xx->gpio_reset, 1);
-
-		regcache_mark_dirty(aic31xx->regmap);
-		dev_dbg(aic31xx->dev, "## %s: DISABLE received\n", __func__);
-	}
-
-	return 0;
-}
-
 static int aic31xx_reset(struct aic31xx_priv *aic31xx)
 {
 	int ret = 0;
@@ -1263,26 +1235,12 @@ static int aic31xx_set_bias_level(struct snd_soc_component *component,
 static int aic31xx_codec_probe(struct snd_soc_component *component)
 {
 	struct aic31xx_priv *aic31xx = snd_soc_component_get_drvdata(component);
-	int i, ret;
+	int ret;
 
 	dev_dbg(aic31xx->dev, "## %s\n", __func__);
 
 	aic31xx->component = component;
 
-	for (i = 0; i < ARRAY_SIZE(aic31xx->supplies); i++) {
-		aic31xx->disable_nb[i].nb.notifier_call =
-			aic31xx_regulator_event;
-		aic31xx->disable_nb[i].aic31xx = aic31xx;
-		ret = regulator_register_notifier(aic31xx->supplies[i].consumer,
-						  &aic31xx->disable_nb[i].nb);
-		if (ret) {
-			dev_err(component->dev,
-				"Failed to request regulator notifier: %d\n",
-				ret);
-			return ret;
-		}
-	}
-
 	regcache_cache_only(aic31xx->regmap, true);
 	regcache_mark_dirty(aic31xx->regmap);
 
@@ -1297,19 +1255,8 @@ static int aic31xx_codec_probe(struct snd_soc_component *component)
 	return 0;
 }
 
-static void aic31xx_codec_remove(struct snd_soc_component *component)
-{
-	struct aic31xx_priv *aic31xx = snd_soc_component_get_drvdata(component);
-	int i;
-
-	for (i = 0; i < ARRAY_SIZE(aic31xx->supplies); i++)
-		regulator_unregister_notifier(aic31xx->supplies[i].consumer,
-					      &aic31xx->disable_nb[i].nb);
-}
-
 static const struct snd_soc_component_driver soc_codec_driver_aic31xx = {
 	.probe			= aic31xx_codec_probe,
-	.remove			= aic31xx_codec_remove,
 	.set_bias_level		= aic31xx_set_bias_level,
 	.controls		= common31xx_snd_controls,
 	.num_controls		= ARRAY_SIZE(common31xx_snd_controls),
-- 
2.18.0


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH] ASoC: tlv320aic31xx: Remove regulator notification handling
  2018-08-31 18:17 [PATCH] ASoC: tlv320aic31xx: Remove regulator notification handling Andrew F. Davis
@ 2018-09-03 11:30 ` Mark Brown
  2018-09-04 14:50   ` Andrew F. Davis
  0 siblings, 1 reply; 7+ messages in thread
From: Mark Brown @ 2018-09-03 11:30 UTC (permalink / raw)
  To: Andrew F. Davis; +Cc: Liam Girdwood, alsa-devel, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 394 bytes --]

On Fri, Aug 31, 2018 at 01:17:37PM -0500, Andrew F. Davis wrote:
> The notification handler sets the reset line but never re-enables it
> as no one is listening for an enable event, this is certainly broken
> and was most likely just copied from other CODECs, remove this code.

Why not fix it?  The usual pattern would be to take the CODEC out of
reset when bringing the bias back to standby.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] ASoC: tlv320aic31xx: Remove regulator notification handling
  2018-09-03 11:30 ` Mark Brown
@ 2018-09-04 14:50   ` Andrew F. Davis
  2018-09-04 14:57     ` Mark Brown
  0 siblings, 1 reply; 7+ messages in thread
From: Andrew F. Davis @ 2018-09-04 14:50 UTC (permalink / raw)
  To: Mark Brown; +Cc: Liam Girdwood, alsa-devel, linux-kernel

On 09/03/2018 06:30 AM, Mark Brown wrote:
> On Fri, Aug 31, 2018 at 01:17:37PM -0500, Andrew F. Davis wrote:
>> The notification handler sets the reset line but never re-enables it
>> as no one is listening for an enable event, this is certainly broken
>> and was most likely just copied from other CODECs, remove this code.
> 
> Why not fix it?  The usual pattern would be to take the CODEC out of
> reset when bringing the bias back to standby.
> 

The only time this code gets called outside of the normal power on/off
path is regulator_force_disable(). And the enable event is only called
inside regulator_enable() which would already be part of the normal
power up path.

I still don't see the need for this code at all, I do not want to fix
unused broken code, and if no one else will fix it, the code should be
dropped.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] ASoC: tlv320aic31xx: Remove regulator notification handling
  2018-09-04 14:50   ` Andrew F. Davis
@ 2018-09-04 14:57     ` Mark Brown
  2018-09-04 15:03       ` Andrew F. Davis
  0 siblings, 1 reply; 7+ messages in thread
From: Mark Brown @ 2018-09-04 14:57 UTC (permalink / raw)
  To: Andrew F. Davis; +Cc: Liam Girdwood, alsa-devel, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 975 bytes --]

On Tue, Sep 04, 2018 at 09:50:50AM -0500, Andrew F. Davis wrote:
> On 09/03/2018 06:30 AM, Mark Brown wrote:
> > On Fri, Aug 31, 2018 at 01:17:37PM -0500, Andrew F. Davis wrote:
> >> The notification handler sets the reset line but never re-enables it
> >> as no one is listening for an enable event, this is certainly broken
> >> and was most likely just copied from other CODECs, remove this code.

> > Why not fix it?  The usual pattern would be to take the CODEC out of
> > reset when bringing the bias back to standby.

> The only time this code gets called outside of the normal power on/off
> path is regulator_force_disable(). And the enable event is only called
> inside regulator_enable() which would already be part of the normal
> power up path.

It's there to save us having to rewrite the register cache if we asked
for the device to be powered down but that didn't actually happen due to
other constraints, we know all the registers are still as we left them.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] ASoC: tlv320aic31xx: Remove regulator notification handling
  2018-09-04 14:57     ` Mark Brown
@ 2018-09-04 15:03       ` Andrew F. Davis
  2018-09-04 15:49         ` Mark Brown
  0 siblings, 1 reply; 7+ messages in thread
From: Andrew F. Davis @ 2018-09-04 15:03 UTC (permalink / raw)
  To: Mark Brown; +Cc: Liam Girdwood, alsa-devel, linux-kernel

On 09/04/2018 09:57 AM, Mark Brown wrote:
> On Tue, Sep 04, 2018 at 09:50:50AM -0500, Andrew F. Davis wrote:
>> On 09/03/2018 06:30 AM, Mark Brown wrote:
>>> On Fri, Aug 31, 2018 at 01:17:37PM -0500, Andrew F. Davis wrote:
>>>> The notification handler sets the reset line but never re-enables it
>>>> as no one is listening for an enable event, this is certainly broken
>>>> and was most likely just copied from other CODECs, remove this code.
> 
>>> Why not fix it?  The usual pattern would be to take the CODEC out of
>>> reset when bringing the bias back to standby.
> 
>> The only time this code gets called outside of the normal power on/off
>> path is regulator_force_disable(). And the enable event is only called
>> inside regulator_enable() which would already be part of the normal
>> power up path.
> 
> It's there to save us having to rewrite the register cache if we asked
> for the device to be powered down but that didn't actually happen due to
> other constraints, we know all the registers are still as we left them.
> 

I don't see that happening for any other user of this, we will still
have to re-write the cache when the device goes from OFF->STANDBY, and
if it stays in standby and never went off, then we are still broken as
we switched to using the register cache only, but never turned on real
writes again.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] ASoC: tlv320aic31xx: Remove regulator notification handling
  2018-09-04 15:03       ` Andrew F. Davis
@ 2018-09-04 15:49         ` Mark Brown
  2018-09-04 15:55           ` Andrew F. Davis
  0 siblings, 1 reply; 7+ messages in thread
From: Mark Brown @ 2018-09-04 15:49 UTC (permalink / raw)
  To: Andrew F. Davis; +Cc: Liam Girdwood, alsa-devel, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 923 bytes --]

On Tue, Sep 04, 2018 at 10:03:40AM -0500, Andrew F. Davis wrote:
> On 09/04/2018 09:57 AM, Mark Brown wrote:

> > It's there to save us having to rewrite the register cache if we asked
> > for the device to be powered down but that didn't actually happen due to
> > other constraints, we know all the registers are still as we left them.

> I don't see that happening for any other user of this, we will still
> have to re-write the cache when the device goes from OFF->STANDBY, and

You will?  All the power_off() code seems to do is mark the regmap as
cache only and turn off the regulators.

> if it stays in standby and never went off, then we are still broken as
> we switched to using the register cache only, but never turned on real
> writes again.

regmap can remember which registers were written to while in cache only
mode and only sync the ones that are actually dirty, or you can
invalidate the entire cache.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] ASoC: tlv320aic31xx: Remove regulator notification handling
  2018-09-04 15:49         ` Mark Brown
@ 2018-09-04 15:55           ` Andrew F. Davis
  0 siblings, 0 replies; 7+ messages in thread
From: Andrew F. Davis @ 2018-09-04 15:55 UTC (permalink / raw)
  To: Mark Brown; +Cc: Liam Girdwood, alsa-devel, linux-kernel

On 09/04/2018 10:49 AM, Mark Brown wrote:
> On Tue, Sep 04, 2018 at 10:03:40AM -0500, Andrew F. Davis wrote:
>> On 09/04/2018 09:57 AM, Mark Brown wrote:
> 
>>> It's there to save us having to rewrite the register cache if we asked
>>> for the device to be powered down but that didn't actually happen due to
>>> other constraints, we know all the registers are still as we left them.
> 
>> I don't see that happening for any other user of this, we will still
>> have to re-write the cache when the device goes from OFF->STANDBY, and
> 
> You will?  All the power_off() code seems to do is mark the regmap as
> cache only and turn off the regulators.
> 

OFF->STANDBY will call power_on(). That is what is needed to start back
up after a regulator notification event.

>> if it stays in standby and never went off, then we are still broken as
>> we switched to using the register cache only, but never turned on real
>> writes again.
> 
> regmap can remember which registers were written to while in cache only
> mode and only sync the ones that are actually dirty, or you can
> invalidate the entire cache.
> 

If we never turn off cache only after a regulator notification then that
doesn't matter.

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2018-09-04 15:55 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-08-31 18:17 [PATCH] ASoC: tlv320aic31xx: Remove regulator notification handling Andrew F. Davis
2018-09-03 11:30 ` Mark Brown
2018-09-04 14:50   ` Andrew F. Davis
2018-09-04 14:57     ` Mark Brown
2018-09-04 15:03       ` Andrew F. Davis
2018-09-04 15:49         ` Mark Brown
2018-09-04 15:55           ` Andrew F. Davis

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).