Skip to content

Commit c29287b

Browse files
JihedChaibitiwai
authored andcommitted
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>
1 parent e135eee commit c29287b

1 file changed

Lines changed: 8 additions & 8 deletions

File tree

sound/pci/asihpi/asihpi.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -982,12 +982,12 @@ static int snd_card_asihpi_playback_open(struct snd_pcm_substream *substream)
982982
err = hpi_outstream_open(card->hpi->adapter->index,
983983
substream->number, &dpcm->h_stream);
984984
hpi_handle_error(err);
985-
if (err)
985+
if (err) {
986986
kfree(dpcm);
987-
if (err == HPI_ERROR_OBJ_ALREADY_OPEN)
988-
return -EBUSY;
989-
if (err)
987+
if (err == HPI_ERROR_OBJ_ALREADY_OPEN)
988+
return -EBUSY;
990989
return -EIO;
990+
}
991991

992992
/*? also check ASI5000 samplerate source
993993
If external, only support external rate.
@@ -1156,12 +1156,12 @@ static int snd_card_asihpi_capture_open(struct snd_pcm_substream *substream)
11561156
err = hpi_handle_error(
11571157
hpi_instream_open(card->hpi->adapter->index,
11581158
substream->number, &dpcm->h_stream));
1159-
if (err)
1159+
if (err) {
11601160
kfree(dpcm);
1161-
if (err == HPI_ERROR_OBJ_ALREADY_OPEN)
1162-
return -EBUSY;
1163-
if (err)
1161+
if (err == HPI_ERROR_OBJ_ALREADY_OPEN)
1162+
return -EBUSY;
11641163
return -EIO;
1164+
}
11651165

11661166
timer_setup(&dpcm->timer, snd_card_asihpi_timer_function, 0);
11671167
dpcm->substream = substream;

0 commit comments

Comments
 (0)