aboutsummaryrefslogtreecommitdiffstats
path: root/sound/pci
diff options
context:
space:
mode:
authorJihed Chaibi <jihed.chaibi.dev@gmail.com>2025-09-14 22:59:45 +0200
committerTakashi Iwai <tiwai@suse.de>2025-09-15 09:25:47 +0200
commitc29287bb32bc72a037c34d84a160060a6122b7ed (patch)
tree0086c1b5c9e91e74750c62b61a5d24b8593f4698 /sound/pci
parentALSA: aoa: Remove redundant size arguments from strscpy() (diff)
downloadlinux-c29287bb32bc72a037c34d84a160060a6122b7ed.tar.gz
linux-c29287bb32bc72a037c34d84a160060a6122b7ed.zip
ALSA: asihpi: Simplify error handling in PCM substream setup
Refactor error handling in the PCM substream setup to combine redundant checks and improve code readability. Free the dpcm structure and return appropriate error codes (-EBUSY for HPI_ERROR_OBJ_ALREADY_OPEN, -EIO for other errors) in a single block. Signed-off-by: Jihed Chaibi <jihed.chaibi.dev@gmail.com> Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/pci')
-rw-r--r--sound/pci/asihpi/asihpi.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/sound/pci/asihpi/asihpi.c b/sound/pci/asihpi/asihpi.c
index 8419f2b6e589..fd0a67b772d1 100644
--- a/sound/pci/asihpi/asihpi.c
+++ b/sound/pci/asihpi/asihpi.c
@@ -982,12 +982,12 @@ static int snd_card_asihpi_playback_open(struct snd_pcm_substream *substream)
err = hpi_outstream_open(card->hpi->adapter->index,
substream->number, &dpcm->h_stream);
hpi_handle_error(err);
- if (err)
+ if (err) {
kfree(dpcm);
- if (err == HPI_ERROR_OBJ_ALREADY_OPEN)
- return -EBUSY;
- if (err)
+ if (err == HPI_ERROR_OBJ_ALREADY_OPEN)
+ return -EBUSY;
return -EIO;
+ }
/*? also check ASI5000 samplerate source
If external, only support external rate.
@@ -1156,12 +1156,12 @@ static int snd_card_asihpi_capture_open(struct snd_pcm_substream *substream)
err = hpi_handle_error(
hpi_instream_open(card->hpi->adapter->index,
substream->number, &dpcm->h_stream));
- if (err)
+ if (err) {
kfree(dpcm);
- if (err == HPI_ERROR_OBJ_ALREADY_OPEN)
- return -EBUSY;
- if (err)
+ if (err == HPI_ERROR_OBJ_ALREADY_OPEN)
+ return -EBUSY;
return -EIO;
+ }
timer_setup(&dpcm->timer, snd_card_asihpi_timer_function, 0);
dpcm->substream = substream;