From patchwork Mon Jan 2 20:30:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 13086990 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 663D7C46467 for ; Mon, 2 Jan 2023 20:30:52 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 89A80A8B4; Mon, 2 Jan 2023 21:30:00 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 89A80A8B4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1672691450; bh=XBGxwjOTps8fLgKAqKNuNDLJBvUHEDjGUgWj7WtL0nw=; h=From:To:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: Cc:From; b=ogBdALj02yB42yHKmO5+ac64JPio9Kf5hV9qmrjul5P6JWGLqWpMkT/6G9ex2FK8r zByWc15dD1Jjb2bt7Tl740z9F4fnM4NTE8bL9Dg77TPsPegy6f219zCendx3dLxZrM bVTicMYRvysvmKC0PhnMbPlPrVEbyik0pH3FCRq4= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 33F45F800D0; Mon, 2 Jan 2023 21:30:00 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 8BB42F80507; Mon, 2 Jan 2023 21:29:58 +0100 (CET) Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id B6EB3F800D0 for ; Mon, 2 Jan 2023 21:29:52 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz B6EB3F800D0 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=ADrmyryP DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1672691393; x=1704227393; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=XBGxwjOTps8fLgKAqKNuNDLJBvUHEDjGUgWj7WtL0nw=; b=ADrmyryP5uDQdHa+P+oA+Wq52PpCaonGuZrfjLJxNWXbiHJ5dMC+9mdw 55+z9XXb/Wb3mmhSAUXYkWm0mLrzoaWj4ccBU3VkdmIfChI3ggCxHJi6+ SHG8buR8cIC2xYVUgiNelkfuJdiFZK881t9mI+5lt6dVX0xJx6ld9TpYM xOxTEDpesjSatTy4NLwoBNTpDshaVeHL+WtAAKshjXwT+1ArmeS2pyt5s ds3OOOpFFZlDbMRobqgG2DNVLz4Ss5Oo7Qxy7bJgCTV3KACVqGrGxh9le NhD+ndclm3Pa77LqnZfXZQ/R09h348uWe9Z7O9jcUtnP+6aIVCOX1PKPB g==; X-IronPort-AV: E=McAfee;i="6500,9779,10578"; a="321602407" X-IronPort-AV: E=Sophos;i="5.96,295,1665471600"; d="scan'208";a="321602407" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Jan 2023 12:29:47 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10578"; a="717889959" X-IronPort-AV: E=Sophos;i="5.96,295,1665471600"; d="scan'208";a="717889959" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga008.fm.intel.com with ESMTP; 02 Jan 2023 12:29:44 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id B3ECC84; Mon, 2 Jan 2023 22:30:16 +0200 (EET) From: Andy Shevchenko To: Mark Brown , Vijendar Mukunda , Hans de Goede , Pierre-Louis Bossart , alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org Subject: [PATCH v1 2/6] ASoC: Intel: bytcht_es8316: Drop reference count of ACPI device after use Date: Mon, 2 Jan 2023 22:30:10 +0200 Message-Id: <20230102203014.16041-2-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20230102203014.16041-1-andriy.shevchenko@linux.intel.com> References: <20230102203014.16041-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.29 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: , Cc: Cezary Rojewski , Andy Shevchenko , Kai Vehmanen , Peter Ujfalusi , Takashi Iwai , Liam Girdwood , Ranjani Sridharan , Bard Liao Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" Theoretically the device might gone if its reference count drops to 0. This might be the case when we try to find the first physical node of the ACPI device. We need to keep reference to it until we get a result of the above mentioned call. Refactor the code to drop the reference count at the correct place. While at it, move to acpi_dev_put() as symmetrical call to the acpi_dev_get_first_match_dev(). Fixes: 3c22a73fb873 ("ASoC: Intel: bytcht_es8316: fix HID handling") Signed-off-by: Andy Shevchenko --- sound/soc/intel/boards/bytcht_es8316.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/sound/soc/intel/boards/bytcht_es8316.c b/sound/soc/intel/boards/bytcht_es8316.c index 09d1f0f6d686..df157b01df8b 100644 --- a/sound/soc/intel/boards/bytcht_es8316.c +++ b/sound/soc/intel/boards/bytcht_es8316.c @@ -497,21 +497,28 @@ static int snd_byt_cht_es8316_mc_probe(struct platform_device *pdev) if (adev) { snprintf(codec_name, sizeof(codec_name), "i2c-%s", acpi_dev_name(adev)); - put_device(&adev->dev); byt_cht_es8316_dais[dai_index].codecs->name = codec_name; } else { dev_err(dev, "Error cannot find '%s' dev\n", mach->id); return -ENXIO; } + codec_dev = acpi_get_first_physical_node(adev); + acpi_dev_put(adev); + if (!codec_dev) + return -EPROBE_DEFER; + priv->codec_dev = get_device(codec_dev); + /* override platform name, if required */ byt_cht_es8316_card.dev = dev; platform_name = mach->mach_params.platform; ret = snd_soc_fixup_dai_links_platform_name(&byt_cht_es8316_card, platform_name); - if (ret) + if (ret) { + put_device(codec_dev); return ret; + } /* Check for BYTCR or other platform and setup quirks */ dmi_id = dmi_first_match(byt_cht_es8316_quirk_table); @@ -539,13 +546,10 @@ static int snd_byt_cht_es8316_mc_probe(struct platform_device *pdev) /* get the clock */ priv->mclk = devm_clk_get(dev, "pmc_plt_clk_3"); - if (IS_ERR(priv->mclk)) + if (IS_ERR(priv->mclk)) { + put_device(codec_dev); return dev_err_probe(dev, PTR_ERR(priv->mclk), "clk_get pmc_plt_clk_3 failed\n"); - - codec_dev = acpi_get_first_physical_node(adev); - if (!codec_dev) - return -EPROBE_DEFER; - priv->codec_dev = get_device(codec_dev); + } if (quirk & BYT_CHT_ES8316_JD_INVERTED) props[cnt++] = PROPERTY_ENTRY_BOOL("everest,jack-detect-inverted");