Received: by 2002:a05:6358:701b:b0:131:369:b2a3 with SMTP id 27csp2859831rwo; Mon, 24 Jul 2023 02:20:32 -0700 (PDT) X-Google-Smtp-Source: APBJJlG9ryZX0ZV5Dg0CXzvPO1yuaLO5gj5j2ipp9GivpXQSMeD3Iuj+4EefH7TxZjxXi7BInfzg X-Received: by 2002:a17:907:78d7:b0:993:e752:1a71 with SMTP id kv23-20020a17090778d700b00993e7521a71mr9279130ejc.9.1690190431884; Mon, 24 Jul 2023 02:20:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690190431; cv=none; d=google.com; s=arc-20160816; b=ynLDOxUXH4JVY4N2+g4ErnwDBERAJ6oQH2ZgEkTqnap9+bFP3IC4/OChwuIheLFeQG ThOWztHSx9yzik3jXGz6TdO6S93FK7HxXGqj9dT2oz4Y6P3BxAmQk8I6BLSPDh2CB39T RVuUTpmkMqVe+yFyHzME8du2Jxj5T1V9Ztxbh+Q88uIWAwbW6nkxHGAMjJzmUUoaVNNv YnlFlJMn15tLzYXN/eU1/TqKJyMbBBEj9ic4ii4motp1I+ZBgV+O4JmYoDImyH9fDehJ r9KoRByWIPJr4MQJI3QgxNkMBdPFIdJxikWDzYCdd3XJzH1BnLe6N+/EXk/W0unNGcsN qbZw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=eBPufabTvNGC1TuFINxZTKVLh2ge2xY0/It64wmGXyQ=; fh=XBq57FL0/qmyOxTsZ7knmHYPNzUiHn6kvKAclOaMHIg=; b=FlmJUxANaC0zA2Ylp8dVbKN0XWO8rdEsWx+WCnPD937iUV57+in9+eO7M5wcpEaBkE fziWg1PxSM0ODvqhiijSkVgVKkGzuAi+Zb44R/mRlulJkSe6ElRB8j2FNL0AcGfsf88j BJTlAvXvSl+gLqXXMzeauB8yW/bCZ/u5sPHYKIBZmCXGAF6Z0o99DGbKjQpam3BEJx0E txkK7R0GhwxZpVdhc43pVHZIb/KUtCK2LWSxFlMLIIaWRhuBbb/A4/M57GV2kXUvtDUq k/7Ti+KgTvVv+m/zfLnFadF3aRj7DAdtsyX3XPdXv6a3N/X4C6ltRcEG56LoUeLAPkww Jsuw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Ix2gkj4A; 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=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f20-20020a170906c09400b00991df467babsi6308392ejz.221.2023.07.24.02.20.07; Mon, 24 Jul 2023 02:20:31 -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=@intel.com header.s=Intel header.b=Ix2gkj4A; 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=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231879AbjGXJLc (ORCPT + 99 others); Mon, 24 Jul 2023 05:11:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33874 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229974AbjGXJLa (ORCPT ); Mon, 24 Jul 2023 05:11:30 -0400 Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E6646F9 for ; Mon, 24 Jul 2023 02:11:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1690189889; x=1721725889; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=IJuS2NPpHW5yxPKPbFGIfcOiW3Jkp5gRaCUPlulOu7Y=; b=Ix2gkj4ATs03SgwGw3ViW9CMfslG5LHjnlJnrNwfcIv+KR39UgND21g0 F0+useCF/I9pJO1/2nIgBKuQi6xrjZT8YW8724mxosrewjjuY2hOO20Et d2azxPtjDLICJQLkeR0F3PStNqSvU6u1lJb4Zjy37jHCpQ4IpknAm/SV2 5sxFgRF+Yv1a4RC+3mfN+ZUjsy5tD9YOp8f9rDlZzD4x6259UtLIaNqXb n69pJMaok3moA+H+terTyfLnJW9xrFEfQOyZTCTxlwj9OlWBjnEDsHpIS HRDpR+WcWX6AtuYmw2TJI0uW90sbh0Zi/1LI4TXTr2t6Wt75Q3YN3IDKu w==; X-IronPort-AV: E=McAfee;i="6600,9927,10780"; a="370060617" X-IronPort-AV: E=Sophos;i="6.01,228,1684825200"; d="scan'208";a="370060617" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Jul 2023 02:11:29 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10780"; a="1056353961" X-IronPort-AV: E=Sophos;i="6.01,228,1684825200"; d="scan'208";a="1056353961" Received: from sosterlu-mobl.ger.corp.intel.com (HELO [10.249.37.56]) ([10.249.37.56]) by fmsmga005-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Jul 2023 02:11:24 -0700 Message-ID: Date: Mon, 24 Jul 2023 11:08:17 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Firefox/102.0 Thunderbird/102.13.0 Subject: Re: [PATCH 1/2] ASoC: Intel: maxim-common: get codec number from ACPI Content-Language: en-US To: Brent Lu , alsa-devel@alsa-project.org Cc: Cezary Rojewski , Liam Girdwood , Peter Ujfalusi , Bard Liao , Ranjani Sridharan , Kai Vehmanen , Mark Brown , Jaroslav Kysela , Takashi Iwai , linux-kernel@vger.kernel.org, Yong Zhi , Ajye Huang , Uday M Bhat , Terry Cheong , Mac Chiang , "Dharageswari . R" , Kuninori Morimoto , Andy Shevchenko References: <20230720092628.758834-1-brent.lu@intel.com> <20230720092628.758834-2-brent.lu@intel.com> From: Pierre-Louis Bossart In-Reply-To: <20230720092628.758834-2-brent.lu@intel.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE 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 On 7/20/23 11:26, Brent Lu wrote: > Implement a helper function to get number of codecs from ACPI > subsystem to remove the need of quirk flag in machine driver. > > Signed-off-by: Brent Lu > --- > sound/soc/intel/boards/sof_maxim_common.c | 174 +++++++++++++--------- > sound/soc/intel/boards/sof_maxim_common.h | 21 ++- > 2 files changed, 113 insertions(+), 82 deletions(-) > > diff --git a/sound/soc/intel/boards/sof_maxim_common.c b/sound/soc/intel/boards/sof_maxim_common.c > index 112e89951da0..f8b44a81fec1 100644 > --- a/sound/soc/intel/boards/sof_maxim_common.c > +++ b/sound/soc/intel/boards/sof_maxim_common.c > @@ -4,6 +4,7 @@ > #include > #include > #include > +#include > #include > #include > #include > @@ -11,6 +12,21 @@ > #include > #include "sof_maxim_common.h" > > +/* helper function to get the number of specific codec */ > +static int get_num_codecs(const char *hid) > +{ > + struct acpi_device *adev = NULL; > + int dev_num = 0; > + > + do { > + adev = acpi_dev_get_next_match_dev(adev, hid, NULL, -1); Humm, I am a bit worried about reference counts. See https://elixir.bootlin.com/linux/latest/source/drivers/acpi/utils.c#L916, it's not clear to me where the get() is done. Adding Andy to make sure this is done right. > + if (adev) > + dev_num++; > + } while (adev != NULL); > + > + return dev_num; > +}