From patchwork Mon Jun 11 05:15:58 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Katsuhiro Suzuki X-Patchwork-Id: 138196 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp3615967lji; Sun, 10 Jun 2018 22:16:09 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJo30AlLJg4kZ/74JCt0xyqv4diA6fbD3Xvunl+lyk4R0OLB1qJfKhs7IsBbS9uzRn/HeeA X-Received: by 2002:a63:a84f:: with SMTP id i15-v6mr13875136pgp.422.1528694169347; Sun, 10 Jun 2018 22:16:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528694169; cv=none; d=google.com; s=arc-20160816; b=ZHoJvX4bzw4+zp6ikj6gQpGigiDUa7V2q7XGryFXYiNEQNO86hHmSmC3niq2CuFnKi /IVKrBiXKeTIjkKxH6FDhq/XvfcwclEeJLx+uH0GpI1PuFUQGBn8qtHgnXzLfHKBE/3W N3a7GiaagLf/Ia/hJHBtfynmrDfZ8CGPUL/dJwrxe+K4nsbcALd/ah6+XGoOhEOB8E8r EnYD6gEGAuXt4t94/zJ5C9m8Y3m5+LcLM/Qm/0VItgZGLGWOr50F4Cf4/GfDJYN9nvx7 4s5nxnAGLz2qhqoybVAbQ7DRyYRxgn+GXZMFZkjUk6U5q8JjvO/+/b7RYkiE/KBdsS/k neUA== 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 t64-v6si14010953pfb.98.2018.06.10.22.16.09; Sun, 10 Jun 2018 22:16:09 -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 S1753989AbeFKFQF (ORCPT + 30 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(-) -- 2.17.1 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)) {