Skip to content

Commit

Permalink
ALSA: x86: Use runtime PM autosuspend
Browse files Browse the repository at this point in the history
This patch adds a few lines to the driver to use autosuspend for the
runtime PM.  It'll become useful with the combination of the keep-link
feature.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
  • Loading branch information
Takashi Iwai committed Feb 21, 2017
1 parent 34371d2 commit 3002b9f
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions sound/x86/intel_hdmi_audio.c
Original file line number Diff line number Diff line change
Expand Up @@ -1082,7 +1082,8 @@ static int had_pcm_open(struct snd_pcm_substream *substream)

return retval;
error:
pm_runtime_put(intelhaddata->dev);
pm_runtime_mark_last_busy(intelhaddata->dev);
pm_runtime_put_autosuspend(intelhaddata->dev);
return retval;
}

Expand All @@ -1106,7 +1107,8 @@ static int had_pcm_close(struct snd_pcm_substream *substream)
}
spin_unlock_irq(&intelhaddata->had_spinlock);

pm_runtime_put(intelhaddata->dev);
pm_runtime_mark_last_busy(intelhaddata->dev);
pm_runtime_put_autosuspend(intelhaddata->dev);
return 0;
}

Expand Down Expand Up @@ -1596,7 +1598,8 @@ static void had_audio_wq(struct work_struct *work)
had_process_mode_change(ctx);
}
mutex_unlock(&ctx->mutex);
pm_runtime_put(ctx->dev);
pm_runtime_mark_last_busy(ctx->dev);
pm_runtime_put_autosuspend(ctx->dev);
}

/*
Expand Down Expand Up @@ -1643,10 +1646,17 @@ static int __maybe_unused hdmi_lpe_audio_suspend(struct device *dev)
return err;
}

static int hdmi_lpe_audio_runtime_resume(struct device *dev)
{
pm_runtime_mark_last_busy(dev);
return 0;
}

static int __maybe_unused hdmi_lpe_audio_resume(struct device *dev)
{
struct snd_intelhad *ctx = dev_get_drvdata(dev);

hdmi_lpe_audio_runtime_resume(dev);
snd_power_change_state(ctx->card, SNDRV_CTL_POWER_D0);
return 0;
}
Expand Down Expand Up @@ -1799,6 +1809,9 @@ static int hdmi_lpe_audio_probe(struct platform_device *pdev)
pdata->notify_pending = false;
spin_unlock_irq(&pdata->lpe_audio_slock);

pm_runtime_use_autosuspend(&pdev->dev);
pm_runtime_mark_last_busy(&pdev->dev);

pm_runtime_set_active(&pdev->dev);
pm_runtime_enable(&pdev->dev);

Expand Down Expand Up @@ -1827,7 +1840,8 @@ static int hdmi_lpe_audio_remove(struct platform_device *pdev)

static const struct dev_pm_ops hdmi_lpe_audio_pm = {
SET_SYSTEM_SLEEP_PM_OPS(hdmi_lpe_audio_suspend, hdmi_lpe_audio_resume)
SET_RUNTIME_PM_OPS(hdmi_lpe_audio_runtime_suspend, NULL, NULL)
SET_RUNTIME_PM_OPS(hdmi_lpe_audio_runtime_suspend,
hdmi_lpe_audio_runtime_resume, NULL)
};

static struct platform_driver hdmi_lpe_audio_driver = {
Expand Down

0 comments on commit 3002b9f

Please sign in to comment.