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);