Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Mark Brown <broonie@kernel.org>

authored by

Lars-Peter Clausen and committed by
Mark Brown
427d204c 6cc79294

+12 -188
+12 -7
include/sound/soc.h
··· 409 409 const struct snd_soc_component_driver *cmpnt_drv, 410 410 struct snd_soc_dai_driver *dai_drv, int num_dai); 411 411 void snd_soc_unregister_component(struct device *dev); 412 - int snd_soc_cache_sync(struct snd_soc_codec *codec); 413 412 int snd_soc_cache_init(struct snd_soc_codec *codec); 414 413 int snd_soc_cache_exit(struct snd_soc_codec *codec); 415 - int snd_soc_cache_write(struct snd_soc_codec *codec, 416 - unsigned int reg, unsigned int value); 417 - int snd_soc_cache_read(struct snd_soc_codec *codec, 418 - unsigned int reg, unsigned int *value); 414 + 419 415 int snd_soc_platform_read(struct snd_soc_platform *platform, 420 416 unsigned int reg); 421 417 int snd_soc_platform_write(struct snd_soc_platform *platform, ··· 787 791 unsigned int ac97_registered:1; /* Codec has been AC97 registered */ 788 792 unsigned int ac97_created:1; /* Codec has been created by SoC */ 789 793 unsigned int cache_init:1; /* codec cache has been initialized */ 790 - u32 cache_sync; /* Cache needs to be synced to hardware */ 791 794 792 795 /* codec IO */ 793 796 void *control_data; /* codec control (i2c/3wire) data */ 794 797 hw_write_t hw_write; 795 798 void *reg_cache; 796 - struct mutex cache_rw_mutex; 797 799 798 800 /* component */ 799 801 struct snd_soc_component component; ··· 1257 1263 unsigned int snd_soc_read(struct snd_soc_codec *codec, unsigned int reg); 1258 1264 int snd_soc_write(struct snd_soc_codec *codec, unsigned int reg, 1259 1265 unsigned int val); 1266 + 1267 + /** 1268 + * snd_soc_cache_sync() - Sync the register cache with the hardware 1269 + * @codec: CODEC to sync 1270 + * 1271 + * Note: This function will call regcache_sync() 1272 + */ 1273 + static inline int snd_soc_cache_sync(struct snd_soc_codec *codec) 1274 + { 1275 + return regcache_sync(codec->component.regmap); 1276 + } 1260 1277 1261 1278 /* component IO */ 1262 1279 int snd_soc_component_read(struct snd_soc_component *component,
-25
include/trace/events/asoc.h
··· 288 288 TP_printk("jack=%s %x", __get_str(name), (int)__entry->val) 289 289 ); 290 290 291 - TRACE_EVENT(snd_soc_cache_sync, 292 - 293 - TP_PROTO(struct snd_soc_codec *codec, const char *type, 294 - const char *status), 295 - 296 - TP_ARGS(codec, type, status), 297 - 298 - TP_STRUCT__entry( 299 - __string( name, codec->component.name) 300 - __string( status, status ) 301 - __string( type, type ) 302 - __field( int, id ) 303 - ), 304 - 305 - TP_fast_assign( 306 - __assign_str(name, codec->component.name); 307 - __assign_str(status, status); 308 - __assign_str(type, type); 309 - __entry->id = codec->component.id; 310 - ), 311 - 312 - TP_printk("codec=%s.%d type=%s status=%s", __get_str(name), 313 - (int)__entry->id, __get_str(type), __get_str(status)) 314 - ); 315 - 316 291 #endif /* _TRACE_ASOC_H */ 317 292 318 293 /* This part must be outside protection */
-152
sound/soc/soc-cache.c
··· 15 15 #include <linux/export.h> 16 16 #include <linux/slab.h> 17 17 18 - #include <trace/events/asoc.h> 19 - 20 - static bool snd_soc_set_cache_val(void *base, unsigned int idx, 21 - unsigned int val, unsigned int word_size) 22 - { 23 - switch (word_size) { 24 - case 1: { 25 - u8 *cache = base; 26 - if (cache[idx] == val) 27 - return true; 28 - cache[idx] = val; 29 - break; 30 - } 31 - case 2: { 32 - u16 *cache = base; 33 - if (cache[idx] == val) 34 - return true; 35 - cache[idx] = val; 36 - break; 37 - } 38 - default: 39 - WARN(1, "Invalid word_size %d\n", word_size); 40 - break; 41 - } 42 - return false; 43 - } 44 - 45 - static unsigned int snd_soc_get_cache_val(const void *base, unsigned int idx, 46 - unsigned int word_size) 47 - { 48 - if (!base) 49 - return -1; 50 - 51 - switch (word_size) { 52 - case 1: { 53 - const u8 *cache = base; 54 - return cache[idx]; 55 - } 56 - case 2: { 57 - const u16 *cache = base; 58 - return cache[idx]; 59 - } 60 - default: 61 - WARN(1, "Invalid word_size %d\n", word_size); 62 - break; 63 - } 64 - /* unreachable */ 65 - return -1; 66 - } 67 - 68 18 int snd_soc_cache_init(struct snd_soc_codec *codec) 69 19 { 70 20 const struct snd_soc_codec_driver *codec_drv = codec->driver; ··· 24 74 25 75 if (!reg_size) 26 76 return 0; 27 - 28 - mutex_init(&codec->cache_rw_mutex); 29 77 30 78 dev_dbg(codec->dev, "ASoC: Initializing cache for %s codec\n", 31 79 codec->component.name); ··· 51 103 codec->reg_cache = NULL; 52 104 return 0; 53 105 } 54 - 55 - /** 56 - * snd_soc_cache_read: Fetch the value of a given register from the cache. 57 - * 58 - * @codec: CODEC to configure. 59 - * @reg: The register index. 60 - * @value: The value to be returned. 61 - */ 62 - int snd_soc_cache_read(struct snd_soc_codec *codec, 63 - unsigned int reg, unsigned int *value) 64 - { 65 - if (!value) 66 - return -EINVAL; 67 - 68 - mutex_lock(&codec->cache_rw_mutex); 69 - if (!ZERO_OR_NULL_PTR(codec->reg_cache)) 70 - *value = snd_soc_get_cache_val(codec->reg_cache, reg, 71 - codec->driver->reg_word_size); 72 - mutex_unlock(&codec->cache_rw_mutex); 73 - 74 - return 0; 75 - } 76 - EXPORT_SYMBOL_GPL(snd_soc_cache_read); 77 - 78 - /** 79 - * snd_soc_cache_write: Set the value of a given register in the cache. 80 - * 81 - * @codec: CODEC to configure. 82 - * @reg: The register index. 83 - * @value: The new register value. 84 - */ 85 - int snd_soc_cache_write(struct snd_soc_codec *codec, 86 - unsigned int reg, unsigned int value) 87 - { 88 - mutex_lock(&codec->cache_rw_mutex); 89 - if (!ZERO_OR_NULL_PTR(codec->reg_cache)) 90 - snd_soc_set_cache_val(codec->reg_cache, reg, value, 91 - codec->driver->reg_word_size); 92 - mutex_unlock(&codec->cache_rw_mutex); 93 - 94 - return 0; 95 - } 96 - EXPORT_SYMBOL_GPL(snd_soc_cache_write); 97 - 98 - static int snd_soc_flat_cache_sync(struct snd_soc_codec *codec) 99 - { 100 - int i; 101 - int ret; 102 - const struct snd_soc_codec_driver *codec_drv; 103 - unsigned int val; 104 - 105 - codec_drv = codec->driver; 106 - for (i = 0; i < codec_drv->reg_cache_size; ++i) { 107 - ret = snd_soc_cache_read(codec, i, &val); 108 - if (ret) 109 - return ret; 110 - if (codec_drv->reg_cache_default) 111 - if (snd_soc_get_cache_val(codec_drv->reg_cache_default, 112 - i, codec_drv->reg_word_size) == val) 113 - continue; 114 - 115 - ret = snd_soc_write(codec, i, val); 116 - if (ret) 117 - return ret; 118 - dev_dbg(codec->dev, "ASoC: Synced register %#x, value = %#x\n", 119 - i, val); 120 - } 121 - return 0; 122 - } 123 - 124 - /** 125 - * snd_soc_cache_sync: Sync the register cache with the hardware. 126 - * 127 - * @codec: CODEC to configure. 128 - * 129 - * Any registers that should not be synced should be marked as 130 - * volatile. In general drivers can choose not to use the provided 131 - * syncing functionality if they so require. 132 - */ 133 - int snd_soc_cache_sync(struct snd_soc_codec *codec) 134 - { 135 - const char *name = "flat"; 136 - int ret; 137 - 138 - if (codec->component.regmap) 139 - return regcache_sync(codec->component.regmap); 140 - 141 - if (!codec->cache_sync) 142 - return 0; 143 - 144 - dev_dbg(codec->dev, "ASoC: Syncing cache for %s codec\n", 145 - codec->component.name); 146 - trace_snd_soc_cache_sync(codec, name, "start"); 147 - ret = snd_soc_flat_cache_sync(codec); 148 - if (!ret) 149 - codec->cache_sync = 0; 150 - trace_snd_soc_cache_sync(codec, name, "end"); 151 - return ret; 152 - } 153 - EXPORT_SYMBOL_GPL(snd_soc_cache_sync);
-4
sound/soc/soc-core.c
··· 309 309 { 310 310 struct snd_soc_codec *codec = snd_soc_component_to_codec(component); 311 311 312 - debugfs_create_bool("cache_sync", 0444, codec->component.debugfs_root, 313 - &codec->cache_sync); 314 - 315 312 codec->debugfs_reg = debugfs_create_file("codec_reg", 0644, 316 313 codec->component.debugfs_root, 317 314 codec, &codec_reg_fops); ··· 653 656 if (codec->driver->suspend) 654 657 codec->driver->suspend(codec); 655 658 codec->suspended = 1; 656 - codec->cache_sync = 1; 657 659 if (codec->component.regmap) 658 660 regcache_mark_dirty(codec->component.regmap); 659 661 /* deactivate pins to sleep state */