From patchwork Wed Jul 5 21:47:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cristian Ciocaltea X-Patchwork-Id: 116453 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9f45:0:b0:3ea:f831:8777 with SMTP id v5csp2157083vqx; Wed, 5 Jul 2023 14:52:42 -0700 (PDT) X-Google-Smtp-Source: APBJJlH7ErYIdrh+9Pb71cbPt92khWYWzsaCSyDonSLirHhdzsPnxWPXKUuFlOZXY0zsfJzXZYW5 X-Received: by 2002:a17:90b:228c:b0:263:850a:b49c with SMTP id kx12-20020a17090b228c00b00263850ab49cmr53788pjb.7.1688593961837; Wed, 05 Jul 2023 14:52:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688593961; cv=none; d=google.com; s=arc-20160816; b=t7EuGOWWb7vzOG8tSfHr0rdDbSfqkuFLaVqI3cyW6xAyIRT8hcLsry9dBLJccS7lK7 jJauOSwI7nVPmh4w4Qbes4HPzMmSVuc1zj4HquRB3avFtbhkGwuxNxxLUzs1I9Lc70V5 QgALg3qATgJ8JM3Wl/0EnsKhuvhkZXz9g4/qVmUhM9MohgjDGR07qaLU/SVFtwAFr10M CyEvLNpPnS6+QmgSZ3jFheoPyRqdKrACdkjRFJpykLmRb0m1lH3jS1W2fvhZgttwIgFg J3fqJtvAbPc7FKfyBSg8cY4SVH2AngGaupN/1olXClcsmqJDLZKlAcgAiuFXRrJCVfLw lMvg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=iN/mvD3LBn+ZNcgz0QFQ8G04Gh/3Ak+rxzrga8HVBbU=; fh=WpwulVhbj4/4SUydfqjIitCcTK++J8QA/iGpwX/VPoo=; b=kBbpgYXlSUBqDqCidteewZ8l8L5hqOPgMjoJwhZRswwClRR0feGx0xtdqksEW4RH1t yvOjEKlw0wswBEVmENTf3Nw6vBJ1kxEsy4TbtwXvm8X+Vd9j0PFpJen/9CV1UxsYL12V 0A13+8FzXabrQO5maFyOC7BdhVkIjGKLzJfQC51kL49yxk80E1c1cJ0u4SUWa01JCHEK QjUEgZhwB7EQ76MobNaF+Mfe0ia+YvXaySWM1kFK5gTy6LB8Bp0jgrZHOxSYLS3/GZ6h XY8CEglpMm2gMGmVnx/nJW1l5ID5d60+V8QvryMHOyot+j+9zCSb2pUBCDmPHbMYRCNH EUbQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=kUKURCXz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h124-20020a636c82000000b0055764ab9ea8si30959pgc.732.2023.07.05.14.52.27; Wed, 05 Jul 2023 14:52:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=kUKURCXz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231935AbjGEVsS (ORCPT + 99 others); Wed, 5 Jul 2023 17:48:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41336 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231969AbjGEVsN (ORCPT ); Wed, 5 Jul 2023 17:48:13 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e5ab]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5EE94198E for ; Wed, 5 Jul 2023 14:48:12 -0700 (PDT) Received: from localhost (unknown [188.24.137.5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: cristicc) by madras.collabora.co.uk (Postfix) with ESMTPSA id 141E46600B9D; Wed, 5 Jul 2023 22:48:11 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1688593691; bh=f6qzZZCqh3StcdQmbdXHhNuewxQtRotpLidUnnuRtcw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kUKURCXzesKef5UuNO0S9nrGOdxIBU6hP2l1oa6onMIafbG3Egc8uHZC2bfroH2AC VAcNc5oGV4CKaLY+wuvoIfnzEQXzIHnNJ1aGUs6MeCaCsjsEpMOXNPsQIdFsvHT5nr jpYQs2pMyCwLOWermrrdgFCWWWpFLz10bz3bRuzyi9cyjexQpbxaXXF2md3VSquE7d ZKUYBUo6JuaBBMSK5gerQBQZUb4xBoTCfdcicdX5D7OakpJMfn2bFWpZ4yHm2tDT+w arZBBc81DYeuDnj6b++imWjWnC+CzhzboY6XIQscxOOvB0rQMZ2sfpar9RHaCF3UmO qI2K/MzSduNCQ== From: Cristian Ciocaltea To: Liam Girdwood , Mark Brown , Jaroslav Kysela , Takashi Iwai , Syed Saba Kareem , Vijendar Mukunda , Arnd Bergmann , Randy Dunlap , Charles Keepax , Kuninori Morimoto Cc: alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, kernel@collabora.com Subject: [PATCH v3 2/3] ASoC: amd: vangogh: Use dmi_first_match() for DMI quirk handling Date: Thu, 6 Jul 2023 00:47:59 +0300 Message-ID: <20230705214800.193244-3-cristian.ciocaltea@collabora.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230705214800.193244-1-cristian.ciocaltea@collabora.com> References: <20230705214800.193244-1-cristian.ciocaltea@collabora.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1770619101877716419?= X-GMAIL-MSGID: =?utf-8?q?1770619101877716419?= In preparation for supporting ACPI probing, move DMI quirk handling logic at the probe's top, to be able to return as quickly as possible in case there is no DMI matching. Additionally, simplify the code by replacing dmi_check_system() and related callback with dmi_first_match(). While at it, also drop a few unnecessary empty lines. Signed-off-by: Cristian Ciocaltea --- sound/soc/amd/vangogh/acp5x-mach.c | 28 +++++++--------------------- 1 file changed, 7 insertions(+), 21 deletions(-) diff --git a/sound/soc/amd/vangogh/acp5x-mach.c b/sound/soc/amd/vangogh/acp5x-mach.c index 5e36179cf611..1efa8f8b77ab 100644 --- a/sound/soc/amd/vangogh/acp5x-mach.c +++ b/sound/soc/amd/vangogh/acp5x-mach.c @@ -22,7 +22,6 @@ #define DRV_NAME "acp5x_mach" #define DUAL_CHANNEL 2 -#define VG_JUPITER 1 #define ACP5X_NAU8821_BCLK 3072000 #define ACP5X_NAU8821_FREQ_OUT 12288000 #define ACP5X_NAU8821_COMP_NAME "i2c-NVTN2020:00" @@ -31,7 +30,6 @@ #define ACP5X_CS35L41_COMP_RNAME "spi-VLV1776:01" #define ACP5X_CS35L41_DAI_NAME "cs35l41-pcm" -static unsigned long acp5x_machine_id; static struct snd_soc_jack vg_headset; SND_SOC_DAILINK_DEF(platform, DAILINK_COMP_ARRAY(COMP_PLATFORM("acp5x_i2s_dma.0"))); @@ -242,7 +240,6 @@ static int acp5x_cs35l41_hw_params(struct snd_pcm_substream *substream, } return 0; - } static const struct snd_soc_ops acp5x_cs35l41_play_ops = { @@ -292,8 +289,6 @@ static struct snd_soc_dai_link acp5x_8821_35l41_dai[] = { }, }; - - static const struct snd_soc_dapm_widget acp5x_8821_35l41_widgets[] = { SND_SOC_DAPM_HP("Headphone", NULL), SND_SOC_DAPM_MIC("Headset Mic", NULL), @@ -331,16 +326,8 @@ static struct snd_soc_card acp5x_8821_35l41_card = { .num_controls = ARRAY_SIZE(acp5x_8821_controls), }; -static int acp5x_vg_quirk_cb(const struct dmi_system_id *id) -{ - acp5x_machine_id = VG_JUPITER; - - return 1; -} - static const struct dmi_system_id acp5x_vg_quirk_table[] = { { - .callback = acp5x_vg_quirk_cb, .matches = { DMI_EXACT_MATCH(DMI_BOARD_VENDOR, "Valve"), DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "Jupiter"), @@ -351,23 +338,22 @@ static const struct dmi_system_id acp5x_vg_quirk_table[] = { static int acp5x_probe(struct platform_device *pdev) { + const struct dmi_system_id *dmi_id; struct acp5x_platform_info *machine; struct device *dev = &pdev->dev; struct snd_soc_card *card; int ret; + dmi_id = dmi_first_match(acp5x_vg_quirk_table); + if (!dmi_id) + return -ENODEV; + + card = &acp5x_8821_35l41_card; + machine = devm_kzalloc(dev, sizeof(*machine), GFP_KERNEL); if (!machine) return -ENOMEM; - dmi_check_system(acp5x_vg_quirk_table); - switch (acp5x_machine_id) { - case VG_JUPITER: - card = &acp5x_8821_35l41_card; - break; - default: - return -ENODEV; - } card->dev = dev; platform_set_drvdata(pdev, card); snd_soc_card_set_drvdata(card, machine);