Received: by 10.192.165.148 with SMTP id m20csp3715241imm; Mon, 30 Apr 2018 05:17:21 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrz5Sr6kvuwiJCxD8i4otNAuvfsXOhEjzXbIbOpR2bYdrLR5eytkv1Kui30zwZ01tKWasVP X-Received: by 10.98.112.2 with SMTP id l2mr11902559pfc.40.1525090641376; Mon, 30 Apr 2018 05:17:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525090641; cv=none; d=google.com; s=arc-20160816; b=goOtJa4Uto+WEF1PzL+08WhtFicY8twNJAbxv2dDG1X+ZbZAxg9/QpZDbcboa9833B cvkZ9EFturogtdqXqJrzo0t0SIKd2rvNXRX1gbK5PrM5ZqN+HYeCmMtJrzEwRQ/eP7rQ sFJjIm0tzxWJj0TXOhZrrh/Cc8rcbq1/vbwlu630FxonMxctapQNp1058BCA6tt4+ckb 8VjctMJA0RJZ99LTM6e0qDVZQegBx++7QOb79BYszieCYRf0zUR2v+BFcj1/NkfkvW1K Xzb0V95u/3LqpjxFZboi6I8tUoJ/KxF4C1/A/MXP0T0Q4RRmFRGBeXAjAjOpU57XASvg Ey/A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:subject:cc :to:from:arc-authentication-results; bh=xT6J9l4ZgpgvgC3h5WVz/oVejRWFrr+RHITjbfQ0QeI=; b=Ghdvg9QyFGNsXraH9wVPJIPzNMXmo5FUboFepiksTxfk55Vwk6RWEOhr4P7XmDnBxO R1BMMx7o0eoLqh7z2mTnaiDcP/MFyplZkgGokRsVa0x87cIDFfzN+c3ivkql32uj7/ER h3q264FMPsfQtOmBI/WtNZu5Oy5+4Ou6GGGwz6W6frFy+9lQ9SuxwlBQwujbWih46fWY pNFmsr+JdvOeXbP2gjkorNeOVddL3zFR218vpGmpZo3CK8w5sZMEoOMZ8toBdo5Wunkg O84z9cDPWUjHdpmy31Er1yoJy+glVG+tODpiMOOD16zPsw8Re5YVt6aTxbWKwv7LwlyX PPFg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id bj6-v6si7436208plb.405.2018.04.30.05.17.07; Mon, 30 Apr 2018 05:17:21 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753181AbeD3MPl (ORCPT + 99 others); Mon, 30 Apr 2018 08:15:41 -0400 Received: from mailgw01.mediatek.com ([210.61.82.183]:20383 "EHLO mailgw01.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1752768AbeD3MPl (ORCPT ); Mon, 30 Apr 2018 08:15:41 -0400 X-UUID: 45ba2f19fa4447f9ae14e61203fe40b3-20180430 Received: from mtkcas06.mediatek.inc [(172.21.101.30)] by mailgw01.mediatek.com (envelope-from ) (mhqrelay.mediatek.com ESMTP with TLS) with ESMTP id 1376817255; Mon, 30 Apr 2018 20:15:35 +0800 Received: from mtkcas08.mediatek.inc (172.21.101.126) by mtkmbs08n1.mediatek.inc (172.21.101.55) with Microsoft SMTP Server (TLS) id 15.0.1210.3; Mon, 30 Apr 2018 20:15:33 +0800 Received: from mtkslt306.mediatek.inc (10.21.14.136) by mtkcas08.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1210.3 via Frontend Transport; Mon, 30 Apr 2018 20:15:32 +0800 From: Ryder Lee To: Mark Brown CC: Garlic Tseng , , , , , Ryder Lee Subject: [PATCH] ASoC: mediatek: add the .probe() callback in mt2701_afe_pcm_dai_component Date: Mon, 30 Apr 2018 20:15:31 +0800 Message-ID: <2bcfa1a389ff00a00204c2ddf3a94882195fd19d.1525090110.git.ryder.lee@mediatek.com> X-Mailer: git-send-email 1.9.1 MIME-Version: 1.0 Content-Type: text/plain X-MTK: N Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org For the sake of uniformity, this patch adds a callback mt2701_afe_pcm_probe() in mt2701_afe_pcm_dai_component to retrieve the regmap - the canonical way to obtain the pointer.. Doing so, we could switch to use devm_snd_soc_register_component() to register the component driver. Signed-off-by: Ryder Lee --- sound/soc/mediatek/mt2701/mt2701-afe-pcm.c | 31 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/sound/soc/mediatek/mt2701/mt2701-afe-pcm.c b/sound/soc/mediatek/mt2701/mt2701-afe-pcm.c index d6eeb4c..828d11c 100644 --- a/sound/soc/mediatek/mt2701/mt2701-afe-pcm.c +++ b/sound/soc/mediatek/mt2701/mt2701-afe-pcm.c @@ -958,7 +958,17 @@ static int mt2701_irq_fs(struct snd_pcm_substream *substream, unsigned int rate) { "O31", "I35 Switch", "I35" }, }; +static int mt2701_afe_pcm_probe(struct snd_soc_component *component) +{ + struct mtk_base_afe *afe = snd_soc_component_get_drvdata(component); + + snd_soc_component_init_regmap(component, afe->regmap); + + return 0; +} + static const struct snd_soc_component_driver mt2701_afe_pcm_dai_component = { + .probe = mt2701_afe_pcm_probe, .name = "mt2701-afe-pcm-dai", .dapm_widgets = mt2701_afe_pcm_widgets, .num_dapm_widgets = ARRAY_SIZE(mt2701_afe_pcm_widgets), @@ -1316,22 +1326,6 @@ static int mt2701_afe_runtime_resume(struct device *dev) return mt2701_afe_enable_clock(afe); } -static int mt2701_afe_add_component(struct mtk_base_afe *afe) -{ - struct snd_soc_component *component; - - component = kzalloc(sizeof(*component), GFP_KERNEL); - if (!component) - return -ENOMEM; - - component->regmap = afe->regmap; - - return snd_soc_add_component(afe->dev, component, - &mt2701_afe_pcm_dai_component, - mt2701_afe_pcm_dais, - ARRAY_SIZE(mt2701_afe_pcm_dais)); -} - static int mt2701_afe_pcm_dev_probe(struct platform_device *pdev) { struct mtk_base_afe *afe; @@ -1442,7 +1436,10 @@ static int mt2701_afe_pcm_dev_probe(struct platform_device *pdev) goto err_platform; } - ret = mt2701_afe_add_component(afe); + ret = devm_snd_soc_register_component(&pdev->dev, + &mt2701_afe_pcm_dai_component, + mt2701_afe_pcm_dais, + ARRAY_SIZE(mt2701_afe_pcm_dais)); if (ret) { dev_warn(dev, "err_dai_component\n"); goto err_platform; -- 1.9.1