Skip to content

Commit 8b73b86

Browse files
adiknothtiwai
authored andcommitted
ALSA: hdspm - DRY cleanup in .release callback
This commit removes code duplication between snd_hdspm_{capture,playback}_release. No semantic changes intended, this is purely cosmetic. Signed-off-by: Adrian Knoth <aknoth@google.com> Signed-off-by: Takashi Iwai <tiwai@suse.de>
1 parent 5ecc5dc commit 8b73b86

File tree

1 file changed

+11
-18
lines changed

1 file changed

+11
-18
lines changed

sound/pci/rme9652/hdspm.c

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6120,33 +6120,26 @@ static int snd_hdspm_open(struct snd_pcm_substream *substream)
61206120
return 0;
61216121
}
61226122

6123-
static int snd_hdspm_playback_release(struct snd_pcm_substream *substream)
6123+
static int snd_hdspm_release(struct snd_pcm_substream *substream)
61246124
{
61256125
struct hdspm *hdspm = snd_pcm_substream_chip(substream);
6126+
bool playback = (substream->stream == SNDRV_PCM_STREAM_PLAYBACK);
61266127

61276128
spin_lock_irq(&hdspm->lock);
61286129

6129-
hdspm->playback_pid = -1;
6130-
hdspm->playback_substream = NULL;
6130+
if (playback) {
6131+
hdspm->playback_pid = -1;
6132+
hdspm->playback_substream = NULL;
6133+
} else {
6134+
hdspm->capture_pid = -1;
6135+
hdspm->capture_substream = NULL;
6136+
}
61316137

61326138
spin_unlock_irq(&hdspm->lock);
61336139

61346140
return 0;
61356141
}
61366142

6137-
static int snd_hdspm_capture_release(struct snd_pcm_substream *substream)
6138-
{
6139-
struct hdspm *hdspm = snd_pcm_substream_chip(substream);
6140-
6141-
spin_lock_irq(&hdspm->lock);
6142-
6143-
hdspm->capture_pid = -1;
6144-
hdspm->capture_substream = NULL;
6145-
6146-
spin_unlock_irq(&hdspm->lock);
6147-
return 0;
6148-
}
6149-
61506143
static int snd_hdspm_hwdep_dummy_op(struct snd_hwdep *hw, struct file *file)
61516144
{
61526145
/* we have nothing to initialize but the call is required */
@@ -6363,7 +6356,7 @@ static int snd_hdspm_hwdep_ioctl(struct snd_hwdep *hw, struct file *file,
63636356

63646357
static struct snd_pcm_ops snd_hdspm_playback_ops = {
63656358
.open = snd_hdspm_open,
6366-
.close = snd_hdspm_playback_release,
6359+
.close = snd_hdspm_release,
63676360
.ioctl = snd_hdspm_ioctl,
63686361
.hw_params = snd_hdspm_hw_params,
63696362
.hw_free = snd_hdspm_hw_free,
@@ -6375,7 +6368,7 @@ static struct snd_pcm_ops snd_hdspm_playback_ops = {
63756368

63766369
static struct snd_pcm_ops snd_hdspm_capture_ops = {
63776370
.open = snd_hdspm_open,
6378-
.close = snd_hdspm_capture_release,
6371+
.close = snd_hdspm_release,
63796372
.ioctl = snd_hdspm_ioctl,
63806373
.hw_params = snd_hdspm_hw_params,
63816374
.hw_free = snd_hdspm_hw_free,

0 commit comments

Comments
 (0)