From: SF Markus Elfring <elfring@users.sourceforge.net>
To: alsa-devel@alsa-project.org, Arnd Bergmann <arnd@arndb.de>,
Colin Ian King <colin.king@canonical.com>,
Jaroslav Kysela <perex@perex.cz>,
Jie Yang <yang.jie@linux.intel.com>,
Liam Girdwood <lgirdwood@gmail.com>,
Mark Brown <broonie@kernel.org>, Takashi Iwai <tiwai@suse.com>
Cc: LKML <linux-kernel@vger.kernel.org>, kernel-janitors@vger.kernel.org
Subject: [PATCH] ASoC: sst-firmware: Improve unlocking of a mutex in sst_block_alloc_scratch()
Date: Sun, 19 Nov 2017 10:56:37 +0100 [thread overview]
Message-ID: <49e56746-f178-d0e1-7b01-c75bde63f72c@users.sourceforge.net> (raw)
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 19 Nov 2017 10:45:36 +0100
* Add a jump target so that a call of the function "mutex_unlock" is stored
only once in this function implementation.
* Replace three calls by goto statements.
* Increase the lock scope.
This issue was detected by using the Coccinelle software.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
sound/soc/intel/common/sst-firmware.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/sound/soc/intel/common/sst-firmware.c b/sound/soc/intel/common/sst-firmware.c
index 79a9fdf94d38..665e66670512 100644
--- a/sound/soc/intel/common/sst-firmware.c
+++ b/sound/soc/intel/common/sst-firmware.c
@@ -1097,8 +1097,8 @@ int sst_block_alloc_scratch(struct sst_dsp *dsp)
if (dsp->scratch_size == 0) {
dev_info(dsp->dev, "no modules need scratch buffer\n");
- mutex_unlock(&dsp->mutex);
- return 0;
+ ret = 0;
+ goto unlock;
}
/* allocate blocks for module scratch buffers */
@@ -1127,21 +1127,21 @@ int sst_block_alloc_scratch(struct sst_dsp *dsp)
}
if (ret < 0) {
dev_err(dsp->dev, "error: can't alloc scratch blocks\n");
- mutex_unlock(&dsp->mutex);
- return ret;
+ goto unlock;
}
ret = block_list_prepare(dsp, &dsp->scratch_block_list);
if (ret < 0) {
dev_err(dsp->dev, "error: scratch block prepare failed\n");
- mutex_unlock(&dsp->mutex);
- return ret;
+ goto unlock;
}
/* assign the same offset of scratch to each module */
dsp->scratch_offset = ba.offset;
+ ret = dsp->scratch_size;
+unlock:
mutex_unlock(&dsp->mutex);
- return dsp->scratch_size;
+ return ret;
}
EXPORT_SYMBOL_GPL(sst_block_alloc_scratch);
--
2.15.0
reply other threads:[~2017-11-19 9:58 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=49e56746-f178-d0e1-7b01-c75bde63f72c@users.sourceforge.net \
--to=elfring@users.sourceforge.net \
--cc=alsa-devel@alsa-project.org \
--cc=arnd@arndb.de \
--cc=broonie@kernel.org \
--cc=colin.king@canonical.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=lgirdwood@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=perex@perex.cz \
--cc=tiwai@suse.com \
--cc=yang.jie@linux.intel.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
all inboxes | Powered by JetHome®