diff options
author | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2008-07-29 06:42:25 -0400 |
---|---|---|
committer | Jaroslav Kysela <perex@perex.cz> | 2008-07-29 15:32:15 -0400 |
commit | 58cd33c0f375578cfda25a52ed280caa888b6254 (patch) | |
tree | c670df251546d8affa258e0720d94d0a6aabcd4f /sound/soc/soc-core.c | |
parent | 8a33de9e51673dbdadb552d888a4544aefe0c31d (diff) |
ALSA: ASoC: Allow codecs to override register display
Some codecs have unusual features in their register maps such as very
large registers representing arrays of coefficients. Support these
codecs in the register cache sysfs file by allowing them to provide a
function register_display() overriding the default output for register
contents.
Also ensure that we don't overflow PAGE_SIZE while writing out the
register dump.
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
Diffstat (limited to 'sound/soc/soc-core.c')
-rw-r--r-- | sound/soc/soc-core.c | 26 |
1 files changed, 23 insertions, 3 deletions
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 | } |