[PATCH -next] ASoC: rk817: Constify static struct snd_soc_dai_ops

Chris Morgan macromorgan at hotmail.com
Wed Jun 2 16:05:26 CEST 2021


On Wed, Jun 02, 2021 at 11:36:43AM +0000, Wei Yongjun wrote:
> The snd_soc_dai_ops structures is only stored in the ops field of a
> snd_soc_dai_driver structure, so make the snd_soc_dai_ops structure
> const to allow the compiler to put it in read-only memory.
> 
> Reported-by: Hulk Robot <hulkci at huawei.com>
> Signed-off-by: Wei Yongjun <weiyongjun1 at huawei.com>

Tested-by: Chris Morgan <macromorgan at hotmail.com>

Works for me when I apply it to my tree. Tested audio playback and
recording still work and no warnings are introduced.

> ---
>  sound/soc/codecs/rk817_codec.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/sound/soc/codecs/rk817_codec.c b/sound/soc/codecs/rk817_codec.c
> index 17e672b85ee5..9a896e4326c3 100644
> --- a/sound/soc/codecs/rk817_codec.c
> +++ b/sound/soc/codecs/rk817_codec.c
> @@ -382,7 +382,7 @@ static int rk817_digital_mute(struct snd_soc_dai *dai, int mute, int stream)
>  			SNDRV_PCM_FMTBIT_S24_LE |\
>  			SNDRV_PCM_FMTBIT_S32_LE)
>  
> -static struct snd_soc_dai_ops rk817_dai_ops = {
> +static const struct snd_soc_dai_ops rk817_dai_ops = {
>  	.hw_params	= rk817_hw_params,
>  	.set_fmt	= rk817_set_dai_fmt,
>  	.set_sysclk	= rk817_set_dai_sysclk,
> 


More information about the Alsa-devel mailing list