diff mbox

[v6,1/4] ALSA: compress: Replace complex if statement with switch

Message ID 1461338126-25998-2-git-send-email-ckeepax@opensource.wolfsonmicro.com (mailing list archive)
State New, archived
Headers show

Commit Message

Charles Keepax April 22, 2016, 3:15 p.m. UTC
A switch statement looks a bit cleaner than an if statement
spread over 3 lines, as such update this to a switch.

Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
Acked-by: Vinod Koul <vinod.koul@intel.com>
---
 sound/core/compress_offload.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

Comments

Charles Keepax May 4, 2016, 3:01 p.m. UTC | #1
On Fri, Apr 22, 2016 at 04:15:23PM +0100, Charles Keepax wrote:
> A switch statement looks a bit cleaner than an if statement
> spread over 3 lines, as such update this to a switch.
> 
> Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
> Acked-by: Vinod Koul <vinod.koul@intel.com>
> ---

As this patch only tenuously relates to the rest of this patch
chain I have included it in a new patch chain [1], best not merge the
one from here so they don't both end up merged through different
trees.

Thanks,
Charles

[1] http://mailman.alsa-project.org/pipermail/alsa-devel/2016-May/107636.html
diff mbox

Patch

diff --git a/sound/core/compress_offload.c b/sound/core/compress_offload.c
index a9933c0..507071d 100644
--- a/sound/core/compress_offload.c
+++ b/sound/core/compress_offload.c
@@ -288,9 +288,12 @@  static ssize_t snd_compr_write(struct file *f, const char __user *buf,
 	stream = &data->stream;
 	mutex_lock(&stream->device->lock);
 	/* write is allowed when stream is running or has been steup */
-	if (stream->runtime->state != SNDRV_PCM_STATE_SETUP &&
-	    stream->runtime->state != SNDRV_PCM_STATE_PREPARED &&
-			stream->runtime->state != SNDRV_PCM_STATE_RUNNING) {
+	switch (stream->runtime->state) {
+	case SNDRV_PCM_STATE_SETUP:
+	case SNDRV_PCM_STATE_PREPARED:
+	case SNDRV_PCM_STATE_RUNNING:
+		break;
+	default:
 		mutex_unlock(&stream->device->lock);
 		return -EBADFD;
 	}