aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMark Brown <broonie@kernel.org>2014-11-19 05:48:20 -0500
committerMark Brown <broonie@kernel.org>2014-11-19 05:48:20 -0500
commite975cec295ea71d5ad01fd3b6195670d3e31885e (patch)
tree0b74ba93cecd9d577d6835e77ad7020f5b22db87
parentc534107fd229ca7d8ae707b3936365445de9ca89 (diff)
parent20feb881988cdf5f53304c355ae8ee3bf82e80ec (diff)
Merge branch 'topic/regmap' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound into asoc-ac97
-rw-r--r--include/sound/soc.h35
-rw-r--r--sound/soc/soc-core.c58
2 files changed, 82 insertions, 11 deletions
diff --git a/include/sound/soc.h b/include/sound/soc.h
index 9e513ae11749..80ca937a20da 100644
--- a/include/sound/soc.h
+++ b/include/sound/soc.h
@@ -1286,6 +1286,41 @@ void snd_soc_component_async_complete(struct snd_soc_component *component);
1286int snd_soc_component_test_bits(struct snd_soc_component *component, 1286int snd_soc_component_test_bits(struct snd_soc_component *component,
1287 unsigned int reg, unsigned int mask, unsigned int value); 1287 unsigned int reg, unsigned int mask, unsigned int value);
1288 1288
1289void snd_soc_component_init_regmap(struct snd_soc_component *component,
1290 struct regmap *regmap);
1291void snd_soc_component_exit_regmap(struct snd_soc_component *component);
1292
1293/**
1294 * snd_soc_codec_init_regmap() - Initialize regmap instance for the CODEC
1295 * @codec: The CODEC for which to initialize the regmap instance
1296 * @regmap: The regmap instance that should be used by the CODEC
1297 *
1298 * This function allows deferred assignment of the regmap instance that is
1299 * associated with the CODEC. Only use this if the regmap instance is not yet
1300 * ready when the CODEC is registered. The function must also be called before
1301 * the first IO attempt of the CODEC.
1302 */
1303static inline void snd_soc_codec_init_regmap(struct snd_soc_codec *codec,
1304 struct regmap *regmap)
1305{
1306 snd_soc_component_init_regmap(&codec->component, regmap);
1307}
1308
1309/**
1310 * snd_soc_codec_exit_regmap() - De-initialize regmap instance for the CODEC
1311 * @codec: The CODEC for which to de-initialize the regmap instance
1312 *
1313 * Calls regmap_exit() on the regmap instance associated to the CODEC and
1314 * removes the regmap instance from the CODEC.
1315 *
1316 * This function should only be used if snd_soc_codec_init_regmap() was used to
1317 * initialize the regmap instance.
1318 */
1319static inline void snd_soc_codec_exit_regmap(struct snd_soc_codec *codec)
1320{
1321 snd_soc_component_exit_regmap(&codec->component);
1322}
1323
1289/* device driver data */ 1324/* device driver data */
1290 1325
1291static inline void snd_soc_card_set_drvdata(struct snd_soc_card *card, 1326static 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 f5bebca84b71..db74c061f520 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -3652,22 +3652,58 @@ static int snd_soc_component_initialize(struct snd_soc_component *component,
3652 return 0; 3652 return 0;
3653} 3653}
3654 3654
3655static void snd_soc_component_init_regmap(struct snd_soc_component *component) 3655static void snd_soc_component_setup_regmap(struct snd_soc_component *component)
3656{ 3656{
3657 if (!component->regmap) 3657 int val_bytes = regmap_get_val_bytes(component->regmap);
3658 component->regmap = dev_get_regmap(component->dev, NULL); 3658
3659 if (component->regmap) { 3659 /* Errors are legitimate for non-integer byte multiples */
3660 int val_bytes = regmap_get_val_bytes(component->regmap); 3660 if (val_bytes > 0)
3661 /* Errors are legitimate for non-integer byte multiples */ 3661 component->val_bytes = val_bytes;
3662 if (val_bytes > 0) 3662}
3663 component->val_bytes = val_bytes; 3663
3664 } 3664/**
3665 * snd_soc_component_init_regmap() - Initialize regmap instance for the component
3666 * @component: The component for which to initialize the regmap instance
3667 * @regmap: The regmap instance that should be used by the component
3668 *
3669 * This function allows deferred assignment of the regmap instance that is
3670 * associated with the component. Only use this if the regmap instance is not
3671 * yet ready when the component is registered. The function must also be called
3672 * before the first IO attempt of the component.
3673 */
3674void snd_soc_component_init_regmap(struct snd_soc_component *component,
3675 struct regmap *regmap)
3676{
3677 component->regmap = regmap;
3678 snd_soc_component_setup_regmap(component);
3665} 3679}
3680EXPORT_SYMBOL_GPL(snd_soc_component_init_regmap);
3681
3682/**
3683 * snd_soc_component_exit_regmap() - De-initialize regmap instance for the component
3684 * @component: The component for which to de-initialize the regmap instance
3685 *
3686 * Calls regmap_exit() on the regmap instance associated to the component and
3687 * removes the regmap instance from the component.
3688 *
3689 * This function should only be used if snd_soc_component_init_regmap() was used
3690 * to initialize the regmap instance.
3691 */
3692void snd_soc_component_exit_regmap(struct snd_soc_component *component)
3693{
3694 regmap_exit(component->regmap);
3695 component->regmap = NULL;
3696}
3697EXPORT_SYMBOL_GPL(snd_soc_component_exit_regmap);
3666 3698
3667static void snd_soc_component_add_unlocked(struct snd_soc_component *component) 3699static void snd_soc_component_add_unlocked(struct snd_soc_component *component)
3668{ 3700{
3669 if (!component->write && !component->read) 3701 if (!component->write && !component->read) {
3670 snd_soc_component_init_regmap(component); 3702 if (!component->regmap)
3703 component->regmap = dev_get_regmap(component->dev, NULL);
3704 if (component->regmap)
3705 snd_soc_component_setup_regmap(component);
3706 }
3671 3707
3672 list_add(&component->list, &component_list); 3708 list_add(&component->list, &component_list);
3673} 3709}