Skip to content

Commit e6c2e7e

Browse files
larsclausentiwai
authored andcommitted
ALSA: Constify the snd_pcm_substream struct ops field
The ops field of the snd_pcm_substream struct is never modified inside the ALSA core. Making it const allows drivers to declare their snd_pcm_ops struct as const. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Takashi Iwai <tiwai@suse.de>
1 parent 3cf9814 commit e6c2e7e

2 files changed

Lines changed: 5 additions & 3 deletions

File tree

‎include/sound/pcm.h‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,7 @@ struct snd_pcm_substream {
384384
unsigned int dma_buf_id;
385385
size_t dma_max;
386386
/* -- hardware operations -- */
387-
struct snd_pcm_ops *ops;
387+
const struct snd_pcm_ops *ops;
388388
/* -- runtime information -- */
389389
struct snd_pcm_runtime *runtime;
390390
/* -- timer section -- */
@@ -871,7 +871,8 @@ const unsigned char *snd_pcm_format_silence_64(snd_pcm_format_t format);
871871
int snd_pcm_format_set_silence(snd_pcm_format_t format, void *buf, unsigned int frames);
872872
snd_pcm_format_t snd_pcm_build_linear_format(int width, int unsigned, int big_endian);
873873

874-
void snd_pcm_set_ops(struct snd_pcm * pcm, int direction, struct snd_pcm_ops *ops);
874+
void snd_pcm_set_ops(struct snd_pcm * pcm, int direction,
875+
const struct snd_pcm_ops *ops);
875876
void snd_pcm_set_sync(struct snd_pcm_substream *substream);
876877
int snd_pcm_lib_interleave_len(struct snd_pcm_substream *substream);
877878
int snd_pcm_lib_ioctl(struct snd_pcm_substream *substream,

‎sound/core/pcm_lib.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -568,7 +568,8 @@ int snd_pcm_update_hw_ptr(struct snd_pcm_substream *substream)
568568
*
569569
* Sets the given PCM operators to the pcm instance.
570570
*/
571-
void snd_pcm_set_ops(struct snd_pcm *pcm, int direction, struct snd_pcm_ops *ops)
571+
void snd_pcm_set_ops(struct snd_pcm *pcm, int direction,
572+
const struct snd_pcm_ops *ops)
572573
{
573574
struct snd_pcm_str *stream = &pcm->streams[direction];
574575
struct snd_pcm_substream *substream;

0 commit comments

Comments
 (0)