From patchwork Fri Aug 13 15:11:09 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierre-Louis Bossart X-Patchwork-Id: 497112 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 775F4C4320A for ; Fri, 13 Aug 2021 15:13:24 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 5C17A61186 for ; Fri, 13 Aug 2021 15:13:23 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 5C17A61186 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.intel.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 1F2701877; Fri, 13 Aug 2021 17:12:31 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 1F2701877 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1628867601; bh=FUuCZ8Q0URZNdZL9qrZQEawsTtV2tXbXDTmatC+Maq0=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=resJLmAA5eVF/Ikuy6vQ78FpSCqufTrePUU0haKoHD33dabnQD/U/N75WwavRcLwq qnA80Tjw4PR9ohviRhK0Zrg1mMOxWXszfDBaakNWgLLevYit2mFdwB1aQoeNoF5YcW 8ivIQSvqNm1VZjw3fBVj0HrEFfErKcnZBDjI13c0= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 9601DF802D2; Fri, 13 Aug 2021 17:11:44 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id D1F13F804E4; Fri, 13 Aug 2021 17:11:41 +0200 (CEST) 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 F16B9F8020D for ; Fri, 13 Aug 2021 17:11:33 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz F16B9F8020D X-IronPort-AV: E=McAfee;i="6200,9189,10075"; a="215301875" X-IronPort-AV: E=Sophos;i="5.84,319,1620716400"; d="scan'208";a="215301875" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Aug 2021 08:11:28 -0700 X-IronPort-AV: E=Sophos;i="5.84,319,1620716400"; d="scan'208";a="422888857" Received: from mchatter-mobl1.amr.corp.intel.com (HELO pbossart-mobl3.intel.com) ([10.212.54.162]) by orsmga003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Aug 2021 08:11:27 -0700 From: Pierre-Louis Bossart To: alsa-devel@alsa-project.org Subject: [PATCH v3 1/8] ASoC: Intel: boards: harden codec property handling Date: Fri, 13 Aug 2021 10:11:09 -0500 Message-Id: <20210813151116.23931-2-pierre-louis.bossart@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210813151116.23931-1-pierre-louis.bossart@linux.intel.com> References: <20210813151116.23931-1-pierre-louis.bossart@linux.intel.com> MIME-Version: 1.0 Cc: Heikki Krogerus , tiwai@suse.de, Pierre-Louis Bossart , Hans de Goede , broonie@kernel.org, Andy Shevchenko X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 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: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" In current ACPI-based devices, the DSDT does not include any of the properties required by the codec driver. This is not an ACPI limitation proper since the _DSD method could be used, as done for Camera and SoundWire in newer platforms. For legacy devices, there is unfortunately no other option than using a work-around: we add properties to the codec device from the machine driver. To avoid any issues with the codec driver being unbound, we need to keep a reference to the codec device until the card is removed. Reviewed-by: Andy Shevchenko Co-developed-by: Hans de Goede Signed-off-by: Hans de Goede Signed-off-by: Pierre-Louis Bossart --- sound/soc/intel/boards/bytcht_es8316.c | 12 +++++-- sound/soc/intel/boards/bytcr_rt5640.c | 47 +++++++++++++++++--------- sound/soc/intel/boards/bytcr_rt5651.c | 37 +++++++++++++------- 3 files changed, 64 insertions(+), 32 deletions(-) diff --git a/sound/soc/intel/boards/bytcht_es8316.c b/sound/soc/intel/boards/bytcht_es8316.c index a0af91580184..893dd74adb94 100644 --- a/sound/soc/intel/boards/bytcht_es8316.c +++ b/sound/soc/intel/boards/bytcht_es8316.c @@ -37,6 +37,7 @@ struct byt_cht_es8316_private { struct clk *mclk; struct snd_soc_jack jack; struct gpio_desc *speaker_en_gpio; + struct device *codec_dev; bool speaker_en; }; @@ -555,7 +556,7 @@ static int snd_byt_cht_es8316_mc_probe(struct platform_device *pdev) gpiod_get_index(codec_dev, "speaker-enable", 0, /* see comment in byt_cht_es8316_resume */ GPIOD_OUT_LOW | GPIOD_FLAGS_BIT_NONEXCLUSIVE); - put_device(codec_dev); + priv->codec_dev = codec_dev; if (IS_ERR(priv->speaker_en_gpio)) { ret = PTR_ERR(priv->speaker_en_gpio); @@ -567,7 +568,7 @@ static int snd_byt_cht_es8316_mc_probe(struct platform_device *pdev) dev_err(dev, "get speaker GPIO failed: %d\n", ret); fallthrough; case -EPROBE_DEFER: - return ret; + goto err_put_codec; } } @@ -605,10 +606,14 @@ static int snd_byt_cht_es8316_mc_probe(struct platform_device *pdev) if (ret) { gpiod_put(priv->speaker_en_gpio); dev_err(dev, "snd_soc_register_card failed: %d\n", ret); - return ret; + goto err_put_codec; } platform_set_drvdata(pdev, &byt_cht_es8316_card); return 0; + +err_put_codec: + put_device(priv->codec_dev); + return ret; } static int snd_byt_cht_es8316_mc_remove(struct platform_device *pdev) @@ -617,6 +622,7 @@ static int snd_byt_cht_es8316_mc_remove(struct platform_device *pdev) struct byt_cht_es8316_private *priv = snd_soc_card_get_drvdata(card); gpiod_put(priv->speaker_en_gpio); + put_device(priv->codec_dev); return 0; } diff --git a/sound/soc/intel/boards/bytcr_rt5640.c b/sound/soc/intel/boards/bytcr_rt5640.c index d51bd22073df..b25ca99d9855 100644 --- a/sound/soc/intel/boards/bytcr_rt5640.c +++ b/sound/soc/intel/boards/bytcr_rt5640.c @@ -90,6 +90,7 @@ enum { struct byt_rt5640_private { struct snd_soc_jack jack; struct clk *mclk; + struct device *codec_dev; }; static bool is_bytcr; @@ -969,15 +970,11 @@ static const struct dmi_system_id byt_rt5640_quirk_table[] = { * Note this MUST be called before snd_soc_register_card(), so that the props * are in place before the codec component driver's probe function parses them. */ -static int byt_rt5640_add_codec_device_props(const char *i2c_dev_name) +static int byt_rt5640_add_codec_device_props(struct device *i2c_dev, + struct byt_rt5640_private *priv) { struct property_entry props[MAX_NO_PROPS] = {}; - struct device *i2c_dev; - int ret, cnt = 0; - - i2c_dev = bus_find_device_by_name(&i2c_bus_type, NULL, i2c_dev_name); - if (!i2c_dev) - return -EPROBE_DEFER; + int cnt = 0; switch (BYT_RT5640_MAP(byt_rt5640_quirk)) { case BYT_RT5640_DMIC1_MAP: @@ -1017,10 +1014,7 @@ static int byt_rt5640_add_codec_device_props(const char *i2c_dev_name) if (byt_rt5640_quirk & BYT_RT5640_JD_NOT_INV) props[cnt++] = PROPERTY_ENTRY_BOOL("realtek,jack-detect-not-inverted"); - ret = device_add_properties(i2c_dev, props); - put_device(i2c_dev); - - return ret; + return device_add_properties(i2c_dev, props); } static int byt_rt5640_init(struct snd_soc_pcm_runtime *runtime) @@ -1367,6 +1361,7 @@ static int snd_byt_rt5640_mc_probe(struct platform_device *pdev) struct snd_soc_acpi_mach *mach; const char *platform_name; struct acpi_device *adev; + struct device *codec_dev; bool sof_parent; int ret_val = 0; int dai_index = 0; @@ -1475,10 +1470,16 @@ static int snd_byt_rt5640_mc_probe(struct platform_device *pdev) byt_rt5640_quirk = quirk_override; } + codec_dev = bus_find_device_by_name(&i2c_bus_type, NULL, byt_rt5640_codec_name); + if (!codec_dev) + return -EPROBE_DEFER; + + priv->codec_dev = codec_dev; + /* Must be called before register_card, also see declaration comment. */ - ret_val = byt_rt5640_add_codec_device_props(byt_rt5640_codec_name); + ret_val = byt_rt5640_add_codec_device_props(codec_dev, priv); if (ret_val) - return ret_val; + goto err; log_quirks(&pdev->dev); @@ -1509,7 +1510,7 @@ static int snd_byt_rt5640_mc_probe(struct platform_device *pdev) * for all other errors, including -EPROBE_DEFER */ if (ret_val != -ENOENT) - return ret_val; + goto err; byt_rt5640_quirk &= ~BYT_RT5640_MCLK_EN; } } @@ -1553,7 +1554,7 @@ static int snd_byt_rt5640_mc_probe(struct platform_device *pdev) ret_val = snd_soc_fixup_dai_links_platform_name(&byt_rt5640_card, platform_name); if (ret_val) - return ret_val; + goto err; sof_parent = snd_soc_acpi_sof_parent(&pdev->dev); @@ -1575,10 +1576,23 @@ static int snd_byt_rt5640_mc_probe(struct platform_device *pdev) if (ret_val) { dev_err(&pdev->dev, "devm_snd_soc_register_card failed %d\n", ret_val); - return ret_val; + goto err; } platform_set_drvdata(pdev, &byt_rt5640_card); return ret_val; + +err: + put_device(priv->codec_dev); + return ret_val; +} + +static int snd_byt_rt5640_mc_remove(struct platform_device *pdev) +{ + struct snd_soc_card *card = platform_get_drvdata(pdev); + struct byt_rt5640_private *priv = snd_soc_card_get_drvdata(card); + + put_device(priv->codec_dev); + return 0; } static struct platform_driver snd_byt_rt5640_mc_driver = { @@ -1586,6 +1600,7 @@ static struct platform_driver snd_byt_rt5640_mc_driver = { .name = "bytcr_rt5640", }, .probe = snd_byt_rt5640_mc_probe, + .remove = snd_byt_rt5640_mc_remove, }; module_platform_driver(snd_byt_rt5640_mc_driver); diff --git a/sound/soc/intel/boards/bytcr_rt5651.c b/sound/soc/intel/boards/bytcr_rt5651.c index e13c0c63a949..7033c07f8fd6 100644 --- a/sound/soc/intel/boards/bytcr_rt5651.c +++ b/sound/soc/intel/boards/bytcr_rt5651.c @@ -85,6 +85,7 @@ struct byt_rt5651_private { struct gpio_desc *ext_amp_gpio; struct gpio_desc *hp_detect; struct snd_soc_jack jack; + struct device *codec_dev; }; static const struct acpi_gpio_mapping *byt_rt5651_gpios; @@ -993,12 +994,12 @@ static int snd_byt_rt5651_mc_probe(struct platform_device *pdev) byt_rt5651_quirk = quirk_override; } + priv->codec_dev = codec_dev; + /* Must be called before register_card, also see declaration comment. */ ret_val = byt_rt5651_add_codec_device_props(codec_dev); - if (ret_val) { - put_device(codec_dev); - return ret_val; - } + if (ret_val) + goto err; /* Cherry Trail devices use an external amplifier enable gpio */ if (soc_intel_is_cht() && !byt_rt5651_gpios) @@ -1022,8 +1023,7 @@ static int snd_byt_rt5651_mc_probe(struct platform_device *pdev) ret_val); fallthrough; case -EPROBE_DEFER: - put_device(codec_dev); - return ret_val; + goto err; } } priv->hp_detect = devm_fwnode_gpiod_get(&pdev->dev, @@ -1042,14 +1042,11 @@ static int snd_byt_rt5651_mc_probe(struct platform_device *pdev) ret_val); fallthrough; case -EPROBE_DEFER: - put_device(codec_dev); - return ret_val; + goto err; } } } - put_device(codec_dev); - log_quirks(&pdev->dev); if ((byt_rt5651_quirk & BYT_RT5651_SSP2_AIF2) || @@ -1073,7 +1070,7 @@ static int snd_byt_rt5651_mc_probe(struct platform_device *pdev) * for all other errors, including -EPROBE_DEFER */ if (ret_val != -ENOENT) - return ret_val; + goto err; byt_rt5651_quirk &= ~BYT_RT5651_MCLK_EN; } } @@ -1102,7 +1099,7 @@ static int snd_byt_rt5651_mc_probe(struct platform_device *pdev) ret_val = snd_soc_fixup_dai_links_platform_name(&byt_rt5651_card, platform_name); if (ret_val) - return ret_val; + goto err; sof_parent = snd_soc_acpi_sof_parent(&pdev->dev); @@ -1124,10 +1121,23 @@ static int snd_byt_rt5651_mc_probe(struct platform_device *pdev) if (ret_val) { dev_err(&pdev->dev, "devm_snd_soc_register_card failed %d\n", ret_val); - return ret_val; + goto err; } platform_set_drvdata(pdev, &byt_rt5651_card); return ret_val; + +err: + put_device(priv->codec_dev); + return ret_val; +} + +static int snd_byt_rt5651_mc_remove(struct platform_device *pdev) +{ + struct snd_soc_card *card = platform_get_drvdata(pdev); + struct byt_rt5651_private *priv = snd_soc_card_get_drvdata(card); + + put_device(priv->codec_dev); + return 0; } static struct platform_driver snd_byt_rt5651_mc_driver = { @@ -1135,6 +1145,7 @@ static struct platform_driver snd_byt_rt5651_mc_driver = { .name = "bytcr_rt5651", }, .probe = snd_byt_rt5651_mc_probe, + .remove = snd_byt_rt5651_mc_remove, }; module_platform_driver(snd_byt_rt5651_mc_driver); From patchwork Fri Aug 13 15:11:10 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierre-Louis Bossart X-Patchwork-Id: 496586 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6A004C43216 for ; Fri, 13 Aug 2021 15:13:27 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id E886A61101 for ; Fri, 13 Aug 2021 15:13:26 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org E886A61101 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.intel.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 7DEF8186B; Fri, 13 Aug 2021 17:12:35 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 7DEF8186B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1628867605; bh=37Oqj2pLC9unks56W7cl8VkW24DQPb51AT5K+psWob4=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=sasWiPeeXVwKpfYHte5frxKzzEzR6eb3pD0HcVxVyy+RMfAAxaEa3qhPc4shdB12L +2h6wLMtuVmRjV3tOj5DKA7UUVgnYnJ66GNgLyfNDzQyzuKKyheeIgd/pv4avrXXqA 9UM9oeUX8nv5Hnl0FetR7FtbU2W9T2llVBSNaFKg= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 5DE79F804E3; Fri, 13 Aug 2021 17:11:49 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 363D5F804E1; Fri, 13 Aug 2021 17:11:43 +0200 (CEST) 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 29A53F802D2 for ; Fri, 13 Aug 2021 17:11:34 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 29A53F802D2 X-IronPort-AV: E=McAfee;i="6200,9189,10075"; a="215301877" X-IronPort-AV: E=Sophos;i="5.84,319,1620716400"; d="scan'208";a="215301877" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Aug 2021 08:11:29 -0700 X-IronPort-AV: E=Sophos;i="5.84,319,1620716400"; d="scan'208";a="422888860" Received: from mchatter-mobl1.amr.corp.intel.com (HELO pbossart-mobl3.intel.com) ([10.212.54.162]) by orsmga003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Aug 2021 08:11:28 -0700 From: Pierre-Louis Bossart To: alsa-devel@alsa-project.org Subject: [PATCH v3 2/8] ASoC: Intel: boards: handle errors with acpi_dev_get_first_match_dev() Date: Fri, 13 Aug 2021 10:11:10 -0500 Message-Id: <20210813151116.23931-3-pierre-louis.bossart@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210813151116.23931-1-pierre-louis.bossart@linux.intel.com> References: <20210813151116.23931-1-pierre-louis.bossart@linux.intel.com> MIME-Version: 1.0 Cc: Heikki Krogerus , tiwai@suse.de, Pierre-Louis Bossart , Hans de Goede , broonie@kernel.org, Andy Shevchenko X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 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: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" acpi_dev_get_first_match_dev() searches for an acpi_handle instantiated by the ACPI table scanning done early during boot. Two of three machine drivers using this search don't deal with errors and the one which does (bytcr_rt5651) returns -ENODEV, which doesn't make sense here: an alternate driver will not be probed. Add consistent error handling and report -ENXIO. Suggested-by: Hans de Goede Reviewed-by: Hans de Goede Reviewed-by: Andy Shevchenko Signed-off-by: Pierre-Louis Bossart --- sound/soc/intel/boards/bytcht_es8316.c | 3 +++ sound/soc/intel/boards/bytcr_rt5640.c | 3 +++ sound/soc/intel/boards/bytcr_rt5651.c | 2 +- 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/sound/soc/intel/boards/bytcht_es8316.c b/sound/soc/intel/boards/bytcht_es8316.c index 893dd74adb94..3224ab7faaa3 100644 --- a/sound/soc/intel/boards/bytcht_es8316.c +++ b/sound/soc/intel/boards/bytcht_es8316.c @@ -492,6 +492,9 @@ static int snd_byt_cht_es8316_mc_probe(struct platform_device *pdev) "i2c-%s", acpi_dev_name(adev)); put_device(&adev->dev); byt_cht_es8316_dais[dai_index].codecs->name = codec_name; + } else { + dev_err(&pdev->dev, "Error cannot find '%s' dev\n", mach->id); + return -ENXIO; } /* override plaform name, if required */ diff --git a/sound/soc/intel/boards/bytcr_rt5640.c b/sound/soc/intel/boards/bytcr_rt5640.c index b25ca99d9855..65c37b037a97 100644 --- a/sound/soc/intel/boards/bytcr_rt5640.c +++ b/sound/soc/intel/boards/bytcr_rt5640.c @@ -1394,6 +1394,9 @@ static int snd_byt_rt5640_mc_probe(struct platform_device *pdev) "i2c-%s", acpi_dev_name(adev)); put_device(&adev->dev); byt_rt5640_dais[dai_index].codecs->name = byt_rt5640_codec_name; + } else { + dev_err(&pdev->dev, "Error cannot find '%s' dev\n", mach->id); + return -ENXIO; } /* diff --git a/sound/soc/intel/boards/bytcr_rt5651.c b/sound/soc/intel/boards/bytcr_rt5651.c index 7033c07f8fd6..b4307d1d5527 100644 --- a/sound/soc/intel/boards/bytcr_rt5651.c +++ b/sound/soc/intel/boards/bytcr_rt5651.c @@ -921,7 +921,7 @@ static int snd_byt_rt5651_mc_probe(struct platform_device *pdev) byt_rt5651_dais[dai_index].codecs->name = byt_rt5651_codec_name; } else { dev_err(&pdev->dev, "Error cannot find '%s' dev\n", mach->id); - return -ENODEV; + return -ENXIO; } codec_dev = bus_find_device_by_name(&i2c_bus_type, NULL, From patchwork Fri Aug 13 15:11:11 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierre-Louis Bossart X-Patchwork-Id: 497111 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9768FC4338F for ; Fri, 13 Aug 2021 15:14:01 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id D428A610FF for ; Fri, 13 Aug 2021 15:14:00 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org D428A610FF Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.intel.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 2EFA9189D; Fri, 13 Aug 2021 17:13:09 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 2EFA9189D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1628867639; bh=TaE6eoHW7lrl48/MiPOYGhB9mXhwUCZdpGkmFDMCg58=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=B3yF6OgVU1FpGcWGOKEiOT5dvOeBRbXeWJ7Go8xKyomejrJBGCFFEjMgHTU4pzv04 UzWwvQZ73Kiv1qr1kw1tzqXxt6VnTTgJNUu+Buk2AhTxSk8+1VHUY2PGPlhWcoXQnJ +zNA3w9U85liqkbh1z+VQxEXOGFQg4+Rq35fHIhE= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id DBF28F804E5; Fri, 13 Aug 2021 17:11:52 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 6C197F804BB; Fri, 13 Aug 2021 17:11:43 +0200 (CEST) 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 DBFBDF80129 for ; Fri, 13 Aug 2021 17:11:35 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz DBFBDF80129 X-IronPort-AV: E=McAfee;i="6200,9189,10075"; a="215301881" X-IronPort-AV: E=Sophos;i="5.84,319,1620716400"; d="scan'208";a="215301881" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Aug 2021 08:11:30 -0700 X-IronPort-AV: E=Sophos;i="5.84,319,1620716400"; d="scan'208";a="422888863" Received: from mchatter-mobl1.amr.corp.intel.com (HELO pbossart-mobl3.intel.com) ([10.212.54.162]) by orsmga003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Aug 2021 08:11:29 -0700 From: Pierre-Louis Bossart To: alsa-devel@alsa-project.org Subject: [PATCH v3 3/8] ASoC: Intel: boards: get codec device with ACPI instead of bus search Date: Fri, 13 Aug 2021 10:11:11 -0500 Message-Id: <20210813151116.23931-4-pierre-louis.bossart@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210813151116.23931-1-pierre-louis.bossart@linux.intel.com> References: <20210813151116.23931-1-pierre-louis.bossart@linux.intel.com> MIME-Version: 1.0 Cc: Heikki Krogerus , tiwai@suse.de, Pierre-Louis Bossart , Hans de Goede , broonie@kernel.org, Andy Shevchenko X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 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: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" We have an existing 'adev' handle from which we can find the codec device, no need for an I2C bus search. Suggested-by: Andy Shevchenko Reviewed-by: Andy Shevchenko Reviewed-by: Hans de Goede Signed-off-by: Pierre-Louis Bossart --- sound/soc/intel/boards/bytcht_es8316.c | 4 ++-- sound/soc/intel/boards/bytcr_rt5640.c | 5 ++--- sound/soc/intel/boards/bytcr_rt5651.c | 6 ++---- 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/sound/soc/intel/boards/bytcht_es8316.c b/sound/soc/intel/boards/bytcht_es8316.c index 3224ab7faaa3..d2e0a0b441fc 100644 --- a/sound/soc/intel/boards/bytcht_es8316.c +++ b/sound/soc/intel/boards/bytcht_es8316.c @@ -539,9 +539,10 @@ static int snd_byt_cht_es8316_mc_probe(struct platform_device *pdev) } /* get speaker enable GPIO */ - codec_dev = bus_find_device_by_name(&i2c_bus_type, NULL, codec_name); + 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"); @@ -559,7 +560,6 @@ static int snd_byt_cht_es8316_mc_probe(struct platform_device *pdev) gpiod_get_index(codec_dev, "speaker-enable", 0, /* see comment in byt_cht_es8316_resume */ GPIOD_OUT_LOW | GPIOD_FLAGS_BIT_NONEXCLUSIVE); - priv->codec_dev = codec_dev; if (IS_ERR(priv->speaker_en_gpio)) { ret = PTR_ERR(priv->speaker_en_gpio); diff --git a/sound/soc/intel/boards/bytcr_rt5640.c b/sound/soc/intel/boards/bytcr_rt5640.c index 65c37b037a97..4215bbafd2f7 100644 --- a/sound/soc/intel/boards/bytcr_rt5640.c +++ b/sound/soc/intel/boards/bytcr_rt5640.c @@ -1473,11 +1473,10 @@ static int snd_byt_rt5640_mc_probe(struct platform_device *pdev) byt_rt5640_quirk = quirk_override; } - codec_dev = bus_find_device_by_name(&i2c_bus_type, NULL, byt_rt5640_codec_name); + codec_dev = acpi_get_first_physical_node(adev); if (!codec_dev) return -EPROBE_DEFER; - - priv->codec_dev = codec_dev; + priv->codec_dev = get_device(codec_dev); /* Must be called before register_card, also see declaration comment. */ ret_val = byt_rt5640_add_codec_device_props(codec_dev, priv); diff --git a/sound/soc/intel/boards/bytcr_rt5651.c b/sound/soc/intel/boards/bytcr_rt5651.c index b4307d1d5527..c70dd729cdbb 100644 --- a/sound/soc/intel/boards/bytcr_rt5651.c +++ b/sound/soc/intel/boards/bytcr_rt5651.c @@ -924,10 +924,10 @@ static int snd_byt_rt5651_mc_probe(struct platform_device *pdev) return -ENXIO; } - codec_dev = bus_find_device_by_name(&i2c_bus_type, NULL, - byt_rt5651_codec_name); + codec_dev = acpi_get_first_physical_node(adev); if (!codec_dev) return -EPROBE_DEFER; + priv->codec_dev = get_device(codec_dev); /* * swap SSP0 if bytcr is detected @@ -994,8 +994,6 @@ static int snd_byt_rt5651_mc_probe(struct platform_device *pdev) byt_rt5651_quirk = quirk_override; } - priv->codec_dev = codec_dev; - /* Must be called before register_card, also see declaration comment. */ ret_val = byt_rt5651_add_codec_device_props(codec_dev); if (ret_val) From patchwork Fri Aug 13 15:11:12 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierre-Louis Bossart X-Patchwork-Id: 496585 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 19413C4338F for ; Fri, 13 Aug 2021 15:14:16 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 1E051610FD for ; Fri, 13 Aug 2021 15:14:15 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 1E051610FD Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.intel.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id A6EC0189A; Fri, 13 Aug 2021 17:13:23 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz A6EC0189A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1628867653; bh=Fihkmh0l+RAKZXGkIy+HCHLcnl7XMQeMwkq4dTLzlvM=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=g3WxjUfyYqTf4S3lUb0MZ2oJaDtAYIbR2SmyRQ1YvdJF8U1igXXxsM0yHMXJWP/5K e0qBdd/XwFZHjVPxpF0vrx2C4OzvevQsnriruKaPDBLRa1On77hSC6G2drU0iUCdWy Ex9AYiKgn93l+Fq2GgkUuCPbDLGHmMBWUHBQfWNg= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 6F3F5F804EC; Fri, 13 Aug 2021 17:11:53 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 56620F804E4; Fri, 13 Aug 2021 17:11:46 +0200 (CEST) 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 00D0CF800E5 for ; Fri, 13 Aug 2021 17:11:35 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 00D0CF800E5 X-IronPort-AV: E=McAfee;i="6200,9189,10075"; a="215301884" X-IronPort-AV: E=Sophos;i="5.84,319,1620716400"; d="scan'208";a="215301884" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Aug 2021 08:11:31 -0700 X-IronPort-AV: E=Sophos;i="5.84,319,1620716400"; d="scan'208";a="422888866" Received: from mchatter-mobl1.amr.corp.intel.com (HELO pbossart-mobl3.intel.com) ([10.212.54.162]) by orsmga003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Aug 2021 08:11:30 -0700 From: Pierre-Louis Bossart To: alsa-devel@alsa-project.org Subject: [PATCH v3 4/8] ASoC: Intel: sof_sdw: pass card information to init/exit functions Date: Fri, 13 Aug 2021 10:11:12 -0500 Message-Id: <20210813151116.23931-5-pierre-louis.bossart@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210813151116.23931-1-pierre-louis.bossart@linux.intel.com> References: <20210813151116.23931-1-pierre-louis.bossart@linux.intel.com> MIME-Version: 1.0 Cc: Heikki Krogerus , tiwai@suse.de, Pierre-Louis Bossart , Hans de Goede , broonie@kernel.org, Andy Shevchenko X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 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: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" If we want to handle a context in init/exit function, we have to pass the card information. This will be necessary to better deal with device properties in the follow-up commits. No functional change other than prototype update. Reviewed-by: Andy Shevchenko Reviewed-by: Hans de Goede Signed-off-by: Pierre-Louis Bossart --- sound/soc/intel/boards/sof_sdw.c | 20 ++++++----- sound/soc/intel/boards/sof_sdw_common.h | 37 +++++++++++++-------- sound/soc/intel/boards/sof_sdw_max98373.c | 3 +- sound/soc/intel/boards/sof_sdw_rt1308.c | 3 +- sound/soc/intel/boards/sof_sdw_rt1316.c | 3 +- sound/soc/intel/boards/sof_sdw_rt5682.c | 3 +- sound/soc/intel/boards/sof_sdw_rt700.c | 3 +- sound/soc/intel/boards/sof_sdw_rt711.c | 5 +-- sound/soc/intel/boards/sof_sdw_rt711_sdca.c | 5 +-- sound/soc/intel/boards/sof_sdw_rt715.c | 3 +- sound/soc/intel/boards/sof_sdw_rt715_sdca.c | 3 +- 11 files changed, 56 insertions(+), 32 deletions(-) diff --git a/sound/soc/intel/boards/sof_sdw.c b/sound/soc/intel/boards/sof_sdw.c index 6c946d7ee0a6..6602eda89e8e 100644 --- a/sound/soc/intel/boards/sof_sdw.c +++ b/sound/soc/intel/boards/sof_sdw.c @@ -352,7 +352,8 @@ static const struct snd_soc_ops sdw_ops = { .shutdown = sdw_shutdown, }; -static int sof_sdw_mic_codec_mockup_init(const struct snd_soc_acpi_link_adr *link, +static int sof_sdw_mic_codec_mockup_init(struct snd_soc_card *card, + const struct snd_soc_acpi_link_adr *link, struct snd_soc_dai_link *dai_links, struct sof_sdw_codec_info *info, bool playback) @@ -697,7 +698,8 @@ static int create_codec_dai_name(struct device *dev, return 0; } -static int set_codec_init_func(const struct snd_soc_acpi_link_adr *link, +static int set_codec_init_func(struct snd_soc_card *card, + const struct snd_soc_acpi_link_adr *link, struct snd_soc_dai_link *dai_links, bool playback, int group_id) { @@ -720,7 +722,8 @@ static int set_codec_init_func(const struct snd_soc_acpi_link_adr *link, if (link->adr_d[i].endpoints->group_id != group_id) continue; if (codec_info_list[codec_index].init) - codec_info_list[codec_index].init(link, + codec_info_list[codec_index].init(card, + link, dai_links, &codec_info_list[codec_index], playback); @@ -805,7 +808,8 @@ static int get_slave_info(const struct snd_soc_acpi_link_adr *adr_link, return 0; } -static int create_sdw_dailink(struct device *dev, int *be_index, +static int create_sdw_dailink(struct snd_soc_card *card, + struct device *dev, int *be_index, struct snd_soc_dai_link *dai_links, int sdw_be_num, int sdw_cpu_dai_num, struct snd_soc_dai_link_component *cpus, @@ -926,7 +930,7 @@ static int create_sdw_dailink(struct device *dev, int *be_index, codecs, codec_num, NULL, &sdw_ops); - ret = set_codec_init_func(link, dai_links + (*be_index)++, + ret = set_codec_init_func(card, link, dai_links + (*be_index)++, playback, group_id); if (ret < 0) { dev_err(dev, "failed to init codec %d", codec_index); @@ -1107,7 +1111,7 @@ static int sof_card_dai_links_create(struct device *dev, group_generated[endpoint->group_id]) continue; - ret = create_sdw_dailink(dev, &be_id, links, sdw_be_num, + ret = create_sdw_dailink(card, dev, &be_id, links, sdw_be_num, sdw_cpu_dai_num, cpus, adr_link, &cpu_id, group_generated, codec_conf, codec_conf_count, @@ -1170,7 +1174,7 @@ static int sof_card_dai_links_create(struct device *dev, ssp_components, 1, NULL, info->ops); - ret = info->init(NULL, links + link_id, info, 0); + ret = info->init(card, NULL, links + link_id, info, 0); if (ret < 0) return ret; @@ -1393,7 +1397,7 @@ static int mc_remove(struct platform_device *pdev) for_each_card_prelinks(card, j, link) { if (!strcmp(link->codecs[0].dai_name, codec_info_list[i].dai_name)) { - ret = codec_info_list[i].exit(&pdev->dev, link); + ret = codec_info_list[i].exit(card, link); if (ret) dev_warn(&pdev->dev, "codec exit failed %d\n", diff --git a/sound/soc/intel/boards/sof_sdw_common.h b/sound/soc/intel/boards/sof_sdw_common.h index 472ccfbbd207..b35f5a9b96f5 100644 --- a/sound/soc/intel/boards/sof_sdw_common.h +++ b/sound/soc/intel/boards/sof_sdw_common.h @@ -62,12 +62,13 @@ struct sof_sdw_codec_info { const char *dai_name; const struct snd_soc_ops *ops; - int (*init)(const struct snd_soc_acpi_link_adr *link, + int (*init)(struct snd_soc_card *card, + const struct snd_soc_acpi_link_adr *link, struct snd_soc_dai_link *dai_links, struct sof_sdw_codec_info *info, bool playback); - int (*exit)(struct device *dev, struct snd_soc_dai_link *dai_link); + int (*exit)(struct snd_soc_card *card, struct snd_soc_dai_link *dai_link); bool late_probe; int (*codec_card_late_probe)(struct snd_soc_card *card); }; @@ -76,6 +77,7 @@ struct mc_private { struct list_head hdmi_pcm_list; bool idisp_codec; struct snd_soc_jack sdw_headset; + struct device *headset_codec_dev; /* only one headset per card */ }; extern unsigned long sof_sdw_quirk; @@ -95,21 +97,24 @@ int sof_sdw_hdmi_card_late_probe(struct snd_soc_card *card); int sof_sdw_dmic_init(struct snd_soc_pcm_runtime *rtd); /* RT711 support */ -int sof_sdw_rt711_init(const struct snd_soc_acpi_link_adr *link, +int sof_sdw_rt711_init(struct snd_soc_card *card, + const struct snd_soc_acpi_link_adr *link, struct snd_soc_dai_link *dai_links, struct sof_sdw_codec_info *info, bool playback); -int sof_sdw_rt711_exit(struct device *dev, struct snd_soc_dai_link *dai_link); +int sof_sdw_rt711_exit(struct snd_soc_card *card, struct snd_soc_dai_link *dai_link); /* RT711-SDCA support */ -int sof_sdw_rt711_sdca_init(const struct snd_soc_acpi_link_adr *link, +int sof_sdw_rt711_sdca_init(struct snd_soc_card *card, + const struct snd_soc_acpi_link_adr *link, struct snd_soc_dai_link *dai_links, struct sof_sdw_codec_info *info, bool playback); -int sof_sdw_rt711_sdca_exit(struct device *dev, struct snd_soc_dai_link *dai_link); +int sof_sdw_rt711_sdca_exit(struct snd_soc_card *card, struct snd_soc_dai_link *dai_link); /* RT700 support */ -int sof_sdw_rt700_init(const struct snd_soc_acpi_link_adr *link, +int sof_sdw_rt700_init(struct snd_soc_card *card, + const struct snd_soc_acpi_link_adr *link, struct snd_soc_dai_link *dai_links, struct sof_sdw_codec_info *info, bool playback); @@ -117,31 +122,36 @@ int sof_sdw_rt700_init(const struct snd_soc_acpi_link_adr *link, /* RT1308 support */ extern struct snd_soc_ops sof_sdw_rt1308_i2s_ops; -int sof_sdw_rt1308_init(const struct snd_soc_acpi_link_adr *link, +int sof_sdw_rt1308_init(struct snd_soc_card *card, + const struct snd_soc_acpi_link_adr *link, struct snd_soc_dai_link *dai_links, struct sof_sdw_codec_info *info, bool playback); /* RT1316 support */ -int sof_sdw_rt1316_init(const struct snd_soc_acpi_link_adr *link, +int sof_sdw_rt1316_init(struct snd_soc_card *card, + const struct snd_soc_acpi_link_adr *link, struct snd_soc_dai_link *dai_links, struct sof_sdw_codec_info *info, bool playback); /* RT715 support */ -int sof_sdw_rt715_init(const struct snd_soc_acpi_link_adr *link, +int sof_sdw_rt715_init(struct snd_soc_card *card, + const struct snd_soc_acpi_link_adr *link, struct snd_soc_dai_link *dai_links, struct sof_sdw_codec_info *info, bool playback); /* RT715-SDCA support */ -int sof_sdw_rt715_sdca_init(const struct snd_soc_acpi_link_adr *link, +int sof_sdw_rt715_sdca_init(struct snd_soc_card *card, + const struct snd_soc_acpi_link_adr *link, struct snd_soc_dai_link *dai_links, struct sof_sdw_codec_info *info, bool playback); /* MAX98373 support */ -int sof_sdw_mx8373_init(const struct snd_soc_acpi_link_adr *link, +int sof_sdw_mx8373_init(struct snd_soc_card *card, + const struct snd_soc_acpi_link_adr *link, struct snd_soc_dai_link *dai_links, struct sof_sdw_codec_info *info, bool playback); @@ -149,7 +159,8 @@ int sof_sdw_mx8373_init(const struct snd_soc_acpi_link_adr *link, int sof_sdw_mx8373_late_probe(struct snd_soc_card *card); /* RT5682 support */ -int sof_sdw_rt5682_init(const struct snd_soc_acpi_link_adr *link, +int sof_sdw_rt5682_init(struct snd_soc_card *card, + const struct snd_soc_acpi_link_adr *link, struct snd_soc_dai_link *dai_links, struct sof_sdw_codec_info *info, bool playback); diff --git a/sound/soc/intel/boards/sof_sdw_max98373.c b/sound/soc/intel/boards/sof_sdw_max98373.c index 25f9065b627c..77a3f32db11e 100644 --- a/sound/soc/intel/boards/sof_sdw_max98373.c +++ b/sound/soc/intel/boards/sof_sdw_max98373.c @@ -120,7 +120,8 @@ static const struct snd_soc_ops max_98373_sdw_ops = { .shutdown = sdw_shutdown, }; -int sof_sdw_mx8373_init(const struct snd_soc_acpi_link_adr *link, +int sof_sdw_mx8373_init(struct snd_soc_card *card, + const struct snd_soc_acpi_link_adr *link, struct snd_soc_dai_link *dai_links, struct sof_sdw_codec_info *info, bool playback) diff --git a/sound/soc/intel/boards/sof_sdw_rt1308.c b/sound/soc/intel/boards/sof_sdw_rt1308.c index 0d476f6f6313..f078fb1aad02 100644 --- a/sound/soc/intel/boards/sof_sdw_rt1308.c +++ b/sound/soc/intel/boards/sof_sdw_rt1308.c @@ -127,7 +127,8 @@ struct snd_soc_ops sof_sdw_rt1308_i2s_ops = { .hw_params = rt1308_i2s_hw_params, }; -int sof_sdw_rt1308_init(const struct snd_soc_acpi_link_adr *link, +int sof_sdw_rt1308_init(struct snd_soc_card *card, + const struct snd_soc_acpi_link_adr *link, struct snd_soc_dai_link *dai_links, struct sof_sdw_codec_info *info, bool playback) diff --git a/sound/soc/intel/boards/sof_sdw_rt1316.c b/sound/soc/intel/boards/sof_sdw_rt1316.c index d6e1ebf18d57..58194b380232 100644 --- a/sound/soc/intel/boards/sof_sdw_rt1316.c +++ b/sound/soc/intel/boards/sof_sdw_rt1316.c @@ -89,7 +89,8 @@ static int all_spk_init(struct snd_soc_pcm_runtime *rtd) return second_spk_init(rtd); } -int sof_sdw_rt1316_init(const struct snd_soc_acpi_link_adr *link, +int sof_sdw_rt1316_init(struct snd_soc_card *card, + const struct snd_soc_acpi_link_adr *link, struct snd_soc_dai_link *dai_links, struct sof_sdw_codec_info *info, bool playback) diff --git a/sound/soc/intel/boards/sof_sdw_rt5682.c b/sound/soc/intel/boards/sof_sdw_rt5682.c index 5fa1a59615b6..ea55479609a8 100644 --- a/sound/soc/intel/boards/sof_sdw_rt5682.c +++ b/sound/soc/intel/boards/sof_sdw_rt5682.c @@ -111,7 +111,8 @@ static int rt5682_rtd_init(struct snd_soc_pcm_runtime *rtd) return ret; } -int sof_sdw_rt5682_init(const struct snd_soc_acpi_link_adr *link, +int sof_sdw_rt5682_init(struct snd_soc_card *card, + const struct snd_soc_acpi_link_adr *link, struct snd_soc_dai_link *dai_links, struct sof_sdw_codec_info *info, bool playback) diff --git a/sound/soc/intel/boards/sof_sdw_rt700.c b/sound/soc/intel/boards/sof_sdw_rt700.c index 21e7e4a81779..bb9584c8f866 100644 --- a/sound/soc/intel/boards/sof_sdw_rt700.c +++ b/sound/soc/intel/boards/sof_sdw_rt700.c @@ -110,7 +110,8 @@ static int rt700_rtd_init(struct snd_soc_pcm_runtime *rtd) return ret; } -int sof_sdw_rt700_init(const struct snd_soc_acpi_link_adr *link, +int sof_sdw_rt700_init(struct snd_soc_card *card, + const struct snd_soc_acpi_link_adr *link, struct snd_soc_dai_link *dai_links, struct sof_sdw_codec_info *info, bool playback) diff --git a/sound/soc/intel/boards/sof_sdw_rt711.c b/sound/soc/intel/boards/sof_sdw_rt711.c index 04074c09dded..8a6a17fe676e 100644 --- a/sound/soc/intel/boards/sof_sdw_rt711.c +++ b/sound/soc/intel/boards/sof_sdw_rt711.c @@ -135,7 +135,7 @@ static int rt711_rtd_init(struct snd_soc_pcm_runtime *rtd) return ret; } -int sof_sdw_rt711_exit(struct device *dev, struct snd_soc_dai_link *dai_link) +int sof_sdw_rt711_exit(struct snd_soc_card *card, struct snd_soc_dai_link *dai_link) { struct device *sdw_dev; @@ -150,7 +150,8 @@ int sof_sdw_rt711_exit(struct device *dev, struct snd_soc_dai_link *dai_link) return 0; } -int sof_sdw_rt711_init(const struct snd_soc_acpi_link_adr *link, +int sof_sdw_rt711_init(struct snd_soc_card *card, + const struct snd_soc_acpi_link_adr *link, struct snd_soc_dai_link *dai_links, struct sof_sdw_codec_info *info, bool playback) diff --git a/sound/soc/intel/boards/sof_sdw_rt711_sdca.c b/sound/soc/intel/boards/sof_sdw_rt711_sdca.c index 19496f0f9110..1ae66f266c6c 100644 --- a/sound/soc/intel/boards/sof_sdw_rt711_sdca.c +++ b/sound/soc/intel/boards/sof_sdw_rt711_sdca.c @@ -135,7 +135,7 @@ static int rt711_sdca_rtd_init(struct snd_soc_pcm_runtime *rtd) return ret; } -int sof_sdw_rt711_sdca_exit(struct device *dev, struct snd_soc_dai_link *dai_link) +int sof_sdw_rt711_sdca_exit(struct snd_soc_card *card, struct snd_soc_dai_link *dai_link) { struct device *sdw_dev; @@ -150,7 +150,8 @@ int sof_sdw_rt711_sdca_exit(struct device *dev, struct snd_soc_dai_link *dai_lin return 0; } -int sof_sdw_rt711_sdca_init(const struct snd_soc_acpi_link_adr *link, +int sof_sdw_rt711_sdca_init(struct snd_soc_card *card, + const struct snd_soc_acpi_link_adr *link, struct snd_soc_dai_link *dai_links, struct sof_sdw_codec_info *info, bool playback) diff --git a/sound/soc/intel/boards/sof_sdw_rt715.c b/sound/soc/intel/boards/sof_sdw_rt715.c index 9b298f79e784..c8af3780cbc3 100644 --- a/sound/soc/intel/boards/sof_sdw_rt715.c +++ b/sound/soc/intel/boards/sof_sdw_rt715.c @@ -24,7 +24,8 @@ static int rt715_rtd_init(struct snd_soc_pcm_runtime *rtd) return 0; } -int sof_sdw_rt715_init(const struct snd_soc_acpi_link_adr *link, +int sof_sdw_rt715_init(struct snd_soc_card *card, + const struct snd_soc_acpi_link_adr *link, struct snd_soc_dai_link *dai_links, struct sof_sdw_codec_info *info, bool playback) diff --git a/sound/soc/intel/boards/sof_sdw_rt715_sdca.c b/sound/soc/intel/boards/sof_sdw_rt715_sdca.c index c056e56a139b..85d3d8c355cc 100644 --- a/sound/soc/intel/boards/sof_sdw_rt715_sdca.c +++ b/sound/soc/intel/boards/sof_sdw_rt715_sdca.c @@ -24,7 +24,8 @@ static int rt715_sdca_rtd_init(struct snd_soc_pcm_runtime *rtd) return 0; } -int sof_sdw_rt715_sdca_init(const struct snd_soc_acpi_link_adr *link, +int sof_sdw_rt715_sdca_init(struct snd_soc_card *card, + const struct snd_soc_acpi_link_adr *link, struct snd_soc_dai_link *dai_links, struct sof_sdw_codec_info *info, bool playback) From patchwork Fri Aug 13 15:11:13 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierre-Louis Bossart X-Patchwork-Id: 497110 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 35683C4338F for ; Fri, 13 Aug 2021 15:14:48 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 6830F610FE for ; Fri, 13 Aug 2021 15:14:47 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 6830F610FE Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.intel.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 0BB741897; Fri, 13 Aug 2021 17:13:56 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 0BB741897 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1628867686; bh=h9Rh4fDyRvUSzlXu/0AngfOk4XMqyWlL6Ksu6nUTAxI=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=Giw4+OGEpbH5mR0utGH9AVw9LNh/NYV/QNS+j2aSsiVYdlREZ47K94tIQhyEP2J+v x8U6HGNJYRsriAeDK96KJ+kQFVd/3reOn5UachhxEW+daM6HakB7WjCSrWyF3djscy 225Wbz2zfSiM2opqsfLgZveh2jVzjtLdfHEGPImQ= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id EFD7BF804F3; Fri, 13 Aug 2021 17:11:53 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id BD176F804E7; Fri, 13 Aug 2021 17:11:49 +0200 (CEST) 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 03924F8032D for ; Fri, 13 Aug 2021 17:11:36 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 03924F8032D X-IronPort-AV: E=McAfee;i="6200,9189,10075"; a="215301886" X-IronPort-AV: E=Sophos;i="5.84,319,1620716400"; d="scan'208";a="215301886" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Aug 2021 08:11:31 -0700 X-IronPort-AV: E=Sophos;i="5.84,319,1620716400"; d="scan'208";a="422888867" Received: from mchatter-mobl1.amr.corp.intel.com (HELO pbossart-mobl3.intel.com) ([10.212.54.162]) by orsmga003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Aug 2021 08:11:31 -0700 From: Pierre-Louis Bossart To: alsa-devel@alsa-project.org Subject: [PATCH v3 5/8] ASoC: Intel: sof_sdw_rt711*: keep codec device reference until remove Date: Fri, 13 Aug 2021 10:11:13 -0500 Message-Id: <20210813151116.23931-6-pierre-louis.bossart@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210813151116.23931-1-pierre-louis.bossart@linux.intel.com> References: <20210813151116.23931-1-pierre-louis.bossart@linux.intel.com> MIME-Version: 1.0 Cc: Heikki Krogerus , tiwai@suse.de, Pierre-Louis Bossart , Hans de Goede , broonie@kernel.org, Andy Shevchenko X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 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: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" Follow the example of Intel Atom drivers and keep a reference to the headset codec until the properties are removed. There is no guarantee that the module for the codec driver is loaded before the machine driver probe, the use of the deferred probe mechanism is required. Reviewed-by: Andy Shevchenko Reviewed-by: Hans de Goede Signed-off-by: Pierre-Louis Bossart --- sound/soc/intel/boards/sof_sdw_rt711.c | 44 +++++++++------------ sound/soc/intel/boards/sof_sdw_rt711_sdca.c | 43 +++++++++----------- 2 files changed, 38 insertions(+), 49 deletions(-) diff --git a/sound/soc/intel/boards/sof_sdw_rt711.c b/sound/soc/intel/boards/sof_sdw_rt711.c index 8a6a17fe676e..510301e09b09 100644 --- a/sound/soc/intel/boards/sof_sdw_rt711.c +++ b/sound/soc/intel/boards/sof_sdw_rt711.c @@ -21,25 +21,15 @@ * Note this MUST be called before snd_soc_register_card(), so that the props * are in place before the codec component driver's probe function parses them. */ -static int rt711_add_codec_device_props(const char *sdw_dev_name) +static int rt711_add_codec_device_props(struct device *sdw_dev) { struct property_entry props[MAX_NO_PROPS] = {}; - struct device *sdw_dev; - int ret; - - sdw_dev = bus_find_device_by_name(&sdw_bus_type, NULL, sdw_dev_name); - if (!sdw_dev) - return -EPROBE_DEFER; - if (SOF_RT711_JDSRC(sof_sdw_quirk)) { - props[0] = PROPERTY_ENTRY_U32("realtek,jd-src", - SOF_RT711_JDSRC(sof_sdw_quirk)); - } - - ret = device_add_properties(sdw_dev, props); - put_device(sdw_dev); + if (!SOF_RT711_JDSRC(sof_sdw_quirk)) + return 0; + props[0] = PROPERTY_ENTRY_U32("realtek,jd-src", SOF_RT711_JDSRC(sof_sdw_quirk)); - return ret; + return device_add_properties(sdw_dev, props); } static const struct snd_soc_dapm_widget rt711_widgets[] = { @@ -137,15 +127,10 @@ static int rt711_rtd_init(struct snd_soc_pcm_runtime *rtd) int sof_sdw_rt711_exit(struct snd_soc_card *card, struct snd_soc_dai_link *dai_link) { - struct device *sdw_dev; - - sdw_dev = bus_find_device_by_name(&sdw_bus_type, NULL, - dai_link->codecs[0].name); - if (!sdw_dev) - return -EINVAL; + struct mc_private *ctx = snd_soc_card_get_drvdata(card); - device_remove_properties(sdw_dev); - put_device(sdw_dev); + device_remove_properties(ctx->headset_codec_dev); + put_device(ctx->headset_codec_dev); return 0; } @@ -156,6 +141,8 @@ int sof_sdw_rt711_init(struct snd_soc_card *card, struct sof_sdw_codec_info *info, bool playback) { + struct mc_private *ctx = snd_soc_card_get_drvdata(card); + struct device *sdw_dev; int ret; /* @@ -165,9 +152,16 @@ int sof_sdw_rt711_init(struct snd_soc_card *card, if (!playback) return 0; - ret = rt711_add_codec_device_props(dai_links->codecs[0].name); - if (ret < 0) + sdw_dev = bus_find_device_by_name(&sdw_bus_type, NULL, dai_links->codecs[0].name); + if (!sdw_dev) + return -EPROBE_DEFER; + + ret = rt711_add_codec_device_props(sdw_dev); + if (ret < 0) { + put_device(sdw_dev); return ret; + } + ctx->headset_codec_dev = sdw_dev; dai_links->init = rt711_rtd_init; diff --git a/sound/soc/intel/boards/sof_sdw_rt711_sdca.c b/sound/soc/intel/boards/sof_sdw_rt711_sdca.c index 1ae66f266c6c..94af40e2beb0 100644 --- a/sound/soc/intel/boards/sof_sdw_rt711_sdca.c +++ b/sound/soc/intel/boards/sof_sdw_rt711_sdca.c @@ -21,25 +21,16 @@ * Note this MUST be called before snd_soc_register_card(), so that the props * are in place before the codec component driver's probe function parses them. */ -static int rt711_sdca_add_codec_device_props(const char *sdw_dev_name) +static int rt711_sdca_add_codec_device_props(struct device *sdw_dev) { struct property_entry props[MAX_NO_PROPS] = {}; - struct device *sdw_dev; - int ret; - - sdw_dev = bus_find_device_by_name(&sdw_bus_type, NULL, sdw_dev_name); - if (!sdw_dev) - return -EPROBE_DEFER; - if (SOF_RT711_JDSRC(sof_sdw_quirk)) { - props[0] = PROPERTY_ENTRY_U32("realtek,jd-src", - SOF_RT711_JDSRC(sof_sdw_quirk)); - } + if (!SOF_RT711_JDSRC(sof_sdw_quirk)) + return 0; - ret = device_add_properties(sdw_dev, props); - put_device(sdw_dev); + props[0] = PROPERTY_ENTRY_U32("realtek,jd-src", SOF_RT711_JDSRC(sof_sdw_quirk)); - return ret; + return device_add_properties(sdw_dev, props); } static const struct snd_soc_dapm_widget rt711_sdca_widgets[] = { @@ -137,15 +128,10 @@ static int rt711_sdca_rtd_init(struct snd_soc_pcm_runtime *rtd) int sof_sdw_rt711_sdca_exit(struct snd_soc_card *card, struct snd_soc_dai_link *dai_link) { - struct device *sdw_dev; - - sdw_dev = bus_find_device_by_name(&sdw_bus_type, NULL, - dai_link->codecs[0].name); - if (!sdw_dev) - return -EINVAL; + struct mc_private *ctx = snd_soc_card_get_drvdata(card); - device_remove_properties(sdw_dev); - put_device(sdw_dev); + device_remove_properties(ctx->headset_codec_dev); + put_device(ctx->headset_codec_dev); return 0; } @@ -156,6 +142,8 @@ int sof_sdw_rt711_sdca_init(struct snd_soc_card *card, struct sof_sdw_codec_info *info, bool playback) { + struct mc_private *ctx = snd_soc_card_get_drvdata(card); + struct device *sdw_dev; int ret; /* @@ -165,9 +153,16 @@ int sof_sdw_rt711_sdca_init(struct snd_soc_card *card, if (!playback) return 0; - ret = rt711_sdca_add_codec_device_props(dai_links->codecs[0].name); - if (ret < 0) + sdw_dev = bus_find_device_by_name(&sdw_bus_type, NULL, dai_links->codecs[0].name); + if (!sdw_dev) + return -EPROBE_DEFER; + + ret = rt711_sdca_add_codec_device_props(sdw_dev); + if (ret < 0) { + put_device(sdw_dev); return ret; + } + ctx->headset_codec_dev = sdw_dev; dai_links->init = rt711_sdca_rtd_init; From patchwork Fri Aug 13 15:11:14 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierre-Louis Bossart X-Patchwork-Id: 496583 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 25F9EC4338F for ; Fri, 13 Aug 2021 15:15:59 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 9DB8860EFE for ; Fri, 13 Aug 2021 15:15:58 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 9DB8860EFE Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.intel.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 4234A18AC; Fri, 13 Aug 2021 17:15:07 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 4234A18AC DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1628867757; bh=O1D/yRa8Hqwk05M9LzeSkHTzsx+cfWwvUyyMG+vgHfY=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=foA20O/vPfiSLGHXtVH7OTS7x/rTULgytqEWQ2nTMPp415Y+M2UI+NIj9geepyncj /0yYa5Giw/y5isaaEeca3eJIwh1phsu45YNoYnrZUeFNKSCkgsVlVz0iCEEdVpFKaS mR7ri5kncfvQNft/WaBXpfCVJG5RbcqG9l4b0gCs= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id DE12EF8051A; Fri, 13 Aug 2021 17:12:56 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id AB7F2F804AE; Fri, 13 Aug 2021 17:12:55 +0200 (CEST) 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 D5E6CF804AE for ; Fri, 13 Aug 2021 17:11:37 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz D5E6CF804AE X-IronPort-AV: E=McAfee;i="6200,9189,10075"; a="215301894" X-IronPort-AV: E=Sophos;i="5.84,319,1620716400"; d="scan'208";a="215301894" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Aug 2021 08:11:32 -0700 X-IronPort-AV: E=Sophos;i="5.84,319,1620716400"; d="scan'208";a="422888868" Received: from mchatter-mobl1.amr.corp.intel.com (HELO pbossart-mobl3.intel.com) ([10.212.54.162]) by orsmga003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Aug 2021 08:11:31 -0700 From: Pierre-Louis Bossart To: alsa-devel@alsa-project.org Subject: [PATCH v3 6/8] ASoC: Intel: use software node API in SoundWire machines Date: Fri, 13 Aug 2021 10:11:14 -0500 Message-Id: <20210813151116.23931-7-pierre-louis.bossart@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210813151116.23931-1-pierre-louis.bossart@linux.intel.com> References: <20210813151116.23931-1-pierre-louis.bossart@linux.intel.com> MIME-Version: 1.0 Cc: Heikki Krogerus , tiwai@suse.de, Pierre-Louis Bossart , Hans de Goede , broonie@kernel.org, Andy Shevchenko X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 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: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" The function device_add_properties() is going to be removed. Replacing it with software node API equivalents. Reviewed-by: Andy Shevchenko Reviewed-by: Hans de Goede Co-developed-by: Heikki Krogerus Signed-off-by: Heikki Krogerus Signed-off-by: Pierre-Louis Bossart --- sound/soc/intel/boards/sof_sdw_rt711.c | 14 ++++++++++++-- sound/soc/intel/boards/sof_sdw_rt711_sdca.c | 14 ++++++++++++-- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/sound/soc/intel/boards/sof_sdw_rt711.c b/sound/soc/intel/boards/sof_sdw_rt711.c index 510301e09b09..c38b70c9fac3 100644 --- a/sound/soc/intel/boards/sof_sdw_rt711.c +++ b/sound/soc/intel/boards/sof_sdw_rt711.c @@ -24,12 +24,22 @@ static int rt711_add_codec_device_props(struct device *sdw_dev) { struct property_entry props[MAX_NO_PROPS] = {}; + struct fwnode_handle *fwnode; + int ret; if (!SOF_RT711_JDSRC(sof_sdw_quirk)) return 0; props[0] = PROPERTY_ENTRY_U32("realtek,jd-src", SOF_RT711_JDSRC(sof_sdw_quirk)); - return device_add_properties(sdw_dev, props); + fwnode = fwnode_create_software_node(props, NULL); + if (IS_ERR(fwnode)) + return PTR_ERR(fwnode); + + ret = device_add_software_node(sdw_dev, to_software_node(fwnode)); + + fwnode_handle_put(fwnode); + + return ret; } static const struct snd_soc_dapm_widget rt711_widgets[] = { @@ -129,7 +139,7 @@ int sof_sdw_rt711_exit(struct snd_soc_card *card, struct snd_soc_dai_link *dai_l { struct mc_private *ctx = snd_soc_card_get_drvdata(card); - device_remove_properties(ctx->headset_codec_dev); + device_remove_software_node(ctx->headset_codec_dev); put_device(ctx->headset_codec_dev); return 0; diff --git a/sound/soc/intel/boards/sof_sdw_rt711_sdca.c b/sound/soc/intel/boards/sof_sdw_rt711_sdca.c index 94af40e2beb0..4215ddc36419 100644 --- a/sound/soc/intel/boards/sof_sdw_rt711_sdca.c +++ b/sound/soc/intel/boards/sof_sdw_rt711_sdca.c @@ -24,13 +24,23 @@ static int rt711_sdca_add_codec_device_props(struct device *sdw_dev) { struct property_entry props[MAX_NO_PROPS] = {}; + struct fwnode_handle *fwnode; + int ret; if (!SOF_RT711_JDSRC(sof_sdw_quirk)) return 0; props[0] = PROPERTY_ENTRY_U32("realtek,jd-src", SOF_RT711_JDSRC(sof_sdw_quirk)); - return device_add_properties(sdw_dev, props); + fwnode = fwnode_create_software_node(props, NULL); + if (IS_ERR(fwnode)) + return PTR_ERR(fwnode); + + ret = device_add_software_node(sdw_dev, to_software_node(fwnode)); + + fwnode_handle_put(fwnode); + + return ret; } static const struct snd_soc_dapm_widget rt711_sdca_widgets[] = { @@ -130,7 +140,7 @@ int sof_sdw_rt711_sdca_exit(struct snd_soc_card *card, struct snd_soc_dai_link * { struct mc_private *ctx = snd_soc_card_get_drvdata(card); - device_remove_properties(ctx->headset_codec_dev); + device_remove_software_node(ctx->headset_codec_dev); put_device(ctx->headset_codec_dev); return 0; From patchwork Fri Aug 13 15:11:15 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierre-Louis Bossart X-Patchwork-Id: 496584 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 92695C4338F for ; Fri, 13 Aug 2021 15:14:55 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 1E9D961153 for ; Fri, 13 Aug 2021 15:14:55 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 1E9D961153 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.intel.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 9E525188B; Fri, 13 Aug 2021 17:14:03 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 9E525188B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1628867693; bh=G8qzkS/GLdtX1D04ebU3OFSCfo0p/NcxL1q9RaV9Rqw=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=vRmSxX4ha23cQxjzYS8YFG9AsKNRngvYWwyMCg5X42qp+ECugFGJdyIcYczsLqAns boMe4cyqo8KD00yRjIES3UrYnJpRgocQ+gryvs9schdE22fd/Ygnf1ysDim2exAjV2 DRBLEf0q5IBFdztFwftGVr/Rnk/SPr1Wcrc1lOKQ= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 7AB48F804FB; Fri, 13 Aug 2021 17:11:54 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 85D73F804E6; Fri, 13 Aug 2021 17:11:51 +0200 (CEST) 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 DBB45F804B4 for ; Fri, 13 Aug 2021 17:11:37 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz DBB45F804B4 X-IronPort-AV: E=McAfee;i="6200,9189,10075"; a="215301900" X-IronPort-AV: E=Sophos;i="5.84,319,1620716400"; d="scan'208";a="215301900" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Aug 2021 08:11:33 -0700 X-IronPort-AV: E=Sophos;i="5.84,319,1620716400"; d="scan'208";a="422888870" Received: from mchatter-mobl1.amr.corp.intel.com (HELO pbossart-mobl3.intel.com) ([10.212.54.162]) by orsmga003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Aug 2021 08:11:32 -0700 From: Pierre-Louis Bossart To: alsa-devel@alsa-project.org Subject: [PATCH v3 7/8] ASoC: Intel: remove device_properties for Atom boards Date: Fri, 13 Aug 2021 10:11:15 -0500 Message-Id: <20210813151116.23931-8-pierre-louis.bossart@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210813151116.23931-1-pierre-louis.bossart@linux.intel.com> References: <20210813151116.23931-1-pierre-louis.bossart@linux.intel.com> MIME-Version: 1.0 Cc: Heikki Krogerus , tiwai@suse.de, Pierre-Louis Bossart , Hans de Goede , broonie@kernel.org, Andy Shevchenko X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 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: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" Prepare the transition to the software node API by removing device properties in the probe error handling and .remove callback. Reviewed-by: Andy Shevchenko Reviewed-by: Hans de Goede Signed-off-by: Pierre-Louis Bossart --- sound/soc/intel/boards/bytcht_es8316.c | 2 ++ sound/soc/intel/boards/bytcr_rt5640.c | 5 ++++- sound/soc/intel/boards/bytcr_rt5651.c | 5 ++++- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/sound/soc/intel/boards/bytcht_es8316.c b/sound/soc/intel/boards/bytcht_es8316.c index d2e0a0b441fc..f3919baaad08 100644 --- a/sound/soc/intel/boards/bytcht_es8316.c +++ b/sound/soc/intel/boards/bytcht_es8316.c @@ -615,6 +615,7 @@ static int snd_byt_cht_es8316_mc_probe(struct platform_device *pdev) return 0; err_put_codec: + device_remove_properties(priv->codec_dev); put_device(priv->codec_dev); return ret; } @@ -625,6 +626,7 @@ static int snd_byt_cht_es8316_mc_remove(struct platform_device *pdev) struct byt_cht_es8316_private *priv = snd_soc_card_get_drvdata(card); gpiod_put(priv->speaker_en_gpio); + device_remove_properties(priv->codec_dev); put_device(priv->codec_dev); return 0; } diff --git a/sound/soc/intel/boards/bytcr_rt5640.c b/sound/soc/intel/boards/bytcr_rt5640.c index 4215bbafd2f7..41fd56d42103 100644 --- a/sound/soc/intel/boards/bytcr_rt5640.c +++ b/sound/soc/intel/boards/bytcr_rt5640.c @@ -1481,7 +1481,7 @@ static int snd_byt_rt5640_mc_probe(struct platform_device *pdev) /* Must be called before register_card, also see declaration comment. */ ret_val = byt_rt5640_add_codec_device_props(codec_dev, priv); if (ret_val) - goto err; + goto err_device; log_quirks(&pdev->dev); @@ -1584,6 +1584,8 @@ static int snd_byt_rt5640_mc_probe(struct platform_device *pdev) return ret_val; err: + device_remove_properties(priv->codec_dev); +err_device: put_device(priv->codec_dev); return ret_val; } @@ -1593,6 +1595,7 @@ static int snd_byt_rt5640_mc_remove(struct platform_device *pdev) struct snd_soc_card *card = platform_get_drvdata(pdev); struct byt_rt5640_private *priv = snd_soc_card_get_drvdata(card); + device_remove_properties(priv->codec_dev); put_device(priv->codec_dev); return 0; } diff --git a/sound/soc/intel/boards/bytcr_rt5651.c b/sound/soc/intel/boards/bytcr_rt5651.c index c70dd729cdbb..cc1505e53b4f 100644 --- a/sound/soc/intel/boards/bytcr_rt5651.c +++ b/sound/soc/intel/boards/bytcr_rt5651.c @@ -997,7 +997,7 @@ static int snd_byt_rt5651_mc_probe(struct platform_device *pdev) /* Must be called before register_card, also see declaration comment. */ ret_val = byt_rt5651_add_codec_device_props(codec_dev); if (ret_val) - goto err; + goto err_device; /* Cherry Trail devices use an external amplifier enable gpio */ if (soc_intel_is_cht() && !byt_rt5651_gpios) @@ -1125,6 +1125,8 @@ static int snd_byt_rt5651_mc_probe(struct platform_device *pdev) return ret_val; err: + device_remove_properties(priv->codec_dev); +err_device: put_device(priv->codec_dev); return ret_val; } @@ -1134,6 +1136,7 @@ static int snd_byt_rt5651_mc_remove(struct platform_device *pdev) struct snd_soc_card *card = platform_get_drvdata(pdev); struct byt_rt5651_private *priv = snd_soc_card_get_drvdata(card); + device_remove_properties(priv->codec_dev); put_device(priv->codec_dev); return 0; } From patchwork Fri Aug 13 15:11:16 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierre-Louis Bossart X-Patchwork-Id: 497109 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2EE17C432BE for ; Fri, 13 Aug 2021 15:15:42 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 9D7D1610EA for ; Fri, 13 Aug 2021 15:15:41 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 9D7D1610EA Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.intel.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 3C7BB18A8; Fri, 13 Aug 2021 17:14:50 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 3C7BB18A8 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1628867740; bh=kgwem+pyZrBdeMnaL4BE8e29VIH9+T9w89AWQ8Lbyj8=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=AQrybLLlJT5sbm1AHI1pLZDPLZ6Qcags71DNYKvUKq+Xw2+BZnBZflpb5mWHR72JG Rkj8qw99wEKnKxP5XNpAt4Ax9GbWuisajMFwAFJyypP8f3VLsLiNLfvQCi771l9SbV N+jyfpq1HSxz8M9ePH8g9cBNdKsuvOD14wPdY6AY= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 36B7DF804AE; Fri, 13 Aug 2021 17:12:56 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id A87F9F804DA; Fri, 13 Aug 2021 17:12:55 +0200 (CEST) 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 03123F804B0 for ; Fri, 13 Aug 2021 17:11:38 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 03123F804B0 X-IronPort-AV: E=McAfee;i="6200,9189,10075"; a="215301905" X-IronPort-AV: E=Sophos;i="5.84,319,1620716400"; d="scan'208";a="215301905" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Aug 2021 08:11:34 -0700 X-IronPort-AV: E=Sophos;i="5.84,319,1620716400"; d="scan'208";a="422888871" Received: from mchatter-mobl1.amr.corp.intel.com (HELO pbossart-mobl3.intel.com) ([10.212.54.162]) by orsmga003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Aug 2021 08:11:33 -0700 From: Pierre-Louis Bossart To: alsa-devel@alsa-project.org Subject: [PATCH v3 8/8] ASoC: Intel: boards: use software node API in Atom boards Date: Fri, 13 Aug 2021 10:11:16 -0500 Message-Id: <20210813151116.23931-9-pierre-louis.bossart@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210813151116.23931-1-pierre-louis.bossart@linux.intel.com> References: <20210813151116.23931-1-pierre-louis.bossart@linux.intel.com> MIME-Version: 1.0 Cc: Heikki Krogerus , tiwai@suse.de, Pierre-Louis Bossart , Hans de Goede , broonie@kernel.org, Andy Shevchenko X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 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: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" From: Heikki Krogerus The function device_add_properties() is going to be removed. Replacing it with software node API equivalents. Reviewed-by: Andy Shevchenko Reviewed-by: Hans de Goede Co-developed-by: Pierre-Louis Bossart Signed-off-by: Pierre-Louis Bossart Signed-off-by: Heikki Krogerus --- sound/soc/intel/boards/bytcht_es8316.c | 16 +++++++++++++--- sound/soc/intel/boards/bytcr_rt5640.c | 18 +++++++++++++++--- sound/soc/intel/boards/bytcr_rt5651.c | 23 ++++++++++++++++++----- 3 files changed, 46 insertions(+), 11 deletions(-) diff --git a/sound/soc/intel/boards/bytcht_es8316.c b/sound/soc/intel/boards/bytcht_es8316.c index f3919baaad08..055248f104b2 100644 --- a/sound/soc/intel/boards/bytcht_es8316.c +++ b/sound/soc/intel/boards/bytcht_es8316.c @@ -462,6 +462,7 @@ static int snd_byt_cht_es8316_mc_probe(struct platform_device *pdev) const struct dmi_system_id *dmi_id; struct device *dev = &pdev->dev; struct snd_soc_acpi_mach *mach; + struct fwnode_handle *fwnode; const char *platform_name; struct acpi_device *adev; struct device *codec_dev; @@ -548,7 +549,16 @@ static int snd_byt_cht_es8316_mc_probe(struct platform_device *pdev) props[cnt++] = PROPERTY_ENTRY_BOOL("everest,jack-detect-inverted"); if (cnt) { - ret = device_add_properties(codec_dev, props); + fwnode = fwnode_create_software_node(props, NULL); + if (IS_ERR(fwnode)) { + put_device(codec_dev); + return PTR_ERR(fwnode); + } + + ret = device_add_software_node(codec_dev, to_software_node(fwnode)); + + fwnode_handle_put(fwnode); + if (ret) { put_device(codec_dev); return ret; @@ -615,7 +625,7 @@ static int snd_byt_cht_es8316_mc_probe(struct platform_device *pdev) return 0; err_put_codec: - device_remove_properties(priv->codec_dev); + device_remove_software_node(priv->codec_dev); put_device(priv->codec_dev); return ret; } @@ -626,7 +636,7 @@ static int snd_byt_cht_es8316_mc_remove(struct platform_device *pdev) struct byt_cht_es8316_private *priv = snd_soc_card_get_drvdata(card); gpiod_put(priv->speaker_en_gpio); - device_remove_properties(priv->codec_dev); + device_remove_software_node(priv->codec_dev); put_device(priv->codec_dev); return 0; } diff --git a/sound/soc/intel/boards/bytcr_rt5640.c b/sound/soc/intel/boards/bytcr_rt5640.c index 41fd56d42103..fecccff76caf 100644 --- a/sound/soc/intel/boards/bytcr_rt5640.c +++ b/sound/soc/intel/boards/bytcr_rt5640.c @@ -974,7 +974,9 @@ static int byt_rt5640_add_codec_device_props(struct device *i2c_dev, struct byt_rt5640_private *priv) { struct property_entry props[MAX_NO_PROPS] = {}; + struct fwnode_handle *fwnode; int cnt = 0; + int ret; switch (BYT_RT5640_MAP(byt_rt5640_quirk)) { case BYT_RT5640_DMIC1_MAP: @@ -1014,7 +1016,17 @@ static int byt_rt5640_add_codec_device_props(struct device *i2c_dev, if (byt_rt5640_quirk & BYT_RT5640_JD_NOT_INV) props[cnt++] = PROPERTY_ENTRY_BOOL("realtek,jack-detect-not-inverted"); - return device_add_properties(i2c_dev, props); + fwnode = fwnode_create_software_node(props, NULL); + if (IS_ERR(fwnode)) { + /* put_device() is handled in caller */ + return PTR_ERR(fwnode); + } + + ret = device_add_software_node(i2c_dev, to_software_node(fwnode)); + + fwnode_handle_put(fwnode); + + return ret; } static int byt_rt5640_init(struct snd_soc_pcm_runtime *runtime) @@ -1584,7 +1596,7 @@ static int snd_byt_rt5640_mc_probe(struct platform_device *pdev) return ret_val; err: - device_remove_properties(priv->codec_dev); + device_remove_software_node(priv->codec_dev); err_device: put_device(priv->codec_dev); return ret_val; @@ -1595,7 +1607,7 @@ static int snd_byt_rt5640_mc_remove(struct platform_device *pdev) struct snd_soc_card *card = platform_get_drvdata(pdev); struct byt_rt5640_private *priv = snd_soc_card_get_drvdata(card); - device_remove_properties(priv->codec_dev); + device_remove_software_node(priv->codec_dev); put_device(priv->codec_dev); return 0; } diff --git a/sound/soc/intel/boards/bytcr_rt5651.c b/sound/soc/intel/boards/bytcr_rt5651.c index cc1505e53b4f..e94c9124d4f4 100644 --- a/sound/soc/intel/boards/bytcr_rt5651.c +++ b/sound/soc/intel/boards/bytcr_rt5651.c @@ -528,10 +528,13 @@ static const struct dmi_system_id byt_rt5651_quirk_table[] = { * Note this MUST be called before snd_soc_register_card(), so that the props * are in place before the codec component driver's probe function parses them. */ -static int byt_rt5651_add_codec_device_props(struct device *i2c_dev) +static int byt_rt5651_add_codec_device_props(struct device *i2c_dev, + struct byt_rt5651_private *priv) { struct property_entry props[MAX_NO_PROPS] = {}; + struct fwnode_handle *fwnode; int cnt = 0; + int ret; props[cnt++] = PROPERTY_ENTRY_U32("realtek,jack-detect-source", BYT_RT5651_JDSRC(byt_rt5651_quirk)); @@ -548,7 +551,17 @@ static int byt_rt5651_add_codec_device_props(struct device *i2c_dev) if (byt_rt5651_quirk & BYT_RT5651_JD_NOT_INV) props[cnt++] = PROPERTY_ENTRY_BOOL("realtek,jack-detect-not-inverted"); - return device_add_properties(i2c_dev, props); + fwnode = fwnode_create_software_node(props, NULL); + if (IS_ERR(fwnode)) { + /* put_device(i2c_dev) is handled in caller */ + return PTR_ERR(fwnode); + } + + ret = device_add_software_node(i2c_dev, to_software_node(fwnode)); + + fwnode_handle_put(fwnode); + + return ret; } static int byt_rt5651_init(struct snd_soc_pcm_runtime *runtime) @@ -995,7 +1008,7 @@ static int snd_byt_rt5651_mc_probe(struct platform_device *pdev) } /* Must be called before register_card, also see declaration comment. */ - ret_val = byt_rt5651_add_codec_device_props(codec_dev); + ret_val = byt_rt5651_add_codec_device_props(codec_dev, priv); if (ret_val) goto err_device; @@ -1125,7 +1138,7 @@ static int snd_byt_rt5651_mc_probe(struct platform_device *pdev) return ret_val; err: - device_remove_properties(priv->codec_dev); + device_remove_software_node(priv->codec_dev); err_device: put_device(priv->codec_dev); return ret_val; @@ -1136,7 +1149,7 @@ static int snd_byt_rt5651_mc_remove(struct platform_device *pdev) struct snd_soc_card *card = platform_get_drvdata(pdev); struct byt_rt5651_private *priv = snd_soc_card_get_drvdata(card); - device_remove_properties(priv->codec_dev); + device_remove_software_node(priv->codec_dev); put_device(priv->codec_dev); return 0; }