From: Takashi Iwai Date: Sun, 5 Jan 2020 14:47:20 +0000 (+0100) Subject: ALSA: pcm: More constifications X-Git-Tag: v5.15~4528^2~107 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d03af9b8ea7e8655869834f2eed1f1d583cc5672;p=platform%2Fkernel%2Flinux-starfive.git ALSA: pcm: More constifications Apply const prefix to more possible places: the string tables for PCM format and co, the table for the PCM type helpers, etc. Just for minor optimization and no functional changes. Link: https://lore.kernel.org/r/20200105144823.29547-6-tiwai@suse.de Signed-off-by: Takashi Iwai --- diff --git a/sound/core/pcm.c b/sound/core/pcm.c index a0f704b..a141a30 100644 --- a/sound/core/pcm.c +++ b/sound/core/pcm.c @@ -163,7 +163,7 @@ static int snd_pcm_control_ioctl(struct snd_card *card, #define FORMAT(v) [SNDRV_PCM_FORMAT_##v] = #v -static char *snd_pcm_format_names[] = { +static const char * const snd_pcm_format_names[] = { FORMAT(S8), FORMAT(U8), FORMAT(S16_LE), @@ -237,12 +237,12 @@ EXPORT_SYMBOL_GPL(snd_pcm_format_name); #define START(v) [SNDRV_PCM_START_##v] = #v #define SUBFORMAT(v) [SNDRV_PCM_SUBFORMAT_##v] = #v -static char *snd_pcm_stream_names[] = { +static const char * const snd_pcm_stream_names[] = { STREAM(PLAYBACK), STREAM(CAPTURE), }; -static char *snd_pcm_state_names[] = { +static const char * const snd_pcm_state_names[] = { STATE(OPEN), STATE(SETUP), STATE(PREPARED), @@ -253,7 +253,7 @@ static char *snd_pcm_state_names[] = { STATE(SUSPENDED), }; -static char *snd_pcm_access_names[] = { +static const char * const snd_pcm_access_names[] = { ACCESS(MMAP_INTERLEAVED), ACCESS(MMAP_NONINTERLEAVED), ACCESS(MMAP_COMPLEX), @@ -261,11 +261,11 @@ static char *snd_pcm_access_names[] = { ACCESS(RW_NONINTERLEAVED), }; -static char *snd_pcm_subformat_names[] = { +static const char * const snd_pcm_subformat_names[] = { SUBFORMAT(STD), }; -static char *snd_pcm_tstamp_mode_names[] = { +static const char * const snd_pcm_tstamp_mode_names[] = { TSTAMP(NONE), TSTAMP(ENABLE), }; diff --git a/sound/core/pcm_lib.c b/sound/core/pcm_lib.c index 18f498a..872a852 100644 --- a/sound/core/pcm_lib.c +++ b/sound/core/pcm_lib.c @@ -1452,7 +1452,7 @@ EXPORT_SYMBOL(snd_pcm_hw_constraint_step); static int snd_pcm_hw_rule_pow2(struct snd_pcm_hw_params *params, struct snd_pcm_hw_rule *rule) { - static unsigned int pow2_sizes[] = { + static const unsigned int pow2_sizes[] = { 1<<0, 1<<1, 1<<2, 1<<3, 1<<4, 1<<5, 1<<6, 1<<7, 1<<8, 1<<9, 1<<10, 1<<11, 1<<12, 1<<13, 1<<14, 1<<15, 1<<16, 1<<17, 1<<18, 1<<19, 1<<20, 1<<21, 1<<22, 1<<23, diff --git a/sound/core/pcm_misc.c b/sound/core/pcm_misc.c index c4eb561..a6a5415 100644 --- a/sound/core/pcm_misc.c +++ b/sound/core/pcm_misc.c @@ -42,7 +42,7 @@ struct pcm_format_data { /* we do lots of calculations on snd_pcm_format_t; shut up sparse */ #define INT __force int -static struct pcm_format_data pcm_formats[(INT)SNDRV_PCM_FORMAT_LAST+1] = { +static const struct pcm_format_data pcm_formats[(INT)SNDRV_PCM_FORMAT_LAST+1] = { [SNDRV_PCM_FORMAT_S8] = { .width = 8, .phys = 8, .le = -1, .signd = 1, .silence = {}, @@ -415,7 +415,8 @@ EXPORT_SYMBOL(snd_pcm_format_silence_64); int snd_pcm_format_set_silence(snd_pcm_format_t format, void *data, unsigned int samples) { int width; - unsigned char *dst, *pat; + unsigned char *dst; + const unsigned char *pat; if ((INT)format < 0 || (INT)format > (INT)SNDRV_PCM_FORMAT_LAST) return -EINVAL;