alsa-devel.alsa-project.org archive mirror
 help / color / mirror / Atom feed
From: Lars-Peter Clausen <lars@metafoo.de>
To: Mark Brown <broonie@kernel.org>, Liam Girdwood <lgirdwood@gmail.com>
Cc: alsa-devel@alsa-project.org, Lars-Peter Clausen <lars@metafoo.de>
Subject: [PATCH 11/13] ASoC: Automatically initialize regmap for all components
Date: Tue, 19 Aug 2014 15:51:28 +0200	[thread overview]
Message-ID: <1408456290-13945-12-git-send-email-lars@metafoo.de> (raw)
In-Reply-To: <1408456290-13945-1-git-send-email-lars@metafoo.de>

So far regmap is only automatically initialized for CODECs. Now that we have the
infrastructure in place to let components have DAPM widgets and controls that
want to use the generic regmap based IO also make sure to automatically
initialize regmap for all components.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
---
 include/sound/soc.h  |  3 ---
 sound/soc/soc-core.c | 35 +++++++++++++++++------------------
 sound/soc/soc-io.c   | 28 ----------------------------
 3 files changed, 17 insertions(+), 49 deletions(-)

diff --git a/include/sound/soc.h b/include/sound/soc.h
index f8abe22..d4ba8048 100644
--- a/include/sound/soc.h
+++ b/include/sound/soc.h
@@ -1289,9 +1289,6 @@ void snd_soc_component_async_complete(struct snd_soc_component *component);
 int snd_soc_component_test_bits(struct snd_soc_component *component,
 	unsigned int reg, unsigned int mask, unsigned int value);
 
-int snd_soc_component_init_io(struct snd_soc_component *component,
-	struct regmap *regmap);
-
 /* device driver data */
 
 static inline void snd_soc_card_set_drvdata(struct snd_soc_card *card,
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index 9d05a28..5c78098 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -4032,8 +4032,23 @@ static int snd_soc_component_initialize(struct snd_soc_component *component,
 	return 0;
 }
 
+static void snd_soc_component_init_regmap(struct snd_soc_component *component)
+{
+	if (!component->regmap)
+		component->regmap = dev_get_regmap(component->dev, NULL);
+	if (component->regmap) {
+		int val_bytes = regmap_get_val_bytes(component->regmap);
+		/* Errors are legitimate for non-integer byte multiples */
+		if (val_bytes > 0)
+			component->val_bytes = val_bytes;
+	}
+}
+
 static void snd_soc_component_add_unlocked(struct snd_soc_component *component)
 {
+	if (!component->write && !component->read)
+		snd_soc_component_init_regmap(component);
+
 	list_add(&component->list, &component_list);
 }
 
@@ -4371,7 +4386,6 @@ int snd_soc_register_codec(struct device *dev,
 {
 	struct snd_soc_codec *codec;
 	struct snd_soc_dai *dai;
-	struct regmap *regmap;
 	int ret, i;
 
 	dev_dbg(dev, "codec register %s\n", dev_name(dev));
@@ -4425,23 +4439,8 @@ int snd_soc_register_codec(struct device *dev,
 	codec->component.debugfs_prefix = "codec";
 #endif
 
-	if (!codec->component.write) {
-		if (codec_drv->get_regmap)
-			regmap = codec_drv->get_regmap(dev);
-		else
-			regmap = dev_get_regmap(dev, NULL);
-
-		if (regmap) {
-			ret = snd_soc_component_init_io(&codec->component,
-				regmap);
-			if (ret) {
-				dev_err(codec->dev,
-						"Failed to set cache I/O:%d\n",
-						ret);
-				goto err_cleanup;
-			}
-		}
-	}
+	if (codec_drv->get_regmap)
+		codec->component.regmap = codec_drv->get_regmap(dev);
 
 	for (i = 0; i < num_dai; i++) {
 		fixup_codec_formats(&dai_drv[i].playback);
diff --git a/sound/soc/soc-io.c b/sound/soc/soc-io.c
index 7767fbd..9b39390 100644
--- a/sound/soc/soc-io.c
+++ b/sound/soc/soc-io.c
@@ -271,31 +271,3 @@ int snd_soc_platform_write(struct snd_soc_platform *platform,
 	return snd_soc_component_write(&platform->component, reg, val);
 }
 EXPORT_SYMBOL_GPL(snd_soc_platform_write);
-
-/**
- * snd_soc_component_init_io() - Initialize regmap IO
- *
- * @component: component to initialize
- * @regmap: regmap instance to use for IO operations
- *
- * Return: 0 on success, a negative error code otherwise
- */
-int snd_soc_component_init_io(struct snd_soc_component *component,
-	struct regmap *regmap)
-{
-	int ret;
-
-	if (!regmap)
-		return -EINVAL;
-
-	ret = regmap_get_val_bytes(regmap);
-	/* Errors are legitimate for non-integer byte
-	 * multiples */
-	if (ret > 0)
-		component->val_bytes = ret;
-
-	component->regmap = regmap;
-
-	return 0;
-}
-EXPORT_SYMBOL_GPL(snd_soc_component_init_io);
-- 
1.8.0

  parent reply	other threads:[~2014-08-19 13:51 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-19 13:51 [PATCH 00/13] ASoC: Componentization: Unified probe/remove path Lars-Peter Clausen
2014-08-19 13:51 ` [PATCH 01/13] ASoC: Move debugfs registration to the component level Lars-Peter Clausen
2014-08-19 13:51 ` [PATCH 02/13] ASoC: Consolidate platform and CODEC probe/remove Lars-Peter Clausen
2014-08-19 13:51 ` [PATCH 03/13] ASoC: Make rtd->codec optional Lars-Peter Clausen
2014-08-19 13:51 ` [PATCH 04/13] ASoC: Add component level probe/remove support Lars-Peter Clausen
2014-08-19 13:51 ` [PATCH 05/13] ASoC: Move AUX dev support to the component level Lars-Peter Clausen
2014-08-19 13:51 ` [PATCH 06/13] ASoC: Pass component instead of DAPM context to AUX dev init callback Lars-Peter Clausen
2014-08-19 13:51 ` [PATCH 07/13] ASoC: Move component->probed check into soc_{remove, probe}_component() Lars-Peter Clausen
2014-08-19 13:51 ` [PATCH 08/13] ASoC: Cleanup DAI module reference counting Lars-Peter Clausen
2014-08-19 13:51 ` [PATCH 09/13] ASoC: Consolidate CPU and CODEC DAI removal Lars-Peter Clausen
2014-08-19 13:51 ` [PATCH 10/13] ASoC: Consolidate CPU and CODEC DAI lookup Lars-Peter Clausen
2014-08-19 13:51 ` Lars-Peter Clausen [this message]
2014-08-19 13:51 ` [PATCH 12/13] ASoC: Remove support for legacy snd_soc_platform IO Lars-Peter Clausen
2014-08-19 13:51 ` [PATCH 13/13] ASoC: Replace list_empty(&card->codec_dev_list) with !card->instantiated Lars-Peter Clausen
2014-08-19 16:01 ` [PATCH 00/13] ASoC: Componentization: Unified probe/remove path Mark Brown

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1408456290-13945-12-git-send-email-lars@metafoo.de \
    --to=lars@metafoo.de \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    --cc=lgirdwood@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).