From 1d3ff20c7fbc52cd57b65248c85734d85c4ccdac Mon Sep 17 00:00:00 2001 From: Imre Deak Date: Sat, 19 Mar 2016 23:51:06 +0200 Subject: [PATCH 2/2] sound/hda: Silently fail if the i915 audio component is disabled Signed-off-by: Imre Deak --- sound/hda/hdac_i915.c | 34 +++++++++++++++++++++++++++++++--- 1 files changed, 31 insertions(+), 3 deletions(-) diff --git a/sound/hda/hdac_i915.c b/sound/hda/hdac_i915.c index fb96aea..ffe545f 100644 --- a/sound/hda/hdac_i915.c +++ b/sound/hda/hdac_i915.c @@ -43,6 +43,9 @@ int snd_hdac_set_codec_wakeup(struct hdac_bus *bus, bool enable) if (!acomp || !acomp->ops) return -ENODEV; + if (acomp->ops->disabled) + return 0; + if (!acomp->ops->codec_wake_override) { dev_warn(bus->dev, "Invalid codec wake callback\n"); @@ -81,6 +84,9 @@ int snd_hdac_display_power(struct hdac_bus *bus, bool enable) dev_dbg(bus->dev, "display power %s\n", enable ? "enable" : "disable"); + if (acomp->ops->disabled) + return 0; + if (enable) { if (!bus->i915_power_refcount++) { acomp->ops->get_power(acomp->dev); @@ -114,6 +120,9 @@ int snd_hdac_get_display_clk(struct hdac_bus *bus) if (!acomp || !acomp->ops) return -ENODEV; + if (acomp->ops->disabled) + return 0; + return acomp->ops->get_cdclk_freq(acomp->dev); } EXPORT_SYMBOL_GPL(snd_hdac_get_display_clk); @@ -148,8 +157,15 @@ int snd_hdac_sync_audio_rate(struct hdac_bus *bus, hda_nid_t nid, int rate) struct i915_audio_component *acomp = bus->audio_component; int port; - if (!acomp || !acomp->ops || !acomp->ops->sync_audio_rate) + if (!acomp || !acomp->ops) + return -ENODEV; + + if (acomp->ops->disabled) + return 0; + + if (!acomp->ops->sync_audio_rate) return -ENODEV; + port = pin2port(nid); if (port < 0) return -EINVAL; @@ -186,6 +202,12 @@ int snd_hdac_acomp_get_eld(struct hdac_bus *bus, hda_nid_t nid, if (!acomp || !acomp->ops || !acomp->ops->get_eld) return -ENODEV; + if (acomp->ops->disabled) + return 0; + + if (!acomp->ops->get_eld) + return -ENODEV; + port = pin2port(nid); if (port < 0) return -EINVAL; @@ -203,8 +225,14 @@ static int hdac_component_master_bind(struct device *dev) if (ret < 0) return ret; - if (WARN_ON(!(acomp->dev && acomp->ops && acomp->ops->get_power && - acomp->ops->put_power && acomp->ops->get_cdclk_freq))) { + if (WARN_ON(!(acomp->dev && acomp->ops))) { + ret = -EINVAL; + goto out_unbind; + } + + if (WARN_ON(!acomp->ops->disabled && + !(acomp->ops->get_power && acomp->ops->put_power && + acomp->ops->get_cdclk_freq))) { ret = -EINVAL; goto out_unbind; } -- 1.7.0.2