From patchwork Tue Nov 5 13:10:54 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matti Vaittinen X-Patchwork-Id: 1191023 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 477z9L2NYNz9sP6 for ; Thu, 7 Nov 2019 20:48:06 +1100 (AEDT) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=fi.rohmeurope.com Received: from bilbo.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 477z9L1Kl8zF22J for ; Thu, 7 Nov 2019 20:48:06 +1100 (AEDT) X-Original-To: linux-aspeed@lists.ozlabs.org Delivered-To: linux-aspeed@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gmail.com (client-ip=209.85.167.67; helo=mail-lf1-f67.google.com; envelope-from=mazziesaccount@gmail.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=fi.rohmeurope.com Received: from mail-lf1-f67.google.com (mail-lf1-f67.google.com [209.85.167.67]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 476qmd6Mz7zF4vl for ; Wed, 6 Nov 2019 00:11:13 +1100 (AEDT) Received: by mail-lf1-f67.google.com with SMTP id f5so15094491lfp.1 for ; Tue, 05 Nov 2019 05:11:13 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=l8Im5R3FQ0f+QIAnNwvzY4o+9bLtjTOzR+ED97CX0bQ=; b=lTEkYfJ2CLnC8J7PUTg+TcjArJ2alTMaHO4XY50QFPgSpajKRfJKOT+XxuPXxsbLiz Ef68CNdIQONQZ/T9Ogh/vh0LTBIIG0G/HEBl0T8J2N1M29Ud/ac7wFA4NLF/e/TdqDnN Vra8+FIzceO4oZjG4vBNbrt1+1dwoiGJnu/nWwkV1ggsFMy9pVuJdchVETJr81pm7Qh7 wShWM1r8T1AsSun7e011NY0F/Fx6OmDih9hr2/VK/5g9AgG9BrOkF9DWEpKvt+sqM1oH IC7qNCwGlUTaNPvkw9rV4KHsMJ/zJiMsfSXfJJmgKIZlzwa5h5bqpcqC/E9cibADcO7X xY/g== X-Gm-Message-State: APjAAAUtowFpoTxPOcmxECAUe0N5+s+vg+rmZR2nu+Zk1mtPu/BLLeM2 Dz+mxJWWqHxzRdEtqFcz0eA= X-Google-Smtp-Source: APXvYqxG8YUAy+DwKkIGY9cWv77NiqqeBDme3G0xG3YGsXTNlOyWrcCj6kB+mRP7VfBCxP+SG4zG9Q== X-Received: by 2002:a19:5010:: with SMTP id e16mr7124449lfb.49.1572959468332; Tue, 05 Nov 2019 05:11:08 -0800 (PST) Received: from localhost.localdomain ([213.255.186.46]) by smtp.gmail.com with ESMTPSA id z22sm8538198ljm.92.2019.11.05.05.11.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Nov 2019 05:11:07 -0800 (PST) Date: Tue, 5 Nov 2019 15:10:54 +0200 From: Matti Vaittinen To: matti.vaittinen@fi.rohmeurope.com, mazziesaccount@gmail.com Subject: [RESEND PATCH 01/62] gpio: Add definition for GPIO direction Message-ID: <9e233d62cc282f3b03196d638f2188d9ab394b75.1572875541.git.matti.vaittinen@fi.rohmeurope.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.12.1 (2019-06-15) X-Mailman-Approved-At: Thu, 07 Nov 2019 20:47:02 +1100 X-BeenThere: linux-aspeed@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux ASPEED SoC development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Semi Malinen , Kuppuswamy Sathyanarayanan , linux-aspeed@lists.ozlabs.org, David Daney , Linus Walleij , alsa-devel@alsa-project.org, Peter Tyser , Thierry Reding , Jonathan Hunter , Fabio Estevam , linux-stm32@st-md-mailman.stormreply.com, Marek Vasut , Florian Fainelli , Kevin Hilman , Michal Simek , Marek Behun , Bartosz Golaszewski , Ludovic Desroches , bcm-kernel-feedback-list@broadcom.com, Uwe =?iso-8859-1?q?Kleine-K=F6n?= =?iso-8859-1?q?ig?= , Bamvor Jian Zhang , NXP Linux Team , linux-pwm@vger.kernel.org, Grygorii Strashko , Charles Keepax , Maxime Coquelin , linux-omap@vger.kernel.org, Alexandre Torgue , Ray Jui , Sascha Hauer , Nandor Han , William Breathitt Gray , linux-gpio@vger.kernel.org, Richard Fitzgerald , Santosh Shilimkar , linux-tegra@vger.kernel.org, Andy Shevchenko , linux-arm-kernel@lists.infradead.org, Scott Branden , Masahiro Yamada , "Enrico Weigelt, metux IT consult" , linux-kernel@vger.kernel.org, linux-renesas-soc@vger.kernel.org, Thorsten Scherer , Pengutronix Kernel Team , patches@opensource.cirrus.com, Shawn Guo Errors-To: linux-aspeed-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Linux-aspeed" At least for me it is difficult to remember the meaning of GPIO direction values. Define GPIO_LINE_DIRECTION_IN and GPIO_LINE_DIRECTION_OUT so that occasional GPIO contributors would not need to always check the meaning of hard coded values 1 and 0. Signed-off-by: Matti Vaittinen --- Sorry for folks. I do resend this single patch as this was intended to be sent for _all_ reviewers. I accidentally did originally send this only to those the get_maintainer.py listed for this patch. include/linux/gpio/driver.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/include/linux/gpio/driver.h b/include/linux/gpio/driver.h index 5dd9c982e2cb..cc9ade4552d9 100644 --- a/include/linux/gpio/driver.h +++ b/include/linux/gpio/driver.h @@ -22,6 +22,9 @@ enum gpio_lookup_flags; struct gpio_chip; +#define GPIO_LINE_DIRECTION_IN 1 +#define GPIO_LINE_DIRECTION_OUT 0 + /** * struct gpio_irq_chip - GPIO interrupt controller */ From patchwork Tue Nov 5 10:12:30 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matti Vaittinen X-Patchwork-Id: 1191021 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 477z8s5K2Wz9sP6 for ; Thu, 7 Nov 2019 20:47:41 +1100 (AEDT) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=fi.rohmeurope.com Received: from bilbo.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 477z8s4HxSzF6KD for ; Thu, 7 Nov 2019 20:47:41 +1100 (AEDT) X-Original-To: linux-aspeed@lists.ozlabs.org Delivered-To: linux-aspeed@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gmail.com (client-ip=209.85.208.193; helo=mail-lj1-f193.google.com; envelope-from=mazziesaccount@gmail.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=fi.rohmeurope.com Received: from mail-lj1-f193.google.com (mail-lj1-f193.google.com [209.85.208.193]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 476lph1XlBzF4f9 for ; Tue, 5 Nov 2019 21:12:43 +1100 (AEDT) Received: by mail-lj1-f193.google.com with SMTP id e9so7817366ljp.13 for ; Tue, 05 Nov 2019 02:12:43 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=V7qLFq4K93vUH8fK9wNC+b3dmkN6TfhoYmCQsWeu7yY=; b=FpvN0z5SKOPBwP9+myBBtZafhnJZbkVw94+CmFB952J4VPVZ5jqzipoHLSQZ+HQu3M IzNE7+5KtBzM63QeDre3Xuf0aW920TZ66JwyS+RAS39k+zrD8HvSGj5k/H0m+9yGo07a u6taXydBu6K6cu0MKd380K6cF9zIriK80ZW/5QhCCyqcsCxRpRf47K6NMFIz51WKj13X JCJyp2o7XgsotTM1i6OzJlccFx+aOnHMcUqwIU6ikfuiKqG7tS278tFHiRvp26ZRv2mf M5RBpliRde/HR/hqiWyxamDJJZbiREgQJIuVLITDCbh394PvwE1w+zlsDq6EfOdJq+XH rCyQ== X-Gm-Message-State: APjAAAV0XbtF88na8aosWRt+PYxXCpamzyGVaygQJK4cfHD7TtPxvIBv dwlUy3eJCnX+XwMhUU7HjOQ= X-Google-Smtp-Source: APXvYqwjjYsGhWJv9rnRxQZ46vKzy4j+wiUPekzGtjMuNsXdHE3646nl8SjkCccQfYCbSzyJz8M77w== X-Received: by 2002:a2e:28a:: with SMTP id y10mr20290638lje.155.1572948760228; Tue, 05 Nov 2019 02:12:40 -0800 (PST) Received: from localhost.localdomain ([213.255.186.46]) by smtp.gmail.com with ESMTPSA id k9sm1362903lfj.97.2019.11.05.02.12.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Nov 2019 02:12:39 -0800 (PST) Date: Tue, 5 Nov 2019 12:12:30 +0200 From: Matti Vaittinen To: matti.vaittinen@fi.rohmeurope.com, mazziesaccount@gmail.com Subject: [PATCH 07/62] gpio: gpio-aspeed: Use new GPIO_LINE_DIRECTION Message-ID: <493e2f9ed5aff112519adcdf2d3044bf54c2d91a.1572945709.git.matti.vaittinen@fi.rohmeurope.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.12.1 (2019-06-15) X-Mailman-Approved-At: Thu, 07 Nov 2019 20:47:02 +1100 X-BeenThere: linux-aspeed@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux ASPEED SoC development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-aspeed@lists.ozlabs.org, linux-gpio@vger.kernel.org, Linus Walleij , linux-kernel@vger.kernel.org, Bartosz Golaszewski , linux-arm-kernel@lists.infradead.org Errors-To: linux-aspeed-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Linux-aspeed" It's hard for occasional GPIO code reader/writer to know if values 0/1 equal to IN or OUT. Use defined GPIO_LINE_DIRECTION_IN and GPIO_LINE_DIRECTION_OUT to help them out. Signed-off-by: Matti Vaittinen Reviewed-by: Andrew Jeffery --- drivers/gpio/gpio-aspeed.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/gpio/gpio-aspeed.c b/drivers/gpio/gpio-aspeed.c index 09e53c5f3b0a..f1037b61f763 100644 --- a/drivers/gpio/gpio-aspeed.c +++ b/drivers/gpio/gpio-aspeed.c @@ -487,10 +487,10 @@ static int aspeed_gpio_get_direction(struct gpio_chip *gc, unsigned int offset) u32 val; if (!have_input(gpio, offset)) - return 0; + return GPIO_LINE_DIRECTION_OUT; if (!have_output(gpio, offset)) - return 1; + return GPIO_LINE_DIRECTION_IN; spin_lock_irqsave(&gpio->lock, flags); @@ -498,8 +498,7 @@ static int aspeed_gpio_get_direction(struct gpio_chip *gc, unsigned int offset) spin_unlock_irqrestore(&gpio->lock, flags); - return !val; - + return val ? GPIO_LINE_DIRECTION_OUT : GPIO_LINE_DIRECTION_IN; } static inline int irqd_to_aspeed_gpio_data(struct irq_data *d, From patchwork Tue Nov 5 10:42:21 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matti Vaittinen X-Patchwork-Id: 1191022 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 477z8y5Qpdz9sP6 for ; Thu, 7 Nov 2019 20:47:46 +1100 (AEDT) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=fi.rohmeurope.com Received: from bilbo.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 477z8y33BCzF6KJ for ; Thu, 7 Nov 2019 20:47:46 +1100 (AEDT) X-Original-To: linux-aspeed@lists.ozlabs.org Delivered-To: linux-aspeed@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gmail.com (client-ip=209.85.208.194; helo=mail-lj1-f194.google.com; envelope-from=mazziesaccount@gmail.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=fi.rohmeurope.com Received: from mail-lj1-f194.google.com (mail-lj1-f194.google.com [209.85.208.194]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 476mT43jwzzF4tJ for ; Tue, 5 Nov 2019 21:42:32 +1100 (AEDT) Received: by mail-lj1-f194.google.com with SMTP id y3so21242806ljj.6 for ; Tue, 05 Nov 2019 02:42:32 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=zJQtw6WsLKIdVwDZMV0Pz6fU4JFtWwFkbgS9iv+/IOA=; b=nMviDITHO1jfvXdT+fq282M2nB3myokay5E6vuH1Fq1ogqFQ7OWhady2FM75jbMAxB RGluvTzPnKgKWhEaFUpR5Ka5Sxv15BPT6t87f7SUBRHAdArMY115UqtelHvZoeAh+HvH Jarw0K2uqnp/xMAU4anobNbSeOcZQcMyaDYFHfEo/04xS3iryF8kwnzi/Gb+CeiRp+oj f6TfzHTSgZwsyTPUJrJf38xOYRWseuBPkxSq2p7ihOc+hTG4IHdgsngrKDUG0J4hnylJ AJNY0xkSCnH9Vx8X5mRmYtLxZju1pZPdV/l6eGmA2H8+ipNXJpfuJbKb5LdVVlQ6Qw7f RuaQ== X-Gm-Message-State: APjAAAUQuq1nRPhNiKOofoq0mvnDzGqBpES/B7xoX8NMlLWyCUQNRa2s +T82Ju4R6StZFCs+5kwd2Xw= X-Google-Smtp-Source: APXvYqwOFSWIOcTngdfrUrZTLUT1vT2lZ4x7hyEHAU08t2ea6kvg8p56NtVIkvH7brQqOjIrQEACtw== X-Received: by 2002:a2e:8e21:: with SMTP id r1mr22778902ljk.81.1572950548332; Tue, 05 Nov 2019 02:42:28 -0800 (PST) Received: from localhost.localdomain ([213.255.186.46]) by smtp.gmail.com with ESMTPSA id z22sm8386482ljm.92.2019.11.05.02.42.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Nov 2019 02:42:27 -0800 (PST) Date: Tue, 5 Nov 2019 12:42:21 +0200 From: Matti Vaittinen To: matti.vaittinen@fi.rohmeurope.com, mazziesaccount@gmail.com Subject: [PATCH 62/62] gpiolib: Nag for INPUT direction values other than GPIO_LINE_DIRECTION_IN Message-ID: <06aa0acec5797fc5711354d8ecad18bc6e947122.1572875541.git.matti.vaittinen@fi.rohmeurope.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.12.1 (2019-06-15) X-Mailman-Approved-At: Thu, 07 Nov 2019 20:47:02 +1100 X-BeenThere: linux-aspeed@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux ASPEED SoC development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Semi Malinen , Kuppuswamy Sathyanarayanan , linux-aspeed@lists.ozlabs.org, David Daney , Linus Walleij , alsa-devel@alsa-project.org, Peter Tyser , Thierry Reding , Jonathan Hunter , Fabio Estevam , linux-stm32@st-md-mailman.stormreply.com, Marek Vasut , Florian Fainelli , Kevin Hilman , Michal Simek , Marek Behun , Bartosz Golaszewski , Ludovic Desroches , bcm-kernel-feedback-list@broadcom.com, Uwe =?iso-8859-1?q?Kleine-K=F6n?= =?iso-8859-1?q?ig?= , Bamvor Jian Zhang , NXP Linux Team , linux-pwm@vger.kernel.org, Grygorii Strashko , Charles Keepax , Maxime Coquelin , linux-omap@vger.kernel.org, Alexandre Torgue , Ray Jui , Sascha Hauer , Nandor Han , William Breathitt Gray , linux-gpio@vger.kernel.org, Richard Fitzgerald , Santosh Shilimkar , linux-tegra@vger.kernel.org, Andy Shevchenko , linux-arm-kernel@lists.infradead.org, Scott Branden , Masahiro Yamada , "Enrico Weigelt, metux IT consult" , linux-kernel@vger.kernel.org, linux-renesas-soc@vger.kernel.org, Thorsten Scherer , Pengutronix Kernel Team , patches@opensource.cirrus.com, Shawn Guo Errors-To: linux-aspeed-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Linux-aspeed" It seems that bunch of drivers put some effort (namely use !! or ! when converting GPIO direction register value to direction) to only return 1 or 0 for direction INPUT/UOTPUT. Others do just return any positive value they happen to read from register for INPUT. Let's try iron out this habit by nagging if our cool new definitions GPIO_LINE_DIRECTION_IN and GPIO_LINE_DIRECTION_OUT are not used. Signed-off-by: Matti Vaittinen --- drivers/gpio/gpiolib.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index 104ed299d5ea..ed292498afb6 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -226,6 +226,12 @@ int gpiod_get_direction(struct gpio_desc *desc) ret = chip->get_direction(chip, offset); if (ret > 0) { /* GPIOF_DIR_IN, or other positive */ + if (ret != GPIO_LINE_DIRECTION_IN) { + struct gpio_device *gdev = chip->gpiodev; + + dev_warn(&gdev->dev, + "drivers should use GPIO_LINE_DIRECTION_IN\n"); + } ret = 1; clear_bit(FLAG_IS_OUT, &desc->flags); } @@ -1389,12 +1395,18 @@ int gpiochip_add_data_with_key(struct gpio_chip *chip, void *data, for (i = 0; i < chip->ngpio; i++) { struct gpio_desc *desc = &gdev->descs[i]; + int dir; if (chip->get_direction && gpiochip_line_is_valid(chip, i)) { - if (!chip->get_direction(chip, i)) + dir = chip->get_direction(chip, i); + if (!dir) { set_bit(FLAG_IS_OUT, &desc->flags); - else + } else { + if (dir != GPIO_LINE_DIRECTION_IN) + dev_warn(&gdev->dev, + "drivers should use GPIO_LINE_DIRECTION_IN\n"); clear_bit(FLAG_IS_OUT, &desc->flags); + } } else { if (!chip->direction_input) set_bit(FLAG_IS_OUT, &desc->flags);