Alsa-Devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Takashi Iwai <tiwai@suse.de>
To: alsa-devel@alsa-project.org
Cc: Libin Yang <libin.yang@intel.com>,
	Mengdong Lin <mengdong.lin@intel.com>,
	David Henningsson <david.henningsson@canonical.com>
Subject: [PATCH 2/2] ALSA: hda - Allow calling snd_hdac_i915_*() without actual binding
Date: Wed, 10 Jun 2015 12:26:05 +0200	[thread overview]
Message-ID: <1433931965-12337-2-git-send-email-tiwai@suse.de> (raw)
In-Reply-To: <1433931965-12337-1-git-send-email-tiwai@suse.de>

Add the missing NULL checks so that snd_hdac_i915*() can be called
even after the binding with i915 failed.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
This is only for 4.2 (for-next branch).

 sound/hda/hdac_i915.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/sound/hda/hdac_i915.c b/sound/hda/hdac_i915.c
index cb78c25585ac..442500e06b7c 100644
--- a/sound/hda/hdac_i915.c
+++ b/sound/hda/hdac_i915.c
@@ -27,7 +27,7 @@ int snd_hdac_set_codec_wakeup(struct hdac_bus *bus, bool enable)
 {
 	struct i915_audio_component *acomp = bus->audio_component;
 
-	if (!acomp->ops)
+	if (!acomp || !acomp->ops)
 		return -ENODEV;
 
 	if (!acomp->ops->codec_wake_override) {
@@ -49,7 +49,7 @@ int snd_hdac_display_power(struct hdac_bus *bus, bool enable)
 {
 	struct i915_audio_component *acomp = bus->audio_component;
 
-	if (!acomp->ops)
+	if (!acomp || !acomp->ops)
 		return -ENODEV;
 
 	dev_dbg(bus->dev, "display power %s\n",
@@ -72,7 +72,7 @@ int snd_hdac_get_display_clk(struct hdac_bus *bus)
 {
 	struct i915_audio_component *acomp = bus->audio_component;
 
-	if (!acomp->ops)
+	if (!acomp || !acomp->ops)
 		return -ENODEV;
 
 	return acomp->ops->get_cdclk_freq(acomp->dev);
@@ -179,8 +179,11 @@ int snd_hdac_i915_exit(struct hdac_bus *bus)
 	struct device *dev = bus->dev;
 	struct i915_audio_component *acomp = bus->audio_component;
 
+	if (!acomp)
+		return 0;
+
 	WARN_ON(bus->i915_power_refcount);
-	if (bus->i915_power_refcount > 0 && acomp && acomp->ops)
+	if (bus->i915_power_refcount > 0 && acomp->ops)
 		acomp->ops->put_power(acomp->dev);
 
 	component_master_del(dev, &hdac_component_master_ops);
-- 
2.4.3

  reply	other threads:[~2015-06-10 10:26 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-10 10:26 [PATCH 1/2] ALSA: hda - Continue probing even if i915 binding fails Takashi Iwai
2015-06-10 10:26 ` Takashi Iwai [this message]
2015-06-12  2:08 ` Lin, Mengdong
2015-06-12  5:08   ` Takashi Iwai
2015-06-12  5:50     ` Lin, Mengdong
2015-06-12  6:06       ` Takashi Iwai
2015-06-12  6:17         ` David Henningsson
2015-06-12  6:37           ` Takashi Iwai
2015-06-12 14:14             ` Takashi Iwai
2015-06-12 14:33               ` David Henningsson
2015-06-12 14:36                 ` Takashi Iwai
2015-06-12  6:51           ` Lin, Mengdong

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1433931965-12337-2-git-send-email-tiwai@suse.de \
    --to=tiwai@suse.de \
    --cc=alsa-devel@alsa-project.org \
    --cc=david.henningsson@canonical.com \
    --cc=libin.yang@intel.com \
    --cc=mengdong.lin@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox