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: 207336 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id F1EB7C3524D for ; Mon, 3 Feb 2020 13:30:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C39AD20721 for ; Mon, 3 Feb 2020 13:30:35 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=bgdev-pl.20150623.gappssmtp.com header.i=@bgdev-pl.20150623.gappssmtp.com header.b="hHjJni+T" 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: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: 207335 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9B739C35247 for ; Mon, 3 Feb 2020 13:30:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7185520721 for ; Mon, 3 Feb 2020 13:30:46 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=bgdev-pl.20150623.gappssmtp.com header.i=@bgdev-pl.20150623.gappssmtp.com header.b="1QKDsrCa" 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)