Skip to content

Commit fc033cb

Browse files
committed
ALSA: pcm: Allow NULL ioctl ops
Currently PCM ioctl ops is a mandatory field but almost all drivers simply pass snd_pcm_lib_ioctl. For simplicity, allow to set NULL in the field and call snd_pcm_lib_ioctl() as default. Link: https://lore.kernel.org/r/20191117085308.23915-4-tiwai@suse.de Signed-off-by: Takashi Iwai <tiwai@suse.de>
1 parent 72b4bcb commit fc033cb

1 file changed

Lines changed: 15 additions & 4 deletions

File tree

‎sound/core/pcm_native.c‎

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,16 @@ void snd_pcm_stream_unlock_irqrestore(struct snd_pcm_substream *substream,
178178
}
179179
EXPORT_SYMBOL_GPL(snd_pcm_stream_unlock_irqrestore);
180180

181+
/* Run PCM ioctl ops */
182+
static int snd_pcm_ops_ioctl(struct snd_pcm_substream *substream,
183+
unsigned cmd, void *arg)
184+
{
185+
if (substream->ops->ioctl)
186+
return substream->ops->ioctl(substream, cmd, arg);
187+
else
188+
return snd_pcm_lib_ioctl(substream, cmd, arg);
189+
}
190+
181191
int snd_pcm_info(struct snd_pcm_substream *substream, struct snd_pcm_info *info)
182192
{
183193
struct snd_pcm *pcm = substream->pcm;
@@ -448,8 +458,9 @@ static int fixup_unreferenced_params(struct snd_pcm_substream *substream,
448458
m = hw_param_mask_c(params, SNDRV_PCM_HW_PARAM_FORMAT);
449459
i = hw_param_interval_c(params, SNDRV_PCM_HW_PARAM_CHANNELS);
450460
if (snd_mask_single(m) && snd_interval_single(i)) {
451-
err = substream->ops->ioctl(substream,
452-
SNDRV_PCM_IOCTL1_FIFO_SIZE, params);
461+
err = snd_pcm_ops_ioctl(substream,
462+
SNDRV_PCM_IOCTL1_FIFO_SIZE,
463+
params);
453464
if (err < 0)
454465
return err;
455466
}
@@ -971,7 +982,7 @@ static int snd_pcm_channel_info(struct snd_pcm_substream *substream,
971982
return -EINVAL;
972983
memset(info, 0, sizeof(*info));
973984
info->channel = channel;
974-
return substream->ops->ioctl(substream, SNDRV_PCM_IOCTL1_CHANNEL_INFO, info);
985+
return snd_pcm_ops_ioctl(substream, SNDRV_PCM_IOCTL1_CHANNEL_INFO, info);
975986
}
976987

977988
static int snd_pcm_channel_info_user(struct snd_pcm_substream *substream,
@@ -1647,7 +1658,7 @@ static int snd_pcm_pre_reset(struct snd_pcm_substream *substream, int state)
16471658
static int snd_pcm_do_reset(struct snd_pcm_substream *substream, int state)
16481659
{
16491660
struct snd_pcm_runtime *runtime = substream->runtime;
1650-
int err = substream->ops->ioctl(substream, SNDRV_PCM_IOCTL1_RESET, NULL);
1661+
int err = snd_pcm_ops_ioctl(substream, SNDRV_PCM_IOCTL1_RESET, NULL);
16511662
if (err < 0)
16521663
return err;
16531664
runtime->hw_ptr_base = 0;

0 commit comments

Comments
 (0)