From: Markus Elfring <Markus.Elfring@web.de>
To: linux-sound@vger.kernel.org, Jaroslav Kysela <perex@perex.cz>,
Takashi Iwai <tiwai@suse.com>
Cc: LKML <linux-kernel@vger.kernel.org>
Subject: [PATCH] ALSA: i2c: cs8427: Use common code in snd_cs8427_qsubcode_get()
Date: Sun, 15 Sep 2024 13:48:51 +0200 [thread overview]
Message-ID: <641210ba-571b-43e7-9007-5633a6c7434c@web.de> (raw)
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 15 Sep 2024 13:38:29 +0200
Add two labels so that a bit of exception handling can be better reused
at the end of this function implementation.
This issue was detected by using the Coccinelle software.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
sound/i2c/cs8427.c | 17 ++++++++++++-----
1 file changed, 12 insertions(+), 5 deletions(-)
diff --git a/sound/i2c/cs8427.c b/sound/i2c/cs8427.c
index 29a1a7a0d050..ee650006cac4 100644
--- a/sound/i2c/cs8427.c
+++ b/sound/i2c/cs8427.c
@@ -397,18 +397,25 @@ static int snd_cs8427_qsubcode_get(struct snd_kcontrol *kcontrol,
if (err != 1) {
dev_err(device->bus->card->dev,
"unable to send register 0x%x byte to CS8427\n", reg);
- snd_i2c_unlock(device->bus);
- return err < 0 ? err : -EIO;
+ goto recheck_err;
}
err = snd_i2c_readbytes(device, ucontrol->value.bytes.data, 10);
if (err != 10) {
dev_err(device->bus->card->dev,
"unable to read Q-subcode bytes from CS8427\n");
- snd_i2c_unlock(device->bus);
- return err < 0 ? err : -EIO;
+ goto recheck_err;
}
+
+ err = 0;
+unlock:
snd_i2c_unlock(device->bus);
- return 0;
+ return err;
+
+recheck_err:
+ if (err >= 0)
+ err = -EIO;
+
+ goto unlock;
}
static int snd_cs8427_spdif_info(struct snd_kcontrol *kcontrol,
--
2.46.0
next reply other threads:[~2024-09-15 11:49 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-15 11:48 Markus Elfring [this message]
2024-09-16 7:18 ` [PATCH] ALSA: i2c: cs8427: Use common code in snd_cs8427_qsubcode_get() Takashi Iwai
2024-09-17 6:33 ` Markus Elfring
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=641210ba-571b-43e7-9007-5633a6c7434c@web.de \
--to=markus.elfring@web.de \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sound@vger.kernel.org \
--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