Commit fbce23a0 authored by Takashi Iwai's avatar Takashi Iwai

ALSA: hda - Check the return value from pm_runtime_get/put*()

This patch changes the return type of snd_hdac_power_up/down() and
variants to pass the error code from the underlying
pm_runtime_get/put() calls.  Currently they are ignored, but in most
places, these should be handled properly.

As an example, the regmap handler is updated to check the return value
and accesses the register only when the wakeup succeeds.
Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent 6986a0e2
......@@ -164,15 +164,15 @@ static inline int snd_hdac_read_parm(struct hdac_device *codec, hda_nid_t nid,
}
#ifdef CONFIG_PM
void snd_hdac_power_up(struct hdac_device *codec);
void snd_hdac_power_down(struct hdac_device *codec);
void snd_hdac_power_up_pm(struct hdac_device *codec);
void snd_hdac_power_down_pm(struct hdac_device *codec);
int snd_hdac_power_up(struct hdac_device *codec);
int snd_hdac_power_down(struct hdac_device *codec);
int snd_hdac_power_up_pm(struct hdac_device *codec);
int snd_hdac_power_down_pm(struct hdac_device *codec);
#else
static inline void snd_hdac_power_up(struct hdac_device *codec) {}
static inline void snd_hdac_power_down(struct hdac_device *codec) {}
static inline void snd_hdac_power_up_pm(struct hdac_device *codec) {}
static inline void snd_hdac_power_down_pm(struct hdac_device *codec) {}
static inline int snd_hdac_power_up(struct hdac_device *codec) { return 0; }
static inline int snd_hdac_power_down(struct hdac_device *codec) { return 0; }
static inline int snd_hdac_power_up_pm(struct hdac_device *codec) { return 0; }
static inline int snd_hdac_power_down_pm(struct hdac_device *codec) { return 0; }
#endif
/*
......
......@@ -501,23 +501,27 @@ EXPORT_SYMBOL_GPL(snd_hdac_get_connections);
* This function calls the runtime PM helper to power up the given codec.
* Unlike snd_hdac_power_up_pm(), you should call this only for the code
* path that isn't included in PM path. Otherwise it gets stuck.
*
* Returns zero if successful, or a negative error code.
*/
void snd_hdac_power_up(struct hdac_device *codec)
int snd_hdac_power_up(struct hdac_device *codec)
{
pm_runtime_get_sync(&codec->dev);
return pm_runtime_get_sync(&codec->dev);
}
EXPORT_SYMBOL_GPL(snd_hdac_power_up);
/**
* snd_hdac_power_down - power down the codec
* @codec: the codec object
*
* Returns zero if successful, or a negative error code.
*/
void snd_hdac_power_down(struct hdac_device *codec)
int snd_hdac_power_down(struct hdac_device *codec)
{
struct device *dev = &codec->dev;
pm_runtime_mark_last_busy(dev);
pm_runtime_put_autosuspend(dev);
return pm_runtime_put_autosuspend(dev);
}
EXPORT_SYMBOL_GPL(snd_hdac_power_down);
......@@ -529,11 +533,14 @@ EXPORT_SYMBOL_GPL(snd_hdac_power_down);
* which may be called by PM suspend/resume again. OTOH, if a power-up
* call must wake up the sleeper (e.g. in a kctl callback), use
* snd_hdac_power_up() instead.
*
* Returns zero if successful, or a negative error code.
*/
void snd_hdac_power_up_pm(struct hdac_device *codec)
int snd_hdac_power_up_pm(struct hdac_device *codec)
{
if (!atomic_inc_not_zero(&codec->in_pm))
snd_hdac_power_up(codec);
return snd_hdac_power_up(codec);
return 0;
}
EXPORT_SYMBOL_GPL(snd_hdac_power_up_pm);
......@@ -543,11 +550,14 @@ EXPORT_SYMBOL_GPL(snd_hdac_power_up_pm);
*
* Like snd_hdac_power_up_pm(), this function is used in a recursive
* code path like init code which may be called by PM suspend/resume again.
*
* Returns zero if successful, or a negative error code.
*/
void snd_hdac_power_down_pm(struct hdac_device *codec)
int snd_hdac_power_down_pm(struct hdac_device *codec)
{
if (atomic_dec_if_positive(&codec->in_pm) < 0)
snd_hdac_power_down(codec);
return snd_hdac_power_down(codec);
return 0;
}
EXPORT_SYMBOL_GPL(snd_hdac_power_down_pm);
#endif
......
......@@ -410,7 +410,8 @@ int snd_hdac_regmap_write_raw(struct hdac_device *codec, unsigned int reg,
err = reg_raw_write(codec, reg, val);
if (err == -EAGAIN) {
snd_hdac_power_up_pm(codec);
err = snd_hdac_power_up_pm(codec);
if (!err)
err = reg_raw_write(codec, reg, val);
snd_hdac_power_down_pm(codec);
}
......@@ -442,7 +443,8 @@ int snd_hdac_regmap_read_raw(struct hdac_device *codec, unsigned int reg,
err = reg_raw_read(codec, reg, val);
if (err == -EAGAIN) {
snd_hdac_power_up_pm(codec);
err = snd_hdac_power_up_pm(codec);
if (!err)
err = reg_raw_read(codec, reg, val);
snd_hdac_power_down_pm(codec);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment