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: kernel-janitors@vger.kernel.org, LKML <linux-kernel@vger.kernel.org>
Subject: [PATCH 2/2] ALSA: rme96: Improve unlocking of an IRQ in snd_rme96_capture_hw_params()
Date: Sat, 18 Nov 2017 13:53:45 +0100 [thread overview]
Message-ID: <1e2f56b0-df93-d9d3-da79-758439de00a5@users.sourceforge.net> (raw)
In-Reply-To: <7b7da9a6-64e1-bde5-99aa-de21f0665323@users.sourceforge.net>
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
prev parent reply other threads:[~2017-11-18 12:53 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-18 12:51 [PATCH 0/2] ALSA-RME Digi96: Fine-tuning for four function implementations SF Markus Elfring
2017-11-18 12:52 ` [PATCH 1/2] ALSA: rme96: Adjust 11 function calls together with a variable assignment SF Markus Elfring
2017-11-18 12:53 ` 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=1e2f56b0-df93-d9d3-da79-758439de00a5@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;
as well as URLs for NNTP newsgroup(s).