Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 8b73b867 authored by Adrian Knoth's avatar Adrian Knoth Committed by Takashi Iwai
Browse files

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: default avatarAdrian Knoth <aknoth@google.com>
Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent 5ecc5dc7
Loading
Loading
Loading
Loading
+11 −18
Original line number Original line Diff line number Diff line
@@ -6120,30 +6120,23 @@ static int snd_hdspm_open(struct snd_pcm_substream *substream)
	return 0;
	return 0;
}
}


static int snd_hdspm_playback_release(struct snd_pcm_substream *substream)
static int snd_hdspm_release(struct snd_pcm_substream *substream)
{
{
	struct hdspm *hdspm = snd_pcm_substream_chip(substream);
	struct hdspm *hdspm = snd_pcm_substream_chip(substream);
	bool playback = (substream->stream == SNDRV_PCM_STREAM_PLAYBACK);


	spin_lock_irq(&hdspm->lock);
	spin_lock_irq(&hdspm->lock);


	if (playback) {
		hdspm->playback_pid = -1;
		hdspm->playback_pid = -1;
		hdspm->playback_substream = NULL;
		hdspm->playback_substream = NULL;

	} else {
	spin_unlock_irq(&hdspm->lock);

	return 0;
}

static int snd_hdspm_capture_release(struct snd_pcm_substream *substream)
{
	struct hdspm *hdspm = snd_pcm_substream_chip(substream);

	spin_lock_irq(&hdspm->lock);

		hdspm->capture_pid = -1;
		hdspm->capture_pid = -1;
		hdspm->capture_substream = NULL;
		hdspm->capture_substream = NULL;
	}


	spin_unlock_irq(&hdspm->lock);
	spin_unlock_irq(&hdspm->lock);

	return 0;
	return 0;
}
}


@@ -6363,7 +6356,7 @@ static int snd_hdspm_hwdep_ioctl(struct snd_hwdep *hw, struct file *file,


static struct snd_pcm_ops snd_hdspm_playback_ops = {
static struct snd_pcm_ops snd_hdspm_playback_ops = {
	.open = snd_hdspm_open,
	.open = snd_hdspm_open,
	.close = snd_hdspm_playback_release,
	.close = snd_hdspm_release,
	.ioctl = snd_hdspm_ioctl,
	.ioctl = snd_hdspm_ioctl,
	.hw_params = snd_hdspm_hw_params,
	.hw_params = snd_hdspm_hw_params,
	.hw_free = snd_hdspm_hw_free,
	.hw_free = snd_hdspm_hw_free,
@@ -6375,7 +6368,7 @@ static struct snd_pcm_ops snd_hdspm_playback_ops = {


static struct snd_pcm_ops snd_hdspm_capture_ops = {
static struct snd_pcm_ops snd_hdspm_capture_ops = {
	.open = snd_hdspm_open,
	.open = snd_hdspm_open,
	.close = snd_hdspm_capture_release,
	.close = snd_hdspm_release,
	.ioctl = snd_hdspm_ioctl,
	.ioctl = snd_hdspm_ioctl,
	.hw_params = snd_hdspm_hw_params,
	.hw_params = snd_hdspm_hw_params,
	.hw_free = snd_hdspm_hw_free,
	.hw_free = snd_hdspm_hw_free,