lkml.org 
[lkml]   [2017]   [Nov]   [18]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Subject[PATCH 2/2] ALSA: rme96: Improve unlocking of an IRQ in snd_rme96_capture_hw_params()
From
Date
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 18 Nov 2017 13:26:59 +0100

* Add jump targets so that a call of the function "spin_unlock_irq"
is stored only twice in this function implementation.

* Replace five calls by goto statements.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
sound/pci/rme96.c | 39 ++++++++++++++++++---------------------
1 file changed, 18 insertions(+), 21 deletions(-)

diff --git a/sound/pci/rme96.c b/sound/pci/rme96.c
index fd8a62ceffde..1c1106f770e7 100644
--- a/sound/pci/rme96.c
+++ b/sound/pci/rme96.c
@@ -1066,30 +1066,21 @@ snd_rme96_capture_hw_params(struct snd_pcm_substream *substream,

spin_lock_irq(&rme96->lock);
err = snd_rme96_capture_setformat(rme96, params_format(params));
- if (err < 0) {
- spin_unlock_irq(&rme96->lock);
- return err;
- }
+ if (err < 0)
+ goto unlock;
+
if (snd_rme96_getinputtype(rme96) == RME96_INPUT_ANALOG) {
err = snd_rme96_capture_analog_setrate(rme96,
params_rate(params));
- if (err < 0) {
- spin_unlock_irq(&rme96->lock);
- return err;
- }
+ if (err < 0)
+ goto unlock;
} else {
rate = snd_rme96_capture_getrate(rme96, &isadat);
- if (rate > 0) {
- if ((int)params_rate(params) != rate) {
- spin_unlock_irq(&rme96->lock);
- return -EIO;
- }
- if ((isadat && runtime->hw.channels_min == 2) ||
- (!isadat && runtime->hw.channels_min == 8)) {
- spin_unlock_irq(&rme96->lock);
- return -EIO;
- }
- }
+ if (rate > 0 &&
+ ((int)params_rate(params) != rate ||
+ (isadat && runtime->hw.channels_min == 2) ||
+ (!isadat && runtime->hw.channels_min == 8)))
+ goto e_io;
}

snd_rme96_setframelog(rme96, params_channels(params), 0);
@@ -1097,8 +1088,8 @@ snd_rme96_capture_hw_params(struct snd_pcm_substream *substream,
if (params_period_size(params) << rme96->capture_frlog !=
rme96->playback_periodsize)
{
- spin_unlock_irq(&rme96->lock);
- return -EBUSY;
+ err = -EBUSY;
+ goto unlock;
}
}
rme96->capture_periodsize =
@@ -1107,6 +1098,12 @@ snd_rme96_capture_hw_params(struct snd_pcm_substream *substream,
spin_unlock_irq(&rme96->lock);

return 0;
+
+e_io:
+ err = -EIO;
+unlock:
+ spin_unlock_irq(&rme96->lock);
+ return err;
}

static void
--
2.15.0
\
 
 \ /
  Last update: 2017-11-18 13:55    [W:0.022 / U:0.412 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site