Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp1112649ybh; Sat, 7 Mar 2020 19:16:11 -0800 (PST) X-Google-Smtp-Source: ADFU+vuSmeqR93nxaPAutV/ek2vQQgkmCYptMEB0ylcqhIUjjbnoLomzFTy9HQxXNEv+AlA4bToc X-Received: by 2002:aca:c256:: with SMTP id s83mr7610086oif.57.1583637370941; Sat, 07 Mar 2020 19:16:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1583637370; cv=none; d=google.com; s=arc-20160816; b=iyV5+0gclFtm2FsouMV/VFnqWZOfpJibgsnU8sEk8zzEjpEHWmdF/RKhp/f53FkYh6 DNiQOL7QzNpirJn8n1vXyEajBsMD/Tq6/IZbrICquI77sjd/lS2h+SEsi4HDMG1ipPRC JTuiKsOBcvRdi4KGyRzsMZEkUTfdXx+NZf2RPm8coXfGYxyJJ/I6OoDww6Yc7eFXZp2y JppiFdDmsZfKlZEN4Iwfh8VFJhwVz3tJVO2JFBEU2vPjXJNFWCUh4ung3W0JW6/U4EVb y++sl2yM1L2o8m+wwX8InnZ5tAxK+w6IhxibJE5mUEJNDO04iqSfxttuI65QYT46QoqD Mvpw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=P3MWlYBXIHOYXSurE8bYVuhugk/qLdfGzqVhDThULfQ=; b=iXK7ftdUTqhf840r6M1YIvk82h0PBGr2QIWZcrSKB8VxO4i94g69KY0RBE4wFAUm6O jb9civJ1rtvtZzP5KZXjxi3Y1brTD/+fcxCicpyTp/qJuZnC7GE9GlCVsaW6IO4Dgtrp 1fzipLQrLxKwqEuDTobw5GMTNJ8RIsIYY8fzK37eJHRaFFK3mFSewnQuLrTJl5P8gXkC 7pNO2chiUj9okLjOgfv2JxRbFT+EtkvqOwSImtj+ulqP7ZivOuDfJPIPKRZOpCmCvAEM n4zLh0Ob57YdZLxey7tjoorfyC2eUkTdeqiw2Jn3bvLqoIN4KX3m2t9WcRFvfZO1h4Ir u9wQ== 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 193si2201703oie.51.2020.03.07.19.15.59; Sat, 07 Mar 2020 19:16:10 -0800 (PST) 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 S1726296AbgCHDOh (ORCPT + 99 others); Sat, 7 Mar 2020 22:14:37 -0500 Received: from mail.manjaro.org ([176.9.38.148]:57762 "EHLO mail.manjaro.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726138AbgCHDOh (ORCPT ); Sat, 7 Mar 2020 22:14:37 -0500 Received: from localhost (localhost [127.0.0.1]) by mail.manjaro.org (Postfix) with ESMTP id 1B65E39611CC; Sun, 8 Mar 2020 04:14:36 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at manjaro.org Received: from mail.manjaro.org ([127.0.0.1]) by localhost (manjaro.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id tbktZ9oDShq1; Sun, 8 Mar 2020 04:14:33 +0100 (CET) From: Tobias Schramm To: Jaroslav Kysela , Takashi Iwai Cc: Liam Girdwood , alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, Tobias Schramm Subject: [RFC PATCH 1/1] ASoC: jack: use gpiolib inversion flag for inverted gpios Date: Sun, 8 Mar 2020 04:13:55 +0100 Message-Id: <20200308031355.1149173-2-t.schramm@manjaro.org> In-Reply-To: <20200308031355.1149173-1-t.schramm@manjaro.org> References: <20200308031355.1149173-1-t.schramm@manjaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This commit changes the handling of jack gpios with ACTIVE_LOW logic. The inversion flag is now passed down and transparently handled by the legacy gpiolib. Previously the level of a gpio was inverted manually inside snd_soc_jack_gpio_detect and gpiolib ACTIVE_LOW flag was not set on the gpio. This resulted in erroneous output in /dev/class/gpio/gpio*/active_low and debug interfaces like /sys/kernel/debug/gpio where the gpio was still listed as active high while jack status for that gpio actually followed an active low logic. Signed-off-by: Tobias Schramm --- sound/soc/soc-jack.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/sound/soc/soc-jack.c b/sound/soc/soc-jack.c index b5748dcd490f..8c17cfdbb883 100644 --- a/sound/soc/soc-jack.c +++ b/sound/soc/soc-jack.c @@ -254,8 +254,6 @@ static void snd_soc_jack_gpio_detect(struct snd_soc_jack_gpio *gpio) int report; enable = gpiod_get_value_cansleep(gpio->desc); - if (gpio->invert) - enable = !enable; if (enable) report = gpio->report; @@ -385,6 +383,10 @@ int snd_soc_jack_add_gpios(struct snd_soc_jack *jack, int count, } } else { /* legacy GPIO number */ + int flags = GPIOF_IN; + + if (gpios[i].invert) + flags |= GPIOF_ACTIVE_LOW; if (!gpio_is_valid(gpios[i].gpio)) { dev_err(jack->card->dev, "ASoC: Invalid gpio %d\n", @@ -393,7 +395,7 @@ int snd_soc_jack_add_gpios(struct snd_soc_jack *jack, int count, goto undo; } - ret = gpio_request_one(gpios[i].gpio, GPIOF_IN, + ret = gpio_request_one(gpios[i].gpio, flags, gpios[i].name); if (ret) goto undo; -- 2.24.1