Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp3643349imm; Sun, 10 Jun 2018 22:16:54 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKTyCMbPIfpKUTS7KcrqaS4mMKqc9HNbJaiXsDKWfBGc47RQRIBvMmd9dAzgjZE557hDvdH X-Received: by 2002:a62:3b5d:: with SMTP id i90-v6mr16203390pfa.24.1528694214009; Sun, 10 Jun 2018 22:16:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528694213; cv=none; d=google.com; s=arc-20160816; b=rdkwimDEqf+Ue749HNj7fZwJqCsPcdf75N9/UrX5ubTeLsRKJUTTyOBx0YSQvPBaW3 wsOkAUNMWnoGUh9rrVw4fiMygjDtU+JU+K02GMLLTqB4MmN8f0NScBb+UcoEI3P5VUZH 6cOo+uZn5AeC9ERjoH7E7LsVOFlx4ARTeRXlhjIUsBZPJFijHZKwu0DCFsXxhzA0Hd3A /YRTgAvqU37HA1dnKtpG3hOMc/qZkeMQZYYieX267oyFvdPPI6vyHP713QdVSFr/QqQ3 PgLYyPd2NMWtDOkGK4Ai9hymkYU48+km2GwDWowWnllS5b0LBuS/KwTrHYZ0ltRvwF0J nuTA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=rDY8H15rp8b9hDK7j12QEdugBcRW1scLGhczFAReINQ=; b=GYmuKLcvg/vCzYAj3qvky7xQ+iOU/5aDX2UU3RzGMPLSDRx9joJN3ySdDXD18bsx10 Zgs57DosrlvcpE+U1PA8kEGafCKvKC35YLzjPuTxXI3CMDpjI3lfcGit1v15bVpyEaY/ ZsCXMtzIqRn8oC1CT1HEsLulBtIyMn34brou9ke+eJGNst+XPfQMwRvEnKs3TGtOaVRg ZcJhjAQDbZTvx6sHJUvTCoqnhlRhTGnxXc0LkNDQfgTLjlHb7cN9k9krTNDUrKwmW9gj QVjpYyYDztAtQWwVhqJt0tC+JqoYDK4AcpZQjMgSq/W2QA2sDBcFzgCfHwRHbr6GE3d3 ectA== 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 m63-v6si59709734pld.429.2018.06.10.22.16.39; Sun, 10 Jun 2018 22:16:53 -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 S1753983AbeFKFQF (ORCPT + 99 others); Mon, 11 Jun 2018 01:16:05 -0400 Received: from mx.socionext.com ([202.248.49.38]:19718 "EHLO mx.socionext.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753909AbeFKFQD (ORCPT ); Mon, 11 Jun 2018 01:16:03 -0400 Received: from unknown (HELO iyokan-ex.css.socionext.com) ([172.31.9.54]) by mx.socionext.com with ESMTP; 11 Jun 2018 14:16:02 +0900 Received: from mail.mfilter.local (m-filter-1 [10.213.24.61]) by iyokan-ex.css.socionext.com (Postfix) with ESMTP id 2E7736006F; Mon, 11 Jun 2018 14:16:02 +0900 (JST) Received: from 172.31.9.53 (172.31.9.53) by m-FILTER with ESMTP; Mon, 11 Jun 2018 14:16:02 +0900 Received: from yuzu.css.socionext.com (yuzu [172.31.8.45]) by iyokan.css.socionext.com (Postfix) with ESMTP id C09A740389; Mon, 11 Jun 2018 14:16:01 +0900 (JST) Received: from aegis.e01.socionext.com (unknown [10.213.134.210]) by yuzu.css.socionext.com (Postfix) with ESMTP id 940B1120139; Mon, 11 Jun 2018 14:16:01 +0900 (JST) From: Katsuhiro Suzuki To: Kuninori Morimoto , Mark Brown , alsa-devel@alsa-project.org Cc: Masami Hiramatsu , Jassi Brar , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Katsuhiro Suzuki Subject: [PATCH v2 2/3] ASoC: simple-card: move hp and mic detection to soc_card probe Date: Mon, 11 Jun 2018 14:15:58 +0900 Message-Id: <20180611051559.18082-2-suzuki.katsuhiro@socionext.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180611051559.18082-1-suzuki.katsuhiro@socionext.com> References: <20180611051559.18082-1-suzuki.katsuhiro@socionext.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This patch moves headphone and microphone detection to probe() of snd_soc_card from init() of snd_soc_dai_link. This is because init() is called (and an input device /dev/input/eventX is created too) twice or above if simple card has two or more DAI links. Signed-off-by: Katsuhiro Suzuki --- Changes from v1: - Newly added --- sound/soc/generic/simple-card.c | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/sound/soc/generic/simple-card.c b/sound/soc/generic/simple-card.c index 1bbd9e46bf2a..9eb26ee06892 100644 --- a/sound/soc/generic/simple-card.c +++ b/sound/soc/generic/simple-card.c @@ -149,14 +149,6 @@ static int asoc_simple_card_dai_init(struct snd_soc_pcm_runtime *rtd) if (ret < 0) return ret; - ret = asoc_simple_card_init_hp(rtd->card, &priv->hp_jack, PREFIX); - if (ret < 0) - return ret; - - ret = asoc_simple_card_init_mic(rtd->card, &priv->mic_jack, PREFIX); - if (ret < 0) - return ret; - return 0; } @@ -350,6 +342,22 @@ static int asoc_simple_card_parse_of(struct simple_card_data *priv) return ret; } +static int asoc_simple_soc_card_probe(struct snd_soc_card *card) +{ + struct simple_card_data *priv = snd_soc_card_get_drvdata(card); + int ret; + + ret = asoc_simple_card_init_hp(card, &priv->hp_jack, NULL); + if (ret < 0) + return ret; + + ret = asoc_simple_card_init_mic(card, &priv->mic_jack, NULL); + if (ret < 0) + return ret; + + return 0; +} + static int asoc_simple_card_probe(struct platform_device *pdev) { struct simple_card_data *priv; @@ -385,6 +393,7 @@ static int asoc_simple_card_probe(struct platform_device *pdev) card->dev = dev; card->dai_link = priv->dai_link; card->num_links = num; + card->probe = asoc_simple_soc_card_probe; if (np && of_device_is_available(np)) { -- 2.17.1