Received: by 2002:a05:6a10:7420:0:0:0:0 with SMTP id hk32csp838374pxb; Wed, 16 Feb 2022 05:37:42 -0800 (PST) X-Google-Smtp-Source: ABdhPJyR19SR8jtWjICV4JW4qa6iSPsw5Fh7HXGxH2QggDPCbKZ3FUEDOJpCJyuJ9cx4Q+MXCpJr X-Received: by 2002:a17:906:3e84:b0:6cf:cd36:6316 with SMTP id a4-20020a1709063e8400b006cfcd366316mr2281110ejj.581.1645018662206; Wed, 16 Feb 2022 05:37:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645018662; cv=none; d=google.com; s=arc-20160816; b=us1fKKlJyTBHbSSWx5LE6a2m/v8OHrJcy4QViUHONTx6XjMGx1ev0NnyUOEn5Bf8mG j/+5ABuLSHYBBOw5Z5j+YElyUK4unKU72MVs1s7xNz4IwbmvuYxqZ0V/0KeSWRzudgzu An24oE5V4zQUCKv+W5xGnZRF7Qb/7ZWbiqJqw+yRZAHw0sYu4tOzYgRAs5fP+oRnSDRE IFT8fvf797MRVsyYz7D71HYv74aRG26yh5mXk3EUihjQDlpk4pka1TamyqqKgZe+SUq/ dPVNMnDQO7uESijzRQQI4U9yCPFeZtxkJJERbwSaBs75GOLvANSZ0IiSQ+fmrUCFUtld p3RQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:subject:cc:to:from :dkim-signature; bh=Nxttcr31p2W61Gm3SX8vHvFy59FlP2h71nyWJI7l0ak=; b=Uo8Ry6abjwyCOGQDtGKTLLZxm/tXshIVf2bku+nZtlmk/Wn8yfbrQ+ODdxIoa8u0R/ stp3p/cprbsxK6D2GYGKgiFSg7rr0i4SjXmzlNVS8ffkD4/PkRHnCKcReY1MveeMGiuO MRmHKNHQF5+HpurwRp2dHUg6K0LE4IEE5OC+DlW7PIPXy+h6tHYCFJWiXONTe2p7r28W S6SaEbe6BX2FvyuH4uXjkuNYrdpNar/u90vU07gC2WETlws6G6VUwYp/CGcUDm5qHDT2 DbKW0Hbh/U6p8r0jjQP0iK1ppaUAyKbIZ5KeuTfxJMkca7EeVjcaXUD6XPtoAoMhD8+S v6UQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcdkim header.b=Q3jmITkc; 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=quicinc.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id gk1si22225437ejc.868.2022.02.16.05.37.19; Wed, 16 Feb 2022 05:37:42 -0800 (PST) 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=@quicinc.com header.s=qcdkim header.b=Q3jmITkc; 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=quicinc.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233594AbiBPNZz (ORCPT + 99 others); Wed, 16 Feb 2022 08:25:55 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:35982 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234068AbiBPNZl (ORCPT ); Wed, 16 Feb 2022 08:25:41 -0500 Received: from alexa-out-sd-01.qualcomm.com (alexa-out-sd-01.qualcomm.com [199.106.114.38]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 767DC12779; Wed, 16 Feb 2022 05:25:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; i=@quicinc.com; q=dns/txt; s=qcdkim; t=1645017929; x=1676553929; h=from:to:cc:subject:date:message-id:mime-version; bh=Nxttcr31p2W61Gm3SX8vHvFy59FlP2h71nyWJI7l0ak=; b=Q3jmITkcMWC+vMnkK+I+xceHDqHx3vgGi6HM0jTCU7G3cRwS2r7h5ku2 9cS3RHVsKoEHWVfKdGeUrqGpZeZrrYBhlW8+0+BQCQDFlHI6AwaHLVPjR XUF6Z0kNbd0sxr3VJoZRqdsYkeGzKf8uo5vhx1vUXbx4gU7sF582LAbZy 0=; Received: from unknown (HELO ironmsg03-sd.qualcomm.com) ([10.53.140.143]) by alexa-out-sd-01.qualcomm.com with ESMTP; 16 Feb 2022 05:25:28 -0800 X-QCInternal: smtphost Received: from nasanex01c.na.qualcomm.com ([10.47.97.222]) by ironmsg03-sd.qualcomm.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Feb 2022 05:25:27 -0800 Received: from nalasex01a.na.qualcomm.com (10.47.209.196) by nasanex01c.na.qualcomm.com (10.47.97.222) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.15; Wed, 16 Feb 2022 05:25:26 -0800 Received: from hu-srivasam-hyd.qualcomm.com (10.80.80.8) by nalasex01a.na.qualcomm.com (10.47.209.196) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.922.19; Wed, 16 Feb 2022 05:25:20 -0800 From: Srinivasa Rao Mandadapu To: , , , , , , , , , , , , , , , , CC: Srinivasa Rao Mandadapu , "Venkata Prasad Potturu" Subject: [PATCH] ASoC: codec: wcd938x: Update CTIA/OMTP switch control Date: Wed, 16 Feb 2022 18:54:52 +0530 Message-ID: <1645017892-12522-1-git-send-email-quic_srivasam@quicinc.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nalasex01a.na.qualcomm.com (10.47.209.196) X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS,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 Convert gpio api's to gpio descriptor api's in CTIA/OMTP switch control. Remove redundant NULL checks in swap_gnd_mic function. Fixes: 013cc2aea0f6 ("ASoC: codec: wcd938x: Add switch control for selecting CTIA/OMTP Headset") Signed-off-by: Srinivasa Rao Mandadapu Co-developed-by: Venkata Prasad Potturu Signed-off-by: Venkata Prasad Potturu --- sound/soc/codecs/wcd938x.c | 33 +++++++++++---------------------- 1 file changed, 11 insertions(+), 22 deletions(-) diff --git a/sound/soc/codecs/wcd938x.c b/sound/soc/codecs/wcd938x.c index 08d16a9..88a39e1 100644 --- a/sound/soc/codecs/wcd938x.c +++ b/sound/soc/codecs/wcd938x.c @@ -6,6 +6,7 @@ #include #include #include +#include #include #include #include @@ -194,7 +195,7 @@ struct wcd938x_priv { int ear_rx_path; int variant; int reset_gpio; - int us_euro_gpio; + struct gpio_desc *us_euro_gpio; u32 micb1_mv; u32 micb2_mv; u32 micb3_mv; @@ -4203,22 +4204,11 @@ static bool wcd938x_swap_gnd_mic(struct snd_soc_component *component, bool activ struct wcd938x_priv *wcd938x; - if (!component) { - dev_err(component->dev, "%s component is NULL\n", __func__); - return false; - } - wcd938x = snd_soc_component_get_drvdata(component); - if (!wcd938x) { - dev_err(component->dev, "%s private data is NULL\n", __func__); - return false; - } - value = gpio_get_value(wcd938x->us_euro_gpio); + value = gpiod_get_value(wcd938x->us_euro_gpio); - gpio_set_value(wcd938x->us_euro_gpio, !value); - /* 20us sleep required after changing the gpio state*/ - usleep_range(20, 30); + gpiod_set_value(wcd938x->us_euro_gpio, !value); return true; } @@ -4236,16 +4226,15 @@ static int wcd938x_populate_dt_data(struct wcd938x_priv *wcd938x, struct device return wcd938x->reset_gpio; } - wcd938x->us_euro_gpio = of_get_named_gpio(dev->of_node, "us-euro-gpios", 0); - if (wcd938x->us_euro_gpio < 0) { - dev_err(dev, "Failed to get us-euro-gpios gpio: err = %d\n", wcd938x->us_euro_gpio); - } else { - cfg->swap_gnd_mic = wcd938x_swap_gnd_mic; - gpio_direction_output(wcd938x->us_euro_gpio, 0); - /* 20us sleep required after pulling the reset gpio to LOW */ - usleep_range(20, 30); + wcd938x->us_euro_gpio = devm_gpiod_get_optional(dev, "us-euro", + GPIOD_OUT_LOW); + if (IS_ERR(wcd938x->us_euro_gpio)) { + dev_err(dev, "us-euro swap Control GPIO not found\n"); + return PTR_ERR(wcd938x->us_euro_gpio); } + cfg->swap_gnd_mic = wcd938x_swap_gnd_mic; + wcd938x->supplies[0].supply = "vdd-rxtx"; wcd938x->supplies[1].supply = "vdd-io"; wcd938x->supplies[2].supply = "vdd-buck"; -- 2.7.4