From e3649eb2337c41167b1266fc5df48a33def73a7f Mon Sep 17 00:00:00 2001 From: Eric Laurent Date: Mon, 21 Nov 2016 20:40:13 -0800 Subject: [PATCH] ALSA: Compress - dont use lock for all ioctls Some simple ioctls like timsetamp query, capabities query can be done anytime and should not be under the stream lock. Move these to snd_compress_simple_iotcls() which is invoked without lock held. While at it, improve readblity a bit by sprinkling some empty lines. Change-Id: Icc8ffdadd565c635f6a95e7e5bdda76257f24ea3 Signed-off-by: Vinod Koul Signed-off-by: Eric Laurent Git-commit: 6a44374b8b92e9946dc1e5c15c2a11003aa859b1 Git-repo: https://android.googlesource.com/kernel/msm [dhakumar@codeaurora.org: resolved merge conflicts] Signed-off-by: Dhananjay Kumar [bgoswami@codeaurora.org: resolved merge conflicts] Signed-off-by: Banajit Goswami Signed-off-by: Meng Wang --- sound/core/compress_offload.c | 52 ++++++++++++++++++++++++++++++++++- 1 file changed, 51 insertions(+), 1 deletion(-) diff --git a/sound/core/compress_offload.c b/sound/core/compress_offload.c index 8e1fca0b682d..e83c3f5b35ab 100644 --- a/sound/core/compress_offload.c +++ b/sound/core/compress_offload.c @@ -950,6 +950,48 @@ static int snd_compr_set_next_track_param(struct snd_compr_stream *stream, retval = stream->ops->set_next_track_param(stream, &codec_options); return retval; } + +static int snd_compress_simple_ioctls(struct file *file, + struct snd_compr_stream *stream, + unsigned int cmd, unsigned long arg) +{ + int retval = -ENOTTY; + + switch (_IOC_NR(cmd)) { + case _IOC_NR(SNDRV_COMPRESS_IOCTL_VERSION): + retval = put_user(SNDRV_COMPRESS_VERSION, + (int __user *)arg) ? -EFAULT : 0; + break; + + case _IOC_NR(SNDRV_COMPRESS_GET_CAPS): + retval = snd_compr_get_caps(stream, arg); + break; + +#ifndef COMPR_CODEC_CAPS_OVERFLOW + case _IOC_NR(SNDRV_COMPRESS_GET_CODEC_CAPS): + retval = snd_compr_get_codec_caps(stream, arg); + break; +#endif + + case _IOC_NR(SNDRV_COMPRESS_TSTAMP): + retval = snd_compr_tstamp(stream, arg); + break; + + case _IOC_NR(SNDRV_COMPRESS_AVAIL): + retval = snd_compr_ioctl_avail(stream, arg); + break; + + case _IOC_NR(SNDRV_COMPRESS_DRAIN): + retval = snd_compr_drain(stream); + break; + + case _IOC_NR(SNDRV_COMPRESS_PARTIAL_DRAIN): + retval = snd_compr_partial_drain(stream); + break; + } + + return retval; +} #endif static long snd_compr_ioctl(struct file *f, unsigned int cmd, unsigned long arg) @@ -965,6 +1007,7 @@ static long snd_compr_ioctl(struct file *f, unsigned int cmd, unsigned long arg) mutex_lock(&stream->device->lock); switch (_IOC_NR(cmd)) { +#ifndef CONFIG_AUDIO_QGKI case _IOC_NR(SNDRV_COMPRESS_IOCTL_VERSION): retval = put_user(SNDRV_COMPRESS_VERSION, (int __user *)arg) ? -EFAULT : 0; @@ -976,6 +1019,7 @@ static long snd_compr_ioctl(struct file *f, unsigned int cmd, unsigned long arg) case _IOC_NR(SNDRV_COMPRESS_GET_CODEC_CAPS): retval = snd_compr_get_codec_caps(stream, arg); break; +#endif #endif case _IOC_NR(SNDRV_COMPRESS_SET_PARAMS): retval = snd_compr_set_params(stream, arg); @@ -989,12 +1033,14 @@ static long snd_compr_ioctl(struct file *f, unsigned int cmd, unsigned long arg) case _IOC_NR(SNDRV_COMPRESS_GET_METADATA): retval = snd_compr_get_metadata(stream, arg); break; +#ifndef CONFIG_AUDIO_QGKI case _IOC_NR(SNDRV_COMPRESS_TSTAMP): retval = snd_compr_tstamp(stream, arg); break; case _IOC_NR(SNDRV_COMPRESS_AVAIL): retval = snd_compr_ioctl_avail(stream, arg); break; +#endif case _IOC_NR(SNDRV_COMPRESS_PAUSE): retval = snd_compr_pause(stream); break; @@ -1007,12 +1053,14 @@ static long snd_compr_ioctl(struct file *f, unsigned int cmd, unsigned long arg) case _IOC_NR(SNDRV_COMPRESS_STOP): retval = snd_compr_stop(stream); break; +#ifndef CONFIG_AUDIO_QGKI case _IOC_NR(SNDRV_COMPRESS_DRAIN): retval = snd_compr_drain(stream); break; case _IOC_NR(SNDRV_COMPRESS_PARTIAL_DRAIN): retval = snd_compr_partial_drain(stream); break; +#endif case _IOC_NR(SNDRV_COMPRESS_NEXT_TRACK): retval = snd_compr_next_track(stream); break; @@ -1020,8 +1068,10 @@ static long snd_compr_ioctl(struct file *f, unsigned int cmd, unsigned long arg) case _IOC_NR(SNDRV_COMPRESS_SET_NEXT_TRACK_PARAM): retval = snd_compr_set_next_track_param(stream, arg); break; + default: + mutex_unlock(&stream->device->lock); + return snd_compress_simple_ioctls(f, stream, cmd, arg); #endif - } mutex_unlock(&stream->device->lock); return retval;