Skip to contentSkip to conversation

To simplify the code for ASoC probe.

PATCH Applied Xiubo Li 3 participants 19 messages Feb 27, 2014 – Mar 1, 2014

Subsystems (3)
lore
Share & tools
lore

Xiubo Li

author
#0 lore raw

cover To simplify the code for ASoC probe.

Xiubo Li (3):
ASoC: io: Clean up snd_soc_codec_set_cache_io()
ASoC: core: Set the default I/O up try regmap.
ASoC: SGTL5000: Simplify ASoC probe code.

 sound/soc/codecs/sgtl5000.c | 8 --------
 sound/soc/soc-core.c        | 8 ++++----
 sound/soc/soc-io.c          | 5 -----
 3 files changed, 4 insertions(+), 17 deletions(-)
Signature · 1 line
1.8.4
author
#1 lore raw

PATCH 1/3 ASoC: io: Clean up snd_soc_codec_set_cache_io()

Now that all users have been converted to regmap and the config.reg_bits and config.val_bits can be setted by each user through regmap core API. So these two params are redundant here.

---
 sound/soc/soc-io.c | 5 -----
 1 file changed, 5 deletions(-)
sound/soc/soc-io.c +0 -5
index add99e2..18353f1 100644
@@ -88,16 +88,11 @@ int snd_soc_codec_set_cache_io(struct snd_soc_codec *codec,
 			       int addr_bits, int data_bits,
 			       enum snd_soc_control_type control)
 {
-	struct regmap_config config;
 	int ret;
 
-	memset(&config, 0, sizeof(config));
 	codec->write = hw_write;
 	codec->read = hw_read;
 
-	config.reg_bits = addr_bits;
-	config.val_bits = data_bits;
-
 	switch (control) {
 	case SND_SOC_REGMAP:
 		/* Device has made its own regmap arrangements */
Signature · 1 line
1.8.4
maintainer Applied
#2 lore raw

Re: [PATCH 1/3] ASoC: io: Clean up snd_soc_codec_set_cache_io()

Quoted 3 lines · Xiubo Li

Now that all users have been converted to regmap and the config.reg_bits and config.val_bits can be setted by each user through regmap core API. So these two params are redundant here.

Applied, thanks.

author
#3 lore raw

PATCH 2/3 ASoC: core: Set the default I/O up try regmap.

In reply to Xiubo Li

For most CODEC drivers which the REGMAP is used, the soc_probe_codec() will do the stuff work of snd_soc_codec_set_cache_io(), which the CODEC drivers' ASoC probe will do too, and almost at the same time.

This patch set the default I/O up try regmap, and then the CODEC drivers' stuff work of snd_soc_codec_set_cache_io() will be redundant, while if one CODEC driver needed to set it's own I/O, then it can rewrite the default ones. Then could we just discard the snd_soc_codec_set_cache_io() from the CODEC drivers' ASoC probe to simplify the code.

---
 sound/soc/soc-core.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
sound/soc/soc-core.c +4 -4
index e5a535b..c159a34 100644
@@ -1137,6 +1137,10 @@ static int soc_probe_codec(struct snd_soc_card *card,
 
 	codec->dapm.idle_bias_off = driver->idle_bias_off;
 
+	/* Set the default I/O up try regmap */
+	if (dev_get_regmap(codec->dev, NULL))
+		snd_soc_codec_set_cache_io(codec, 0, 0, SND_SOC_REGMAP);
+
 	if (driver->probe) {
 		ret = driver->probe(codec);
 		if (ret < 0) {
@@ -1150,10 +1154,6 @@ static int soc_probe_codec(struct snd_soc_card *card,
 			codec->name);
 	}
 
-	/* If the driver didn't set I/O up try regmap */
-	if (!codec->write && dev_get_regmap(codec->dev, NULL))
-		snd_soc_codec_set_cache_io(codec, 0, 0, SND_SOC_REGMAP);
-
 	if (driver->controls)
 		snd_soc_add_codec_controls(codec, driver->controls,
 				     driver->num_controls);
Signature · 1 line
1.8.4
maintainer
#4 lore raw

Re: [PATCH 2/3] ASoC: core: Set the default I/O up try regmap.

Quoted 3 lines · Xiubo Li

For most CODEC drivers which the REGMAP is used, the soc_probe_codec() will do the stuff work of snd_soc_codec_set_cache_io(), which the CODEC drivers' ASoC probe will do too, and almost at the same time.

Applied, thanks. I did a check of the drivers and it looks like they'll all be fine with this.

#5 lore raw

RE: [PATCH 2/3] ASoC: core: Set the default I/O up try regmap.

Quoted 10 lines

Subject: Re: [PATCH 2/3] ASoC: core: Set the default I/O up try regmap.

Quoted 3 lines · Xiubo Li

For most CODEC drivers which the REGMAP is used, the soc_probe_codec() will do the stuff work of snd_soc_codec_set_cache_io(), which the CODEC drivers' ASoC probe will do too, and almost at the same time.

Applied, thanks. I did a check of the drivers and it looks like they'll all be fine with this.

Yes.

I'll send another patches to applied to use this for another CODEC drivers. And there almost 80 files, Should I send them in one patch or split them into individual patch for each CODEC driver ?

Thanks,

--
Best Regards,
Xiubo

maintainer
#6 lore raw

Re: [PATCH 2/3] ASoC: core: Set the default I/O up try regmap.

Quoted 3 lines · On Fri, Feb 28, 2014 at 04:00:38AM +0000, [email protected] wrote:

I'll send another patches to applied to use this for another CODEC drivers. And there almost 80 files, Should I send them in one patch or split them into individual patch for each CODEC driver ?

I'd suggest doing one patch that covers the boring drivers where the first thing they do is call set_cache_io() but split out the others into one patch per driver since the need more examination.

#7 lore raw

RE: [PATCH 2/3] ASoC: core: Set the default I/O up try regmap.

Quoted 4 lines

Subject: Re: [PATCH 2/3] ASoC: core: Set the default I/O up try regmap.

On Fri, Feb 28, 2014 at 04:00:38AM +0000, [email protected] wrote:

Quoted 8 lines
Quoted 2 lines

I'll send another patches to applied to use this for another CODEC drivers. And there almost 80 files, Should I send them in one patch or split them

into

Quoted 1 line

individual patch for each CODEC driver ?

I'd suggest doing one patch that covers the boring drivers where the first thing they do is call set_cache_io() but split out the others into one patch per driver since the need more examination.

Got it.

Thanks,

--
Best Regards,
Xiubo

#8 lore raw

Re: [alsa-devel] [PATCH 2/3] ASoC: core: Set the default I/O up try regmap.

Quoted 6 lines · On 02/28/2014 06:56 AM, [email protected] wrote:
Quoted 6 lines

Subject: Re: [PATCH 2/3] ASoC: core: Set the default I/O up try regmap.

Quoted 2 lines · On Fri, Feb 28, 2014 at 04:00:38AM +0000, [email protected] wrote:

I'll send another patches to applied to use this for another CODEC drivers. And there almost 80 files, Should I send them in one patch or split them

Quoted 8 lines
Quoted 6 lines

into

Quoted 1 line

individual patch for each CODEC driver ?

I'd suggest doing one patch that covers the boring drivers where the first thing they do is call set_cache_io() but split out the others into one patch per driver since the need more examination.

Got it.

Btw. be careful, just removing the set_cache_io() call will not work for all drivers. There are some MFD child devices which use regmap from the parent device. So dev_get_regmap() will return NULL for those.

- Lars

#9 lore raw

RE: [alsa-devel] [PATCH 2/3] ASoC: core: Set the default I/O up try regmap.

Quoted 18 lines

Subject: Re: [alsa-devel] [PATCH 2/3] ASoC: core: Set the default I/O up try regmap.

Quoted 13 lines · On 02/28/2014 06:56 AM, [email protected] wrote:
Quoted 12 lines

Subject: Re: [PATCH 2/3] ASoC: core: Set the default I/O up try regmap.

Quoted 2 lines · On Fri, Feb 28, 2014 at 04:00:38AM +0000, [email protected] wrote:

I'll send another patches to applied to use this for another CODEC drivers. And there almost 80 files, Should I send them in one patch or split them

into

Quoted 1 line

individual patch for each CODEC driver ?

I'd suggest doing one patch that covers the boring drivers where the first thing they do is call set_cache_io() but split out the others into one patch per driver since the need more examination.

Quoted 6 lines
Quoted 1 line

Got it.

Btw. be careful, just removing the set_cache_io() call will not work for all drivers. There are some MFD child devices which use regmap from the parent device. So dev_get_regmap() will return NULL for those.

@Lars,

Do you mean the CODEC drivers like wm5110 and wm8997 ?

Thanks,

--
Best Regards,
Xiubo

#10 lore raw

Re: [alsa-devel] [PATCH 2/3] ASoC: core: Set the default I/O up try regmap.

Quoted 20 lines · On 02/28/2014 07:40 AM, [email protected] wrote:
Quoted 20 lines

Subject: Re: [alsa-devel] [PATCH 2/3] ASoC: core: Set the default I/O up try regmap.

Quoted 14 lines · On 02/28/2014 06:56 AM, [email protected] wrote:
Quoted 4 lines

Subject: Re: [PATCH 2/3] ASoC: core: Set the default I/O up try regmap.

On Fri, Feb 28, 2014 at 04:00:38AM +0000, [email protected] wrote:

Quoted 8 lines
Quoted 2 lines

I'll send another patches to applied to use this for another CODEC drivers. And there almost 80 files, Should I send them in one patch or split them

into

Quoted 1 line

individual patch for each CODEC driver ?

I'd suggest doing one patch that covers the boring drivers where the first thing they do is call set_cache_io() but split out the others into one patch per driver since the need more examination.

Got it.

Quoted 9 lines
Quoted 4 lines

Btw. be careful, just removing the set_cache_io() call will not work for all drivers. There are some MFD child devices which use regmap from the parent device. So dev_get_regmap() will return NULL for those.

@Lars,

Do you mean the CODEC drivers like wm5110 and wm8997 ?

Yes.

#11 lore raw

RE: [alsa-devel] [PATCH 2/3] ASoC: core: Set the default I/O up try regmap.

Quoted 22 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

Subject: Re: [PATCH 2/3] ASoC: core: Set the default I/O up try regmap.

Quoted 1 line · On Fri, Feb 28, 2014 at 04:00:38AM +0000, [email protected] wrote:

I'll send another patches to applied to use this for another CODEC

drivers.

Quoted 11 lines
Quoted 11 lines
Quoted 9 lines
Quoted 7 lines
Quoted 1 line

And there almost 80 files, Should I send them in one patch or split them

into

Quoted 1 line

individual patch for each CODEC driver ?

I'd suggest doing one patch that covers the boring drivers where the first thing they do is call set_cache_io() but split out the others into one patch per driver since the need more examination.

Got it.

Btw. be careful, just removing the set_cache_io() call will not work for

all

Quoted 4 lines
Quoted 3 lines

drivers. There are some MFD child devices which use regmap from the parent device. So dev_get_regmap() will return NULL for those.

Quoted 8 lines
Quoted 4 lines

@Lars,

Do you mean the CODEC drivers like wm5110 and wm8997 ?

Yes.

I only found these two CODEC drivers using MFD who would get its parent's regmap.

Has I missed some ?

Thanks,

Best Regards,
Xiubo

#12 lore raw

Re: [alsa-devel] [PATCH 2/3] ASoC: core: Set the default I/O up try regmap.

Quoted 28 lines · On 02/28/2014 08:08 AM, [email protected] wrote:
Quoted 28 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

Subject: Re: [PATCH 2/3] ASoC: core: Set the default I/O up try regmap.

Quoted 1 line · On Fri, Feb 28, 2014 at 04:00:38AM +0000, [email protected] wrote:

I'll send another patches to applied to use this for another CODEC

drivers.

Quoted 11 lines
Quoted 11 lines
Quoted 9 lines
Quoted 7 lines
Quoted 1 line

And there almost 80 files, Should I send them in one patch or split them

into

Quoted 1 line

individual patch for each CODEC driver ?

I'd suggest doing one patch that covers the boring drivers where the first thing they do is call set_cache_io() but split out the others into one patch per driver since the need more examination.

Got it.

Btw. be careful, just removing the set_cache_io() call will not work for

all

Quoted 8 lines
Quoted 3 lines

drivers. There are some MFD child devices which use regmap from the parent device. So dev_get_regmap() will return NULL for those.

@Lars,

Do you mean the CODEC drivers like wm5110 and wm8997 ?

Quoted 6 lines
Quoted 2 lines

Yes.

I only found these two CODEC drivers using MFD who would get its parent's regmap.

Has I missed some ?

A quick grep reveals:
mc13783.c: codec->control_data = dev_get_regmap(codec->dev->parent, NULL);
si476x.c: codec->control_data = dev_get_regmap(codec->dev->parent, NULL);
wm5102.c: codec->control_data = priv->core.arizona->regmap;
wm5110.c: codec->control_data = priv->core.arizona->regmap;
wm8997.c: codec->control_data = priv->core.arizona->regmap;

But there might be more.

#13 lore raw

RE: [alsa-devel] [PATCH 2/3] ASoC: core: Set the default I/O up try regmap.

Quoted 11 lines

A quick grep reveals:
mc13783.c: codec->control_data = dev_get_regmap(codec->dev->parent, NULL);
si476x.c: codec->control_data = dev_get_regmap(codec->dev->parent, NULL);
wm5102.c: codec->control_data = priv->core.arizona->regmap;
wm5110.c: codec->control_data = priv->core.arizona->regmap;
wm8997.c: codec->control_data = priv->core.arizona->regmap;

But there might be more.

Yes, I'll check it more carefully...

Thanks very much.

Best Regards,
Xiubo

#14 lore raw

RE: [alsa-devel] [PATCH 2/3] ASoC: core: Set the default I/O up try regmap.

In reply to Lars-Peter Clausen
Quoted 11 lines

A quick grep reveals:
mc13783.c: codec->control_data = dev_get_regmap(codec->dev->parent, NULL);
si476x.c: codec->control_data = dev_get_regmap(codec->dev->parent, NULL);
wm5102.c: codec->control_data = priv->core.arizona->regmap;
wm5110.c: codec->control_data = priv->core.arizona->regmap;
wm8997.c: codec->control_data = priv->core.arizona->regmap;

But there might be more.

I have found the following ones, who are using MFD & set_cache_io.

   1    143  sound/soc/codecs/cq93vc.c <<cq93vc_probe>>
             snd_soc_codec_set_cache_io(codec, 32, 32, SND_SOC_REGMAP);
   2    618  sound/soc/codecs/mc13783.c <<mc13783_probe>>
             ret = snd_soc_codec_set_cache_io(codec, 8, 24, SND_SOC_REGMAP);
   3   1765  sound/soc/codecs/wm5102.c <<wm5102_codec_probe>>
             ret = snd_soc_codec_set_cache_io(codec, 32, 16, SND_SOC_REGMAP);
   4   1593  sound/soc/codecs/wm5110.c <<wm5110_codec_probe>>
             ret = snd_soc_codec_set_cache_io(codec, 32, 16, SND_SOC_REGMAP);
   5   1510  sound/soc/codecs/wm8350.c <<wm8350_codec_probe>>
             snd_soc_codec_set_cache_io(codec, 8, 16, SND_SOC_REGMAP);
   6   1322  sound/soc/codecs/wm8400.c <<wm8400_codec_probe>>
             snd_soc_codec_set_cache_io(codec, 8, 16, SND_SOC_REGMAP);
   7   4004  sound/soc/codecs/wm8994.c <<wm8994_codec_probe>>
             snd_soc_codec_set_cache_io(codec, 16, 16, SND_SOC_REGMAP);
   8   1058  sound/soc/codecs/wm8997.c <<wm8997_codec_probe>>
             ret = snd_soc_codec_set_cache_io(codec, 32, 16, SND_SOC_REGMAP);

Thanks,

--
Best regards,
Xiubo

#15 lore raw

Re: [alsa-devel] [PATCH 2/3] ASoC: core: Set the default I/O up try regmap.

Quoted 14 lines · On 02/28/2014 08:50 AM, [email protected] wrote:
Quoted 11 lines

A quick grep reveals:
mc13783.c: codec->control_data = dev_get_regmap(codec->dev->parent, NULL);
si476x.c: codec->control_data = dev_get_regmap(codec->dev->parent, NULL);
wm5102.c: codec->control_data = priv->core.arizona->regmap;
wm5110.c: codec->control_data = priv->core.arizona->regmap;
wm8997.c: codec->control_data = priv->core.arizona->regmap;

But there might be more.

I have found the following ones, who are using MFD & set_cache_io.

Quoted 16 lines
    1    143  sound/soc/codecs/cq93vc.c <<cq93vc_probe>>
              snd_soc_codec_set_cache_io(codec, 32, 32, SND_SOC_REGMAP);
    2    618  sound/soc/codecs/mc13783.c <<mc13783_probe>>
              ret = snd_soc_codec_set_cache_io(codec, 8, 24, SND_SOC_REGMAP);
    3   1765  sound/soc/codecs/wm5102.c <<wm5102_codec_probe>>
              ret = snd_soc_codec_set_cache_io(codec, 32, 16, SND_SOC_REGMAP);
    4   1593  sound/soc/codecs/wm5110.c <<wm5110_codec_probe>>
              ret = snd_soc_codec_set_cache_io(codec, 32, 16, SND_SOC_REGMAP);
    5   1510  sound/soc/codecs/wm8350.c <<wm8350_codec_probe>>
              snd_soc_codec_set_cache_io(codec, 8, 16, SND_SOC_REGMAP);
    6   1322  sound/soc/codecs/wm8400.c <<wm8400_codec_probe>>
              snd_soc_codec_set_cache_io(codec, 8, 16, SND_SOC_REGMAP);
    7   4004  sound/soc/codecs/wm8994.c <<wm8994_codec_probe>>
              snd_soc_codec_set_cache_io(codec, 16, 16, SND_SOC_REGMAP);
    8   1058  sound/soc/codecs/wm8997.c <<wm8997_codec_probe>>
              ret = snd_soc_codec_set_cache_io(codec, 32, 16, SND_SOC_REGMAP);

Yes, I think that's almost all of them. si476x is missing, but I think that one is currently broken, as it doesn't call snd_soc_codec_set_cache_io() at all.

As to how to handle those, I think there was a plan to add the possibility to assign a regmap to a device, so that dev_get_regmap() returns the regmap struct that should be used, even though the device itself did not allocate the regmap. But I can't find the details. Mark may know more about this.

- Lars

maintainer
#16 lore raw

Re: [alsa-devel] [PATCH 2/3] ASoC: core: Set the default I/O up try regmap.

Quoted 3 lines · Lars-Peter Clausen

Yes, I think that's almost all of them. si476x is missing, but I think that one is currently broken, as it doesn't call snd_soc_codec_set_cache_io() at all.

Probably, yeah - there were other problems with that driver that make me question if it ever worked properly IIRC. There is a default call to set cache I/O already but it relies on dev_get_regmap().

Quoted 5 lines

As to how to handle those, I think there was a plan to add the possibility to assign a regmap to a device, so that dev_get_regmap() returns the regmap struct that should be used, even though the device itself did not allocate the regmap. But I can't find the details. Mark may know more about this.

That's not for this and is likely to create confusion - that's for handling early init with syscon type devices, allowing the regmap to be created with no device and then have the device attached later. I'd need to look through and see what happens if two devices share a regmap, perhaps it'd actually be OK, but we can always just allow the regmap to be overridden at the ASoC level.

author
#17 lore raw

PATCH 3/3 ASoC: SGTL5000: Simplify ASoC probe code.

In reply to Xiubo Li
---
 sound/soc/codecs/sgtl5000.c | 8 --------
 1 file changed, 8 deletions(-)
sound/soc/codecs/sgtl5000.c +0 -8
index ab4754a..d3ed1be 100644
@@ -1352,14 +1352,6 @@ static int sgtl5000_probe(struct snd_soc_codec *codec)
 	int ret;
 	struct sgtl5000_priv *sgtl5000 = snd_soc_codec_get_drvdata(codec);
 
-	/* setup i2c data ops */
-	codec->control_data = sgtl5000->regmap;
-	ret = snd_soc_codec_set_cache_io(codec, 16, 16, SND_SOC_REGMAP);
-	if (ret < 0) {
-		dev_err(codec->dev, "Failed to set cache I/O: %d\n", ret);
-		return ret;
-	}
-
 	ret = sgtl5000_enable_regulators(codec);
 	if (ret)
 		return ret;
Signature · 1 line
1.8.4