Skip to contentSkip to conversation

ASoC: Forward calls to snd_soc_cache_sync() to regcache_sync()

PATCH Applied Lars-Peter Clausen 2 participants 3 messages Nov 8, 2014 – Nov 9, 2014

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/2 ASoC: Forward calls to snd_soc_cache_sync() to regcache_sync()

For convenience for drivers that do not want to keep their own pointer to regmap struct around forward calls to snd_soc_cache_sync() to regcache_sync() if the driver is using regmap. This is similar to what we do for snd_soc_read()/snd_soc_write().

This patch also fixes drivers which already have been converted to regmap, but still use snd_soc_cache_sync() for trying to the sync the cache.

---
Unfortunately there are a few drivers that have already been converted to regmap, but still use snd_soc_cache_sync(). snd_soc_cache_sync() currently is a noop for those drivers. Some of these conversions were done as early as 3.4 and while this patch applies cleanly to earlier kernel versions, due to the restructuring of the ASoC core it will only work on 3.16+. Hence no Fixes tag.

---
 sound/soc/soc-cache.c | 3 +++
 1 file changed, 3 insertions(+)
sound/soc/soc-cache.c +3 -0
index a9f82b5..6dab817 100644
@@ -187,6 +187,9 @@ int snd_soc_cache_sync(struct snd_soc_codec *codec)
 	const char *name = "flat";
 	int ret;
 
+	if (codec->component.regmap)
+		return regcache_sync(codec->component.regmap);
+
 	if (!codec->cache_sync)
 		return 0;
 
Signature · 1 line
1.8.0
#1 lore raw

PATCH 2/2 ASoC: Remove snd_soc_cache_sync() implementation

This function has no more non regmap user, which means we can remove the implementation of the function and associated functions and structure fields.

For convenience we keep a static inline version of the function that forwards calls to regcache_sync() unconditionally.

---
 include/sound/soc.h         |  19 ++++--
 include/trace/events/asoc.h |  25 --------
 sound/soc/soc-cache.c       | 152 --------------------------------------------
 sound/soc/soc-core.c        |   4 --
 4 files changed, 12 insertions(+), 188 deletions(-)
include/sound/soc.h +12 -7
index edbb07b..8a6215c 100644
@@ -412,13 +412,9 @@ int devm_snd_soc_register_component(struct device *dev,
 			 const struct snd_soc_component_driver *cmpnt_drv,
 			 struct snd_soc_dai_driver *dai_drv, int num_dai);
 void snd_soc_unregister_component(struct device *dev);
-int snd_soc_cache_sync(struct snd_soc_codec *codec);
 int snd_soc_cache_init(struct snd_soc_codec *codec);
 int snd_soc_cache_exit(struct snd_soc_codec *codec);
-int snd_soc_cache_write(struct snd_soc_codec *codec,
-			unsigned int reg, unsigned int value);
-int snd_soc_cache_read(struct snd_soc_codec *codec,
-		       unsigned int reg, unsigned int *value);
+
 int snd_soc_platform_read(struct snd_soc_platform *platform,
 					unsigned int reg);
 int snd_soc_platform_write(struct snd_soc_platform *platform,
@@ -788,13 +784,11 @@ struct snd_soc_codec {
 	unsigned int ac97_registered:1; /* Codec has been AC97 registered */
 	unsigned int ac97_created:1; /* Codec has been created by SoC */
 	unsigned int cache_init:1; /* codec cache has been initialized */
-	u32 cache_sync; /* Cache needs to be synced to hardware */
 
 	/* codec IO */
 	void *control_data; /* codec control (i2c/3wire) data */
 	hw_write_t hw_write;
 	void *reg_cache;
-	struct mutex cache_rw_mutex;
 
 	/* component */
 	struct snd_soc_component component;
@@ -1257,6 +1251,17 @@ unsigned int snd_soc_read(struct snd_soc_codec *codec, unsigned int reg);
 int snd_soc_write(struct snd_soc_codec *codec, unsigned int reg,
 	unsigned int val);
 
+/**
+ * snd_soc_cache_sync() - Sync the register cache with the hardware
+ * @codec: CODEC to sync
+ *
+ * Note: This function will call regcache_sync()
+ */
+static inline int snd_soc_cache_sync(struct snd_soc_codec *codec)
+{
+	return regcache_sync(codec->component.regmap);
+}
+
 /* component IO */
 int snd_soc_component_read(struct snd_soc_component *component,
 	unsigned int reg, unsigned int *val);
include/trace/events/asoc.h +0 -25
index b04ee7e..88cf39d 100644
@@ -288,31 +288,6 @@ TRACE_EVENT(snd_soc_jack_notify,
 	TP_printk("jack=%s %x", __get_str(name), (int)__entry->val)
 );
 
-TRACE_EVENT(snd_soc_cache_sync,
-
-	TP_PROTO(struct snd_soc_codec *codec, const char *type,
-		 const char *status),
-
-	TP_ARGS(codec, type, status),
-
-	TP_STRUCT__entry(
-		__string(	name,		codec->component.name)
-		__string(	status,		status		)
-		__string(	type,		type		)
-		__field(	int,		id		)
-	),
-
-	TP_fast_assign(
-		__assign_str(name, codec->component.name);
-		__assign_str(status, status);
-		__assign_str(type, type);
-		__entry->id = codec->component.id;
-	),
-
-	TP_printk("codec=%s.%d type=%s status=%s", __get_str(name),
-		  (int)__entry->id, __get_str(type), __get_str(status))
-);
-
 #endif /* _TRACE_ASOC_H */
 
 /* This part must be outside protection */
sound/soc/soc-cache.c +0 -152

167 lines not on this page · raw message

sound/soc/soc-core.c +0 -4
index 333f112..397d00a 100644
@@ -309,9 +309,6 @@ static void soc_init_codec_debugfs(struct snd_soc_component *component)
 {
 	struct snd_soc_codec *codec = snd_soc_component_to_codec(component);
 
-	debugfs_create_bool("cache_sync", 0444, codec->component.debugfs_root,
-			    &codec->cache_sync);
-
 	codec->debugfs_reg = debugfs_create_file("codec_reg", 0644,
 						 codec->component.debugfs_root,
 						 codec, &codec_reg_fops);
@@ -651,7 +648,6 @@ int snd_soc_suspend(struct device *dev)
 				if (codec->driver->suspend)
 					codec->driver->suspend(codec);
 				codec->suspended = 1;
-				codec->cache_sync = 1;
 				if (codec->component.regmap)
 					regcache_mark_dirty(codec->component.regmap);
 				/* deactivate pins to sleep state */
Signature · 1 line
1.8.0
maintainer Applied
#2 lore raw
In reply to Lars-Peter Clausen
Quoted 4 lines · Lars-Peter Clausen

For convenience for drivers that do not want to keep their own pointer to regmap struct around forward calls to snd_soc_cache_sync() to regcache_sync() if the driver is using regmap. This is similar to what we do for snd_soc_read()/snd_soc_write().

Applied both, thanks.