Merge tag 'asoc-fix-v5.4-rc6' of https://git.kernel.org/pub/scm/linux/kernel/git...
authorTakashi Iwai <tiwai@suse.de>
Thu, 7 Nov 2019 12:52:17 +0000 (13:52 +0100)
committerTakashi Iwai <tiwai@suse.de>
Thu, 7 Nov 2019 12:52:17 +0000 (13:52 +0100)
ASoC: Fixes for v5.4

These are a collection of fixes since v5.4-rc4 that have accumilated,
they're all driver specific and there's nothing major in here so it's
probably not essential to actually send them but I'll leave that call to
you.

1  2 
sound/core/compress_offload.c

index 41905afada63fee667d34478301217e05b98d3c5,942af8c29b79f6a87331874898732eb6434c5335..f34ce564d92c481791c4121c5b4c8b64f953be9e
@@@ -528,7 -528,7 +528,7 @@@ static int snd_compress_check_input(str
  {
        /* first let's check the buffer parameter's */
        if (params->buffer.fragment_size == 0 ||
-           params->buffer.fragments > INT_MAX / params->buffer.fragment_size ||
+           params->buffer.fragments > U32_MAX / params->buffer.fragment_size ||
            params->buffer.fragments == 0)
                return -EINVAL;
  
@@@ -574,7 -574,10 +574,7 @@@ snd_compr_set_params(struct snd_compr_s
                stream->metadata_set = false;
                stream->next_track = false;
  
 -              if (stream->direction == SND_COMPRESS_PLAYBACK)
 -                      stream->runtime->state = SNDRV_PCM_STATE_SETUP;
 -              else
 -                      stream->runtime->state = SNDRV_PCM_STATE_PREPARED;
 +              stream->runtime->state = SNDRV_PCM_STATE_SETUP;
        } else {
                return -EPERM;
        }
@@@ -690,17 -693,8 +690,17 @@@ static int snd_compr_start(struct snd_c
  {
        int retval;
  
 -      if (stream->runtime->state != SNDRV_PCM_STATE_PREPARED)
 +      switch (stream->runtime->state) {
 +      case SNDRV_PCM_STATE_SETUP:
 +              if (stream->direction != SND_COMPRESS_CAPTURE)
 +                      return -EPERM;
 +              break;
 +      case SNDRV_PCM_STATE_PREPARED:
 +              break;
 +      default:
                return -EPERM;
 +      }
 +
        retval = stream->ops->trigger(stream, SNDRV_PCM_TRIGGER_START);
        if (!retval)
                stream->runtime->state = SNDRV_PCM_STATE_RUNNING;
@@@ -711,15 -705,9 +711,15 @@@ static int snd_compr_stop(struct snd_co
  {
        int retval;
  
 -      if (stream->runtime->state == SNDRV_PCM_STATE_PREPARED ||
 -                      stream->runtime->state == SNDRV_PCM_STATE_SETUP)
 +      switch (stream->runtime->state) {
 +      case SNDRV_PCM_STATE_OPEN:
 +      case SNDRV_PCM_STATE_SETUP:
 +      case SNDRV_PCM_STATE_PREPARED:
                return -EPERM;
 +      default:
 +              break;
 +      }
 +
        retval = stream->ops->trigger(stream, SNDRV_PCM_TRIGGER_STOP);
        if (!retval) {
                snd_compr_drain_notify(stream);
@@@ -807,17 -795,9 +807,17 @@@ static int snd_compr_drain(struct snd_c
  {
        int retval;
  
 -      if (stream->runtime->state == SNDRV_PCM_STATE_PREPARED ||
 -                      stream->runtime->state == SNDRV_PCM_STATE_SETUP)
 +      switch (stream->runtime->state) {
 +      case SNDRV_PCM_STATE_OPEN:
 +      case SNDRV_PCM_STATE_SETUP:
 +      case SNDRV_PCM_STATE_PREPARED:
 +      case SNDRV_PCM_STATE_PAUSED:
                return -EPERM;
 +      case SNDRV_PCM_STATE_XRUN:
 +              return -EPIPE;
 +      default:
 +              break;
 +      }
  
        retval = stream->ops->trigger(stream, SND_COMPR_TRIGGER_DRAIN);
        if (retval) {
@@@ -837,10 -817,6 +837,10 @@@ static int snd_compr_next_track(struct 
        if (stream->runtime->state != SNDRV_PCM_STATE_RUNNING)
                return -EPERM;
  
 +      /* next track doesn't have any meaning for capture streams */
 +      if (stream->direction == SND_COMPRESS_CAPTURE)
 +              return -EPERM;
 +
        /* you can signal next track if this is intended to be a gapless stream
         * and current track metadata is set
         */
  static int snd_compr_partial_drain(struct snd_compr_stream *stream)
  {
        int retval;
 -      if (stream->runtime->state == SNDRV_PCM_STATE_PREPARED ||
 -                      stream->runtime->state == SNDRV_PCM_STATE_SETUP)
 +
 +      switch (stream->runtime->state) {
 +      case SNDRV_PCM_STATE_OPEN:
 +      case SNDRV_PCM_STATE_SETUP:
 +      case SNDRV_PCM_STATE_PREPARED:
 +      case SNDRV_PCM_STATE_PAUSED:
 +              return -EPERM;
 +      case SNDRV_PCM_STATE_XRUN:
 +              return -EPIPE;
 +      default:
 +              break;
 +      }
 +
 +      /* partial drain doesn't have any meaning for capture streams */
 +      if (stream->direction == SND_COMPRESS_CAPTURE)
                return -EPERM;
 +
        /* stream can be drained only when next track has been signalled */
        if (stream->next_track == false)
                return -EPERM;