From patchwork Mon Feb 3 13:30:24 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 1232774 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-gpio-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=bgdev.pl Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=bgdev-pl.20150623.gappssmtp.com header.i=@bgdev-pl.20150623.gappssmtp.com header.a=rsa-sha256 header.s=20150623 header.b=hHjJni+T; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 48B7xS2tzgz9sRt for ; Tue, 4 Feb 2020 00:30:36 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727311AbgBCNae (ORCPT ); Mon, 3 Feb 2020 08:30:34 -0500 Received: from mail-wr1-f66.google.com ([209.85.221.66]:43539 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727948AbgBCNae (ORCPT ); Mon, 3 Feb 2020 08:30:34 -0500 Received: by mail-wr1-f66.google.com with SMTP id z9so5918599wrs.10 for ; Mon, 03 Feb 2020 05:30:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=1f5bwMzVaB6wRo16QwdapcC/oluekqbfNJd6d0tVIEc=; b=hHjJni+TEKfxWEycbKNRTiT691geYQs4q46qUwNY1c6FnG6Rh757MTHBwgCgbC45/h EFR1bWidEOjlaPcGxP/Nf+/yp1DNqAhsj8Dxkch2EiAuZ3jXG+jPuS3HTh60/AnuUNaW qDwWXisqn6gbZBYkyrQZtx8jkm26KC547/ppdAHN7lndwBfQYFiKFDduVwLo89MZRYhO 81epeNGx85akoRGsibe+xj+a+EVow+yQbPp8IGDth/UDp+2qkHbo3aa9yMK03sqDjXfI FfCN5GkMi2I5D6b8P+Pn8uqk2frmHjgPzpVOCkkxVjztBHMRas3WuF2TueQWxcvEfSyN RaiQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=1f5bwMzVaB6wRo16QwdapcC/oluekqbfNJd6d0tVIEc=; b=sio+pYErBmnRIvnSa8FjlZ/xfAs03qBw3Okf3ybQBNLU9jRII7XlhgQnNq3sq7kLs+ Bc3uxm1cCFaEqxh9pDuPF3FZLqESm2qLAwWATTofUND8rf/j5v5OLYIDCBNuD+PIRTJf 0fyI/dZJbbHJKhGhd2RANTPTSP6nMC8dItPXQtxOD+rKF0J2fOp3TeefE0ukUohIMsjP XH9Qy8UzpDDMVGnVu3IYS9Xr6yg1hVpJtCGm/LAM2bWYtyxXDPr6zeQJa4gVkUm2s8Rp Qm9KuD1SnHITVFfswCED/GKgKvZfQCTpRVuO/Bwjykfe07ayJ8JjoYJxw/nq37i99mpO c1Cg== X-Gm-Message-State: APjAAAWreRHx/uKEWcr1w6HxIdcqxgvzIW43A/MGsn6pM0yb0o1pJTBj x/TLdZzlBzyLMhKcdUOoUZrk3g== X-Google-Smtp-Source: APXvYqwihlTRAqU8L8rfD0ugl/hZaBWyHcy/FdrAqB8p6pd6Yd/bh6D5rLLXZ7T4GAbg+1ckLg6yew== X-Received: by 2002:adf:eacb:: with SMTP id o11mr16579664wrn.128.1580736632030; Mon, 03 Feb 2020 05:30:32 -0800 (PST) Received: from localhost.localdomain (lfbn-nic-1-505-157.w90-116.abo.wanadoo.fr. [90.116.92.157]) by smtp.gmail.com with ESMTPSA id l8sm7594540wmj.2.2020.02.03.05.30.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Feb 2020 05:30:31 -0800 (PST) From: Bartosz Golaszewski To: Kent Gibson , Linus Walleij , Andy Shevchenko , Greg Kroah-Hartman , Guenter Roeck , Geert Uytterhoeven Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, Bartosz Golaszewski Subject: [PATCH 1/3] Revert "gpiolib: Remove duplicated function gpio_do_set_config()" Date: Mon, 3 Feb 2020 14:30:24 +0100 Message-Id: <20200203133026.22930-2-brgl@bgdev.pl> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20200203133026.22930-1-brgl@bgdev.pl> References: <20200203133026.22930-1-brgl@bgdev.pl> MIME-Version: 1.0 Sender: linux-gpio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org From: Bartosz Golaszewski This reverts commit d18fddff061d2796525e6d4a958cb3d30aed8efd. This patch came on top of another patch that introduced a regression. Revert it before addressing the culprit. Signed-off-by: Bartosz Golaszewski --- drivers/gpio/gpiolib.c | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index 99ac27a72e28..0673daeaca00 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -3035,8 +3035,8 @@ EXPORT_SYMBOL_GPL(gpiochip_free_own_desc); * rely on gpio_request() having been called beforehand. */ -static int gpio_set_config(struct gpio_chip *gc, unsigned int offset, - enum pin_config_param mode) +static int gpio_do_set_config(struct gpio_chip *gc, unsigned int offset, + enum pin_config_param mode) { if (!gc->set_config) return -ENOTSUPP; @@ -3044,6 +3044,25 @@ static int gpio_set_config(struct gpio_chip *gc, unsigned int offset, return gc->set_config(gc, offset, mode); } +static int gpio_set_config(struct gpio_chip *gc, unsigned int offset, + enum pin_config_param mode) +{ + unsigned arg; + + switch (mode) { + case PIN_CONFIG_BIAS_DISABLE: + case PIN_CONFIG_BIAS_PULL_DOWN: + case PIN_CONFIG_BIAS_PULL_UP: + arg = 1; + break; + + default: + arg = 0; + } + + return gpio_do_set_config(gc, offset, mode); +} + static int gpio_set_bias(struct gpio_chip *chip, struct gpio_desc *desc) { int bias = 0; @@ -3277,7 +3296,7 @@ int gpiod_set_debounce(struct gpio_desc *desc, unsigned debounce) chip = desc->gdev->chip; config = pinconf_to_config_packed(PIN_CONFIG_INPUT_DEBOUNCE, debounce); - return gpio_set_config(chip, gpio_chip_hwgpio(desc), config); + return gpio_do_set_config(chip, gpio_chip_hwgpio(desc), config); } EXPORT_SYMBOL_GPL(gpiod_set_debounce); @@ -3311,7 +3330,7 @@ int gpiod_set_transitory(struct gpio_desc *desc, bool transitory) packed = pinconf_to_config_packed(PIN_CONFIG_PERSIST_STATE, !transitory); gpio = gpio_chip_hwgpio(desc); - rc = gpio_set_config(chip, gpio, packed); + rc = gpio_do_set_config(chip, gpio, packed); if (rc == -ENOTSUPP) { dev_dbg(&desc->gdev->dev, "Persistence not supported for GPIO %d\n", gpio); From patchwork Mon Feb 3 13:30:25 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 1232775 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-gpio-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=bgdev.pl Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=bgdev-pl.20150623.gappssmtp.com header.i=@bgdev-pl.20150623.gappssmtp.com header.a=rsa-sha256 header.s=20150623 header.b=LZqE8iUr; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 48B7xf4kBJz9sRm for ; Tue, 4 Feb 2020 00:30:46 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728012AbgBCNaf (ORCPT ); Mon, 3 Feb 2020 08:30:35 -0500 Received: from mail-wr1-f66.google.com ([209.85.221.66]:40588 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727872AbgBCNaf (ORCPT ); Mon, 3 Feb 2020 08:30:35 -0500 Received: by mail-wr1-f66.google.com with SMTP id j104so18130729wrj.7 for ; Mon, 03 Feb 2020 05:30:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=x1xJqaqAPEC794SAD7Tt6YXPm/qB2065vemTtgGyHK8=; b=LZqE8iUrg07qQSSghcH6r2uhuQys1bYFFy08ATpEC7Et1fhYnaKAZj6SzReNq2FN/s FSQ2z2IAojwof95jzWFXS2sEnF37ErJCWjQ+cq3OXp0PZ+lj2m7grzm5LAWlYnsfNlAX zA0jYiTWqpk3UlfrcqMGUjeeZ35uL0iQu6x/yYah/08bvCEa1yYtIFhlVe5kyp3u1wRg jDGhEbAf5tbLch8TSeD9E1kl4p0jLAaD/EA3JFIEfAWlVG+9SaKLbbsrkLvN1dsRyndd HhG+vwWPd0PYornZtWaJHlVhkvtXylne1iWlo4dYjUrvEHzLoGD/ehkCNCLM6LeydD0o yJgg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=x1xJqaqAPEC794SAD7Tt6YXPm/qB2065vemTtgGyHK8=; b=EqocFMLqyuiUUJBrak1VEcV3kxn/acLvNNaqKcsW3CGF3zwEbha2qy4SXApqI53VGS 70jNsmuR2SzmlJCGkJvTS1yOJ10WKrtYYgThaf7DhQqJkHOKCEBep1E3K9nT0pfHgpuB cuMhP4Hnhm9nFjA18Ydviy5l+3Pdwq9/Jjw3F4ESu4ePrrre6DPA2LkM/iAA+E56wJD+ BIlRuXGu2amibh+PZc7cWHoW2ctnQ/56cgcSYbw9QqBHnETdKZUNVTKdOL+LaEgoJmhu BfFCuk0V+DUA55tJX6eRA79stlGRwJ4Kna+iK3yA5HU7RRYR+nynw1V104eHSn5hlQJk JK/g== X-Gm-Message-State: APjAAAVsqXV3NExHJ5RGtsM678EGBqg+XW3DeJj3qcq46XwoMtFEBpcB jmzgUgPFl8IjdBhui3POCX3voA== X-Google-Smtp-Source: APXvYqwpb5h+57G+AaJyFbBjUKenLrDEE6o8zM17QKKlB6PXdRXabKQvPh2C4N8tVfrcI4GjOGMY5w== X-Received: by 2002:adf:fe83:: with SMTP id l3mr11550295wrr.41.1580736633291; Mon, 03 Feb 2020 05:30:33 -0800 (PST) Received: from localhost.localdomain (lfbn-nic-1-505-157.w90-116.abo.wanadoo.fr. [90.116.92.157]) by smtp.gmail.com with ESMTPSA id l8sm7594540wmj.2.2020.02.03.05.30.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Feb 2020 05:30:32 -0800 (PST) From: Bartosz Golaszewski To: Kent Gibson , Linus Walleij , Andy Shevchenko , Greg Kroah-Hartman , Guenter Roeck , Geert Uytterhoeven Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, Bartosz Golaszewski Subject: [PATCH 2/3] Revert "gpiolib: remove set but not used variable 'config'" Date: Mon, 3 Feb 2020 14:30:25 +0100 Message-Id: <20200203133026.22930-3-brgl@bgdev.pl> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20200203133026.22930-1-brgl@bgdev.pl> References: <20200203133026.22930-1-brgl@bgdev.pl> MIME-Version: 1.0 Sender: linux-gpio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org From: Bartosz Golaszewski This reverts commit e5e42ad224a040f93bf112e96f82b3a0ed97ffab. This patch came on top of another patch that introduced a regression. Revert it before addressing the culprit. Signed-off-by: Bartosz Golaszewski --- drivers/gpio/gpiolib.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index 0673daeaca00..13982056c14e 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -3047,6 +3047,7 @@ static int gpio_do_set_config(struct gpio_chip *gc, unsigned int offset, static int gpio_set_config(struct gpio_chip *gc, unsigned int offset, enum pin_config_param mode) { + unsigned long config; unsigned arg; switch (mode) { @@ -3060,6 +3061,7 @@ static int gpio_set_config(struct gpio_chip *gc, unsigned int offset, arg = 0; } + config = PIN_CONF_PACKED(mode, arg); return gpio_do_set_config(gc, offset, mode); } From patchwork Mon Feb 3 13:30:26 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 1232776 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-gpio-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=bgdev.pl Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=bgdev-pl.20150623.gappssmtp.com header.i=@bgdev-pl.20150623.gappssmtp.com header.a=rsa-sha256 header.s=20150623 header.b=1QKDsrCa; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 48B7xg2jybz9sPK for ; Tue, 4 Feb 2020 00:30:47 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727450AbgBCNap (ORCPT ); Mon, 3 Feb 2020 08:30:45 -0500 Received: from mail-wm1-f65.google.com ([209.85.128.65]:39926 "EHLO mail-wm1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727948AbgBCNaf (ORCPT ); Mon, 3 Feb 2020 08:30:35 -0500 Received: by mail-wm1-f65.google.com with SMTP id c84so17079926wme.4 for ; Mon, 03 Feb 2020 05:30:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=lLtMqSU8FnRsT2MznAhbMw8rQbBTInq5OoP1ERtOceE=; b=1QKDsrCaCPaOPwzfA0FDJLinhHQzKsaIXL3gF8PGxysnLGvwAgNZkJ7H39PuQ4Rya3 BRjQiBg2Jn3kdyv9rjI9uADsD98t2ZIGLF8ZCW1+c04Ex4lHnjwOEvdkoVQpKeaF3isj wIbnVw3VBV9lbZ9i76GLrWga9xj0dJiYvrOCU6ASeTzMdCXmu5dqC0aZe1mGayAadrx2 eU+u345NVa9skEcz7x4bxfUi/nayVfdxY26cyqGLxTcLGTXNvRhpPcNfzCU742nWGoF3 VS0dRw5uFIMMd28SDMDJz15qClXcCOS6fyf43fU0zdbLJtdC/SGojLjYktlLNXErLnI9 9SNA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=lLtMqSU8FnRsT2MznAhbMw8rQbBTInq5OoP1ERtOceE=; b=Qtf4AVHD7j9dQH4mkY2u62m6WzfxKh/V0dFQYA8xjsrTjNxn/jOdixJ9D3pJ9mCp2N HbbyoMOnbGkB/CInLnncxUiLKOzBI4zK+qpOPe3N4TyK9UhAjW7zE6KQqY00+WsgXn0i NwjtX/6yDL6g0r+1EDaM1ggjA+ex2Ek7+Mo5dxUOdM7qGWzapnU7xEHPG1eK+9qaIAy8 Pz7VwteCBKNLkjKBHBxuoO8IigrgnMG1Z0Z2W4+hip0DlA7TF/gvzr9MLQ6MY4kRwwgk 4k2kS6OVbUpPigg4l0WrCGPFcSM0HnpZgIHuJzjaqoJmspDY/2NB4mRbToYTxNDA/ZWn 7cEA== X-Gm-Message-State: APjAAAVxPGT34xlsANpX9VT1w92cVcJZisVCrheRWZGi2rXuvg3f6Swb mco9bXXKpjgybYaqSSspk0Znxg== X-Google-Smtp-Source: APXvYqy0ibNKoyqFGzrTQe7H1FcOYKrZp2jxqp0RBHxgKiXqgpIsqzORUmM5PumAbk2EDiaMVY3zeQ== X-Received: by 2002:a1c:e246:: with SMTP id z67mr30878623wmg.52.1580736634354; Mon, 03 Feb 2020 05:30:34 -0800 (PST) Received: from localhost.localdomain (lfbn-nic-1-505-157.w90-116.abo.wanadoo.fr. [90.116.92.157]) by smtp.gmail.com with ESMTPSA id l8sm7594540wmj.2.2020.02.03.05.30.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Feb 2020 05:30:33 -0800 (PST) From: Bartosz Golaszewski To: Kent Gibson , Linus Walleij , Andy Shevchenko , Greg Kroah-Hartman , Guenter Roeck , Geert Uytterhoeven Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, Bartosz Golaszewski Subject: [PATCH 3/3] gpiolib: fix gpio_do_set_config() Date: Mon, 3 Feb 2020 14:30:26 +0100 Message-Id: <20200203133026.22930-4-brgl@bgdev.pl> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20200203133026.22930-1-brgl@bgdev.pl> References: <20200203133026.22930-1-brgl@bgdev.pl> MIME-Version: 1.0 Sender: linux-gpio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org From: Bartosz Golaszewski Commit d90f36851d65 ("gpiolib: have a single place of calling set_config()") introduced a regression where we don't pass the right variable as argument to the set_config() callback of gpio driver from gpio_set_config(). After reverting two additional patches that came on top of it - this addresses the issue by changing the type of the last argument of gpio_do_set_config() to unsigned long and making sure the packed config variable is actually used in gpio_set_config(). Fixes: d90f36851d65 ("gpiolib: have a single place of calling set_config()") Signed-off-by: Bartosz Golaszewski --- drivers/gpio/gpiolib.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index 13982056c14e..760ae0707c01 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -3036,12 +3036,12 @@ EXPORT_SYMBOL_GPL(gpiochip_free_own_desc); */ static int gpio_do_set_config(struct gpio_chip *gc, unsigned int offset, - enum pin_config_param mode) + unsigned long config) { if (!gc->set_config) return -ENOTSUPP; - return gc->set_config(gc, offset, mode); + return gc->set_config(gc, offset, config); } static int gpio_set_config(struct gpio_chip *gc, unsigned int offset, @@ -3062,7 +3062,7 @@ static int gpio_set_config(struct gpio_chip *gc, unsigned int offset, } config = PIN_CONF_PACKED(mode, arg); - return gpio_do_set_config(gc, offset, mode); + return gpio_do_set_config(gc, offset, config); } static int gpio_set_bias(struct gpio_chip *chip, struct gpio_desc *desc)