aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/sound/soc.h2
-rw-r--r--sound/soc/soc-core.c26
2 files changed, 25 insertions, 3 deletions
diff --git a/include/sound/soc.h b/include/sound/soc.h
index 1890d87c5204..2ce530efcf11 100644
--- a/include/sound/soc.h
+++ b/include/sound/soc.h
@@ -410,6 +410,8 @@ struct snd_soc_codec {
410 void *control_data; /* codec control (i2c/3wire) data */ 410 void *control_data; /* codec control (i2c/3wire) data */
411 unsigned int (*read)(struct snd_soc_codec *, unsigned int); 411 unsigned int (*read)(struct snd_soc_codec *, unsigned int);
412 int (*write)(struct snd_soc_codec *, unsigned int, unsigned int); 412 int (*write)(struct snd_soc_codec *, unsigned int, unsigned int);
413 int (*display_register)(struct snd_soc_codec *, char *,
414 size_t, unsigned int);
413 hw_write_t hw_write; 415 hw_write_t hw_write;
414 hw_read_t hw_read; 416 hw_read_t hw_read;
415 void *reg_cache; 417 void *reg_cache;
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index 83f1190293a8..5d3bf731a4b2 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -970,9 +970,29 @@ static ssize_t codec_reg_show(struct device *dev,
970 step = codec->reg_cache_step; 970 step = codec->reg_cache_step;
971 971
972 count += sprintf(buf, "%s registers\n", codec->name); 972 count += sprintf(buf, "%s registers\n", codec->name);
973 for (i = 0; i < codec->reg_cache_size; i += step) 973 for (i = 0; i < codec->reg_cache_size; i += step) {
974 count += sprintf(buf + count, "%2x: %4x\n", i, 974 count += sprintf(buf + count, "%2x: ", i);
975 codec->read(codec, i)); 975 if (count >= PAGE_SIZE - 1)
976 break;
977
978 if (codec->display_register)
979 count += codec->display_register(codec, buf + count,
980 PAGE_SIZE - count, i);
981 else
982 count += snprintf(buf + count, PAGE_SIZE - count,
983 "%4x", codec->read(codec, i));
984
985 if (count >= PAGE_SIZE - 1)
986 break;
987
988 count += snprintf(buf + count, PAGE_SIZE - count, "\n");
989 if (count >= PAGE_SIZE - 1)
990 break;
991 }
992
993 /* Truncate count; min() would cause a warning */
994 if (count >= PAGE_SIZE)
995 count = PAGE_SIZE - 1;
976 996
977 return count; 997 return count;
978} 998}