From patchwork Wed Jun 10 10:26:05 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Iwai X-Patchwork-Id: 6578451 X-Patchwork-Delegate: tiwai@suse.de Return-Path: X-Original-To: patchwork-alsa-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 638679F326 for ; Wed, 10 Jun 2015 10:26:35 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 95EAB205DC for ; Wed, 10 Jun 2015 10:26:34 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id 3BFD620266 for ; Wed, 10 Jun 2015 10:26:33 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 3EC652659E3; Wed, 10 Jun 2015 12:26:32 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,NO_DNS_FOR_FROM, UNPARSEABLE_RELAY autolearn=no version=3.3.1 Received: from alsa0.perex.cz (localhost [IPv6:::1]) by alsa0.perex.cz (Postfix) with ESMTP id C792F2658F7; Wed, 10 Jun 2015 12:26:24 +0200 (CEST) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id 2670D265963; Wed, 10 Jun 2015 12:26:23 +0200 (CEST) Received: from mx2.suse.de (cantor2.suse.de [195.135.220.15]) by alsa0.perex.cz (Postfix) with ESMTP id 4495E2614D9 for ; Wed, 10 Jun 2015 12:26:07 +0200 (CEST) X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 11452AC8A; Wed, 10 Jun 2015 10:26:07 +0000 (UTC) From: Takashi Iwai To: alsa-devel@alsa-project.org Date: Wed, 10 Jun 2015 12:26:05 +0200 Message-Id: <1433931965-12337-2-git-send-email-tiwai@suse.de> X-Mailer: git-send-email 2.4.3 In-Reply-To: <1433931965-12337-1-git-send-email-tiwai@suse.de> References: <1433931965-12337-1-git-send-email-tiwai@suse.de> Cc: Libin Yang , Mengdong Lin , David Henningsson Subject: [alsa-devel] [PATCH 2/2] ALSA: hda - Allow calling snd_hdac_i915_*() without actual binding X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- 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);