From patchwork Thu Jan 12 11:28:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 13097863 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 CA500C54EBC for ; Thu, 12 Jan 2023 11:30:43 +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 A8CB88B5C; Thu, 12 Jan 2023 12:29:50 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz A8CB88B5C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1673523040; bh=C4Q7t6S4036xeiDu5xxCUyx970NCpXYQ7LpyZ8TZ13k=; h=From:To:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: Cc:From; b=H+FlZvmxgSwRrA9einT/S/cKzOGIT2cJyH8UD31RepbIEh078U6aOlwBnlIzYyX4d LZi0xtt3YuBjqbWtG9CAH/VSW61TdafpozzED9I7yIw9hZcKgAwbL6TlD6GR8xKK9N 0pYAxtxkK0agQPl6+II6upwUFAgm8gVdy/zN2RfM= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id D5A37F80558; Thu, 12 Jan 2023 12:28:45 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id BE8CCF80553; Thu, 12 Jan 2023 12:28:43 +0100 (CET) Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) (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 98F0EF8013D for ; Thu, 12 Jan 2023 12:28:38 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 98F0EF8013D 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=NDwyEPaU DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1673522920; x=1705058920; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=C4Q7t6S4036xeiDu5xxCUyx970NCpXYQ7LpyZ8TZ13k=; b=NDwyEPaUH5bgK682RlfTWGiw8kz6oFTDYIyT4h4eK2Zya8atRUFOxc9K RfU8r52zOEkZAPXFgxNMMod3mrJotWZZ6Gmn+AEz4GIb9AHfrCICNomfu tONGfPf1OUgrV4lm4uZgOmLd8tNDTnoFRQgBFtq03U65pIGB62tpgVB+K YJNFv0FkQw7ufYjIP2Io9X/+lKuKDCAPMCrLRYcdVc/wYcDwaWGOPfAag L1uGGaH3UMAQIa43tfLdHQ+6PuK9ajIkBelUQ8egXdS/8MTZF9rrOMsAt Hrgu1tJls1jDc9mmFzKCtddwqqUwfHlHtgslUqrKnqT7mHzlyydvsppvs g==; X-IronPort-AV: E=McAfee;i="6500,9779,10586"; a="385994949" X-IronPort-AV: E=Sophos;i="5.96,319,1665471600"; d="scan'208";a="385994949" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Jan 2023 03:28:27 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10586"; a="986519418" X-IronPort-AV: E=Sophos;i="5.96,319,1665471600"; d="scan'208";a="986519418" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga005.fm.intel.com with ESMTP; 12 Jan 2023 03:28:22 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id 72458E1; Thu, 12 Jan 2023 13:28:56 +0200 (EET) From: Andy Shevchenko To: Mark Brown , Hans de Goede , Pierre-Louis Bossart , alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 1/5] ASoC: Intel: bytcht_es8316: Drop reference count of ACPI device after use Date: Thu, 12 Jan 2023 13:28:48 +0200 Message-Id: <20230112112852.67714-2-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230112112852.67714-1-andriy.shevchenko@linux.intel.com> References: <20230112112852.67714-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 , Kai Vehmanen , Peter Ujfalusi , Takashi Iwai , Ranjani Sridharan , Liam Girdwood , Andy Shevchenko , 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"); From patchwork Thu Jan 12 11:28:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 13097860 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 43A72C54EBC for ; Thu, 12 Jan 2023 11:30:05 +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 1CFA28B1E; Thu, 12 Jan 2023 12:29:12 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 1CFA28B1E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1673523002; bh=vjV8y8LbzUXQrt45Puugictbqi3QHzP5bvn2L0BGWt0=; h=From:To:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: Cc:From; b=EJUBg0q89SB1CTayPti74N8WFWxi0Kxvs9MzeKCD4LTcuF8yLC/3zEvjdx8W+q4Vf Z+Fe4KUcyZIe2BMqDfa1g4JlNijvAhIoEgspZu96EZZCDd4JktNPht1SdQIC7OKDRN h91uy7+EgfT71eXkVxj5ukOQF+sGk+dNy6+NK9KU= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 28989F8053A; Thu, 12 Jan 2023 12:28:42 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 03175F804BD; Thu, 12 Jan 2023 12:28:37 +0100 (CET) Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) (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 1B242F804BD for ; Thu, 12 Jan 2023 12:28:33 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 1B242F804BD 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=lukPGu8c DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1673522915; x=1705058915; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=vjV8y8LbzUXQrt45Puugictbqi3QHzP5bvn2L0BGWt0=; b=lukPGu8cTVRrou3Iz7wtVw8HKZxba3w1ypRRZFIefXV5e8Ri0yr4q1kO GJ5+X4ZcAqNX7uo6u+HMSx6Riw1kn1Pe1LSWUOshwymDzWcyc86Eo2fCL r0rYGZNDVGyKNCWgA0I2pQIttezhHcgRPXaf+v8nODL9krfkKH7B3kvVD 2PA6YovXLjtQl1umufAfUDUlwH63gr/UIe1QKD/3poFwMvE44YAo6x4kV A5lVZAQ9LJe4w+xYB4osFj6NPNv2jIcE8l8fLBIv1fhu8odS4Mwbk5g9I HWFv4HyOOoHjn2zrmUFUjvSOTcO2PnrkXH78F6X+zDDbv6oqp55JRYdZv g==; X-IronPort-AV: E=McAfee;i="6500,9779,10586"; a="385994938" X-IronPort-AV: E=Sophos;i="5.96,319,1665471600"; d="scan'208";a="385994938" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Jan 2023 03:28:27 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10586"; a="986519423" X-IronPort-AV: E=Sophos;i="5.96,319,1665471600"; d="scan'208";a="986519423" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga005.fm.intel.com with ESMTP; 12 Jan 2023 03:28:22 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id 7C04B14B; Thu, 12 Jan 2023 13:28:56 +0200 (EET) From: Andy Shevchenko To: Mark Brown , Hans de Goede , Pierre-Louis Bossart , alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 2/5] ASoC: Intel: bytcr_rt5651: Drop reference count of ACPI device after use Date: Thu, 12 Jan 2023 13:28:49 +0200 Message-Id: <20230112112852.67714-3-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230112112852.67714-1-andriy.shevchenko@linux.intel.com> References: <20230112112852.67714-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 , Kai Vehmanen , Peter Ujfalusi , Takashi Iwai , Ranjani Sridharan , Liam Girdwood , Andy Shevchenko , 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: 02c0a3b3047f ("ASoC: Intel: bytcr_rt5651: add MCLK, quirks and cleanups") Signed-off-by: Andy Shevchenko --- sound/soc/intel/boards/bytcr_rt5651.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/soc/intel/boards/bytcr_rt5651.c b/sound/soc/intel/boards/bytcr_rt5651.c index 81ac6eeda2e6..8fca9b82d4d0 100644 --- a/sound/soc/intel/boards/bytcr_rt5651.c +++ b/sound/soc/intel/boards/bytcr_rt5651.c @@ -922,7 +922,6 @@ static int snd_byt_rt5651_mc_probe(struct platform_device *pdev) if (adev) { snprintf(byt_rt5651_codec_name, sizeof(byt_rt5651_codec_name), "i2c-%s", acpi_dev_name(adev)); - put_device(&adev->dev); byt_rt5651_dais[dai_index].codecs->name = byt_rt5651_codec_name; } else { dev_err(dev, "Error cannot find '%s' dev\n", mach->id); @@ -930,6 +929,7 @@ static int snd_byt_rt5651_mc_probe(struct platform_device *pdev) } 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); From patchwork Thu Jan 12 11:28:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 13097861 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 05621C54EBC for ; Thu, 12 Jan 2023 11:30:08 +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 4E6258B45; Thu, 12 Jan 2023 12:29:16 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 4E6258B45 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1673523006; bh=BrwpZf0Qi8AA+i94wAgY34Wsc5QpYESR4OVN/jMXpfw=; h=From:To:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: Cc:From; b=XcPhjR8BAtURoB+1kqp9j1qRwru9fOufCqfyqNt2Fqlv0pZw1o4pW8NILs1rA59sX EldInyuomK/i9Av5pJ/EC3bV5a9RRjXTZuxtndLWf+3EDxs+5UJohntqpLbz397GrE HQ//E5THs2QnKgHl8CPTruywbVAUuI+g79sKTBo4= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id A3BE8F80548; Thu, 12 Jan 2023 12:28:42 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id E8B7AF8053D; Thu, 12 Jan 2023 12:28:39 +0100 (CET) Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) (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 30741F8013D for ; Thu, 12 Jan 2023 12:28:36 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 30741F8013D 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=IvztGuGo DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1673522918; x=1705058918; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=BrwpZf0Qi8AA+i94wAgY34Wsc5QpYESR4OVN/jMXpfw=; b=IvztGuGowjd815PScTcuw7+zRwS6fSyaRL67sSR5fbryX3i1megILAen I7hQIpiBELnwuXbykN3rIy2lzfmydcv80UEUnhId36iKZ3A1rfXVwDA8/ C4ctjCTeV+pMd5EXWF64bMTmV1RgdTRBiD+X4inuiV3hFpyPQn4qhVhDK t2fUCL6d3YntC+fOIdaKvMrSHCnAvdHvHEmSIian1/IhoENGomK9JZ68r 4SvDBqJ5h562bJ7bDgWc0rh0xdjC1Ligz4ESXPY/+g5xYt3iLXwpmr1KD CCBf5pP/JRmOi/M2JAF5AxW5hYc+GgTpMqXaOJWmPYYHXMwXprkOiQALU w==; X-IronPort-AV: E=McAfee;i="6500,9779,10586"; a="385994944" X-IronPort-AV: E=Sophos;i="5.96,319,1665471600"; d="scan'208";a="385994944" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Jan 2023 03:28:27 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10586"; a="986519424" X-IronPort-AV: E=Sophos;i="5.96,319,1665471600"; d="scan'208";a="986519424" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga005.fm.intel.com with ESMTP; 12 Jan 2023 03:28:22 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id 8AF4831D; Thu, 12 Jan 2023 13:28:56 +0200 (EET) From: Andy Shevchenko To: Mark Brown , Hans de Goede , Pierre-Louis Bossart , alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 3/5] ASoC: Intel: bytcr_rt5640: Drop reference count of ACPI device after use Date: Thu, 12 Jan 2023 13:28:50 +0200 Message-Id: <20230112112852.67714-4-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230112112852.67714-1-andriy.shevchenko@linux.intel.com> References: <20230112112852.67714-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 , Kai Vehmanen , Peter Ujfalusi , Takashi Iwai , Ranjani Sridharan , Liam Girdwood , Andy Shevchenko , 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: a232b96dcece ("ASoC: Intel: bytcr_rt5640: use HID translation util") Signed-off-by: Andy Shevchenko --- sound/soc/intel/boards/bytcr_rt5640.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/sound/soc/intel/boards/bytcr_rt5640.c b/sound/soc/intel/boards/bytcr_rt5640.c index 4699ca79f3ea..79e0039c79a3 100644 --- a/sound/soc/intel/boards/bytcr_rt5640.c +++ b/sound/soc/intel/boards/bytcr_rt5640.c @@ -1636,13 +1636,18 @@ static int snd_byt_rt5640_mc_probe(struct platform_device *pdev) if (adev) { snprintf(byt_rt5640_codec_name, sizeof(byt_rt5640_codec_name), "i2c-%s", acpi_dev_name(adev)); - put_device(&adev->dev); byt_rt5640_dais[dai_index].codecs->name = byt_rt5640_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); + /* * swap SSP0 if bytcr is detected * (will be overridden if DMI quirk is detected) @@ -1717,11 +1722,6 @@ static int snd_byt_rt5640_mc_probe(struct platform_device *pdev) byt_rt5640_quirk = quirk_override; } - codec_dev = acpi_get_first_physical_node(adev); - if (!codec_dev) - return -EPROBE_DEFER; - priv->codec_dev = get_device(codec_dev); - if (byt_rt5640_quirk & BYT_RT5640_JD_HP_ELITEP_1000G2) { acpi_dev_add_driver_gpios(ACPI_COMPANION(priv->codec_dev), byt_rt5640_hp_elitepad_1000g2_gpios); From patchwork Thu Jan 12 11:28:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 13097862 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 D1957C54EBC for ; Thu, 12 Jan 2023 11:30:23 +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 E002D8B44; Thu, 12 Jan 2023 12:29:30 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz E002D8B44 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1673523020; bh=9CUFrPQ09yPzbbj4IV4mmL6zJucv2gUZLtx+M2adKnU=; h=From:To:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: Cc:From; b=suQ5KVlN2DzUI33Bo6I8aEUB9pyOwWwA22MHZc3p9J8Me+ZGmVE0d/QHW+Kys/OtP +SXTHp8rqvimePwjzjguqyb8+ODE8AUBiX5L7cYyDyKWS88/FP8U8nBCC7YTMbi4sO 9aAp5+Wi+w4vyg+OoztkNSUMxaYbOv7Nrc0/aDnY= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 48A28F80552; Thu, 12 Jan 2023 12:28:45 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id ECBB8F8053D; Thu, 12 Jan 2023 12:28:41 +0100 (CET) Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) (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 5DA81F804CA for ; Thu, 12 Jan 2023 12:28:39 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 5DA81F804CA 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=EmxMTEDf DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1673522920; x=1705058920; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=9CUFrPQ09yPzbbj4IV4mmL6zJucv2gUZLtx+M2adKnU=; b=EmxMTEDf8VyMl6zJuu/iWrjvoG4390c8Xssk9iLziyl8R1xeZyniQLw/ f4Iy3g4dF3qmWdrAli1b1k/F5Vht8Rf8wanUQ9dWbeSc24c19TU5v2hsd 0dP0t7TojZdjr7KfB6k0FzJd/RPgfaoVPg9qc0EqudnxWc2PiZqwGARC5 HDpMhm6aNOqp3+nGHAyydwv+fnJj2P7A6s1WKkpHRpHj/NCVQKABdcUK4 aLEyMxhLlKs/zI3fN6xptTYVcarwyhymbYQT9FjN6y3chFHM9SYO8PdEK 2AFxjK+UhPY0XEMiJCsvUZKgwBHo1HL0gIlN0xANmdmAnuEmg9y1guZGP g==; X-IronPort-AV: E=McAfee;i="6500,9779,10586"; a="385994956" X-IronPort-AV: E=Sophos;i="5.96,319,1665471600"; d="scan'208";a="385994956" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Jan 2023 03:28:27 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10586"; a="986519420" X-IronPort-AV: E=Sophos;i="5.96,319,1665471600"; d="scan'208";a="986519420" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga005.fm.intel.com with ESMTP; 12 Jan 2023 03:28:22 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id 95AFE330; Thu, 12 Jan 2023 13:28:56 +0200 (EET) From: Andy Shevchenko To: Mark Brown , Hans de Goede , Pierre-Louis Bossart , alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 4/5] ASoC: Intel: bytcr_wm5102: Drop reference count of ACPI device after use Date: Thu, 12 Jan 2023 13:28:51 +0200 Message-Id: <20230112112852.67714-5-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230112112852.67714-1-andriy.shevchenko@linux.intel.com> References: <20230112112852.67714-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 , Kai Vehmanen , Peter Ujfalusi , Takashi Iwai , Ranjani Sridharan , Liam Girdwood , Andy Shevchenko , 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: 9a87fc1e0619 ("ASoC: Intel: bytcr_wm5102: Add machine driver for BYT/WM5102") Signed-off-by: Andy Shevchenko --- sound/soc/intel/boards/bytcr_wm5102.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/soc/intel/boards/bytcr_wm5102.c b/sound/soc/intel/boards/bytcr_wm5102.c index 1669eb3bd80f..c0706537f673 100644 --- a/sound/soc/intel/boards/bytcr_wm5102.c +++ b/sound/soc/intel/boards/bytcr_wm5102.c @@ -411,9 +411,9 @@ static int snd_byt_wm5102_mc_probe(struct platform_device *pdev) return -ENOENT; } snprintf(codec_name, sizeof(codec_name), "spi-%s", acpi_dev_name(adev)); - put_device(&adev->dev); codec_dev = bus_find_device_by_name(&spi_bus_type, NULL, codec_name); + acpi_dev_put(adev); if (!codec_dev) return -EPROBE_DEFER; From patchwork Thu Jan 12 11:28:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 13097859 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 68640C54EBC for ; Thu, 12 Jan 2023 11:29:32 +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 EFB8F8B2A; Thu, 12 Jan 2023 12:28:38 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz EFB8F8B2A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1673522969; bh=jhd+WRzaHqmWRkPNRNir7nTbOsn0RTp6sg9bQRKKJuM=; h=From:To:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: Cc:From; b=oezjSYd2PNy5CN7jr2gtT7Sa7N4gJeT9N1oYBoILUC1WhKJMfgdGuHXG/8zVgu1Yw Mpe9Ei1NemqPWz7cK2oUo4+70ZmO8zz7eGB37z+wYvVmi+E2Q4DGwnVNgjEEDSZrNh PMIPnmBfyDxQ/MbjHDy9Z4giq7pJ5TJfY8U1PTEs= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 2FFA7F8016E; Thu, 12 Jan 2023 12:28:38 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 9B598F804CA; Thu, 12 Jan 2023 12:28:36 +0100 (CET) Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) (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 139E1F8013D for ; Thu, 12 Jan 2023 12:28:32 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 139E1F8013D 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=aLPR8Zqn DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1673522914; x=1705058914; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=jhd+WRzaHqmWRkPNRNir7nTbOsn0RTp6sg9bQRKKJuM=; b=aLPR8ZqnHDIyeS2aN8+DLZ/G1AQBdinEzHI9GMV5cyPcW/mo/mGHm+rV iWDOmK7EEgiVrx/fTk1n1edPKbQiV3ZSNXqzuBMDRVeJapUXHXnjTEUxn 2iNgwbvvTDXR1ElHhP3Wpr/Rg24k4mQwFA0SGgSkya34Vi+LmrS+6d3T5 h1qoHYSMuu3qiogEJ6n85A7tfwfZj9/DKlCw/1xHY02wL4W8jIc8ja+4P 8tZvIo8YottvoQak3x6m3hc5TIaWIrfkQYjs8zaj3oy5ESu9X5iTcbQ1w BQm2afC5sfRpeTJLiw+v5W1ezg9jRb1LyJB7dvtbVq2LBLyAkQ0HvF+2v g==; X-IronPort-AV: E=McAfee;i="6500,9779,10586"; a="304058542" X-IronPort-AV: E=Sophos;i="5.96,319,1665471600"; d="scan'208";a="304058542" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Jan 2023 03:28:30 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10586"; a="903164798" X-IronPort-AV: E=Sophos;i="5.96,319,1665471600"; d="scan'208";a="903164798" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga006.fm.intel.com with ESMTP; 12 Jan 2023 03:28:27 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id A03854E3; Thu, 12 Jan 2023 13:28:56 +0200 (EET) From: Andy Shevchenko To: Mark Brown , Hans de Goede , Pierre-Louis Bossart , alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 5/5] ASoC: Intel: sof_es8336: Drop reference count of ACPI device after use Date: Thu, 12 Jan 2023 13:28:52 +0200 Message-Id: <20230112112852.67714-6-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230112112852.67714-1-andriy.shevchenko@linux.intel.com> References: <20230112112852.67714-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 , Kai Vehmanen , Peter Ujfalusi , Takashi Iwai , Ranjani Sridharan , Liam Girdwood , Andy Shevchenko , 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: a164137ce91a ("ASoC: Intel: add machine driver for SOF+ES8336") Signed-off-by: Andy Shevchenko --- sound/soc/intel/boards/sof_es8336.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/sound/soc/intel/boards/sof_es8336.c b/sound/soc/intel/boards/sof_es8336.c index 773e5d1d87d4..894b6610b9e2 100644 --- a/sound/soc/intel/boards/sof_es8336.c +++ b/sound/soc/intel/boards/sof_es8336.c @@ -681,7 +681,6 @@ static int sof_es8336_probe(struct platform_device *pdev) if (adev) { snprintf(codec_name, sizeof(codec_name), "i2c-%s", acpi_dev_name(adev)); - put_device(&adev->dev); dai_links[0].codecs->name = codec_name; /* also fixup codec dai name if relevant */ @@ -692,16 +691,19 @@ static int sof_es8336_probe(struct platform_device *pdev) return -ENXIO; } - ret = snd_soc_fixup_dai_links_platform_name(&sof_es8336_card, - mach->mach_params.platform); - if (ret) - return ret; - 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); + ret = snd_soc_fixup_dai_links_platform_name(&sof_es8336_card, + mach->mach_params.platform); + if (ret) { + put_device(codec_dev); + return ret; + } + if (quirk & SOF_ES8336_JD_INVERTED) props[cnt++] = PROPERTY_ENTRY_BOOL("everest,jack-detect-inverted");