From: SF Markus Elfring <elfring@users.sourceforge.net>
To: alsa-devel@alsa-project.org, Bhumika Goyal <bhumirks@gmail.com>,
Jaroslav Kysela <perex@perex.cz>, Takashi Iwai <tiwai@suse.com>,
Takashi Sakamoto <o-takashi@sakamocchi.jp>
Cc: LKML <linux-kernel@vger.kernel.org>, kernel-janitors@vger.kernel.org
Subject: [PATCH 3/3] ALSA: rme32: Improve unlocking of an IRQ in two functions
Date: Fri, 17 Nov 2017 22:20:02 +0100 [thread overview]
Message-ID: <5aae0bad-92ba-8d01-2379-e2d80ab180b3@users.sourceforge.net> (raw)
In-Reply-To: <67820e63-aed9-c775-8417-b0f531a9b305@users.sourceforge.net>
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 17 Nov 2017 21:51:54 +0100
* Add jump targets so that a call of the function "spin_unlock_irq"
is stored only twice in these function implementations.
* Replace nine calls by goto statements.
This issue was detected by using the Coccinelle software.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
sound/pci/rme32.c | 65 +++++++++++++++++++++++++++----------------------------
1 file changed, 32 insertions(+), 33 deletions(-)
diff --git a/sound/pci/rme32.c b/sound/pci/rme32.c
index 9e6e0fe3a285..81de4f8f2ca3 100644
--- a/sound/pci/rme32.c
+++ b/sound/pci/rme32.c
@@ -688,28 +688,24 @@ snd_rme32_playback_hw_params(struct snd_pcm_substream *substream,
(rate = snd_rme32_capture_getrate(rme32, &dummy)) > 0) {
/* AutoSync */
if ((int)params_rate(params) != rate) {
- spin_unlock_irq(&rme32->lock);
- return -EIO;
+ err = -EIO;
+ goto unlock;
}
} else {
err = snd_rme32_playback_setrate(rme32, params_rate(params));
- if (err < 0) {
- spin_unlock_irq(&rme32->lock);
- return err;
- }
+ if (err < 0)
+ goto unlock;
}
err = snd_rme32_setformat(rme32, params_format(params));
- if (err < 0) {
- spin_unlock_irq(&rme32->lock);
- return err;
- }
+ if (err < 0)
+ goto unlock;
snd_rme32_setframelog(rme32, params_channels(params), 1);
if (rme32->capture_periodsize != 0) {
if (params_period_size(params) << rme32->playback_frlog != rme32->capture_periodsize) {
- spin_unlock_irq(&rme32->lock);
- return -EBUSY;
+ err = -EBUSY;
+ goto unlock;
}
}
rme32->playback_periodsize = params_period_size(params) << rme32->playback_frlog;
@@ -722,6 +718,10 @@ snd_rme32_playback_hw_params(struct snd_pcm_substream *substream,
spin_unlock_irq(&rme32->lock);
return 0;
+
+unlock:
+ spin_unlock_irq(&rme32->lock);
+ return err;
}
static int
@@ -749,27 +749,20 @@ snd_rme32_capture_hw_params(struct snd_pcm_substream *substream,
writel(rme32->wcreg, rme32->iobase + RME32_IO_CONTROL_REGISTER);
err = snd_rme32_setformat(rme32, params_format(params));
- if (err < 0) {
- spin_unlock_irq(&rme32->lock);
- return err;
- }
+ if (err < 0)
+ goto unlock;
+
err = snd_rme32_playback_setrate(rme32, params_rate(params));
- if (err < 0) {
- spin_unlock_irq(&rme32->lock);
- return err;
- }
+ if (err < 0)
+ goto unlock;
+
rate = snd_rme32_capture_getrate(rme32, &isadat);
- if (rate > 0) {
- if ((int)params_rate(params) != rate) {
- spin_unlock_irq(&rme32->lock);
- return -EIO;
- }
- if ((isadat && runtime->hw.channels_min == 2) ||
- (!isadat && runtime->hw.channels_min == 8)) {
- spin_unlock_irq(&rme32->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;
+
/* AutoSync off for recording */
rme32->wcreg &= ~RME32_WCR_AUTOSYNC;
writel(rme32->wcreg, rme32->iobase + RME32_IO_CONTROL_REGISTER);
@@ -778,8 +771,8 @@ snd_rme32_capture_hw_params(struct snd_pcm_substream *substream,
if (rme32->playback_periodsize != 0) {
if (params_period_size(params) << rme32->capture_frlog !=
rme32->playback_periodsize) {
- spin_unlock_irq(&rme32->lock);
- return -EBUSY;
+ err = -EBUSY;
+ goto unlock;
}
}
rme32->capture_periodsize =
@@ -787,6 +780,12 @@ snd_rme32_capture_hw_params(struct snd_pcm_substream *substream,
spin_unlock_irq(&rme32->lock);
return 0;
+
+e_io:
+ err = -EIO;
+unlock:
+ spin_unlock_irq(&rme32->lock);
+ return err;
}
static int snd_rme32_pcm_hw_free(struct snd_pcm_substream *substream)
--
2.15.0
prev parent reply other threads:[~2017-11-17 21:20 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-17 21:14 [PATCH 0/3] ALSA-RME Digi32: Fine-tuning for seven function implementations SF Markus Elfring
2017-11-17 21:16 ` [PATCH 1/3] ALSA: rme32: Adjust 15 function calls together with a variable assignment SF Markus Elfring
2017-11-17 21:18 ` [PATCH 2/3] ALSA: rme32: Use common error handling code in snd_rme32_probe() SF Markus Elfring
2017-11-17 21:20 ` SF Markus Elfring [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5aae0bad-92ba-8d01-2379-e2d80ab180b3@users.sourceforge.net \
--to=elfring@users.sourceforge.net \
--cc=alsa-devel@alsa-project.org \
--cc=bhumirks@gmail.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=o-takashi@sakamocchi.jp \
--cc=perex@perex.cz \
--cc=tiwai@suse.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome