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: "Vaittinen, Matti" X-Patchwork-Id: 11227583 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 03ECC1850 for ; Tue, 5 Nov 2019 11:53:25 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 87C0B21D71 for ; Tue, 5 Nov 2019 11:53:24 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=alsa-project.org header.i=@alsa-project.org header.b="FQx+qt1i" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 87C0B21D71 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=fi.rohmeurope.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id BEC321718; Tue, 5 Nov 2019 12:52:32 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz BEC321718 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1572954802; bh=yVRGdkqBK922kkMdcNGwjOE3j7YI9JT5q0rmj2j+jl4=; h=Date:From:To:References:In-Reply-To:Cc:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=FQx+qt1iPHz30S03yBUFsWXyRwmQBDtr3drkZf1W3vz7QsyD+6fS3Mg9OQwZqAMsY u9OEqpADLmfeO9Kc1hyH2Fbet2tiG4ezV8aLmdzyJkvYM4lAWyqK2mIh3ynQfbpgOm KHxBKSGWCZZ1UZ4DdCJPbAmqlmDy8A1xHYxlrE4o= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id C33FCF805FB; Tue, 5 Nov 2019 12:50:48 +0100 (CET) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa1.perex.cz (Postfix, from userid 50401) id ECCA8F8049B; Tue, 5 Nov 2019 11:42:31 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on alsa1.perex.cz X-Spam-Level: X-Spam-Status: No, score=0.4 required=5.0 tests=FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE, SPF_PASS,SURBL_BLOCKED,URIBL_BLOCKED autolearn=disabled version=3.4.0 Received: from mail-lj1-f193.google.com (mail-lj1-f193.google.com [209.85.208.193]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 603D6F80271 for ; Tue, 5 Nov 2019 11:42:29 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 603D6F80271 Received: by mail-lj1-f193.google.com with SMTP id r7so12536323ljg.2 for ; Tue, 05 Nov 2019 02:42:28 -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=iPIXIKaIC9VXqexp1aCWwWlbteb7fcZPmVie2cv5FVY6vBfuHpqMTZPn+9fpYJnseM bPmcBOTv1imBYeSUGAVUWBRPdrh8OoHoPTDoPdGpeR2TB06+pdTdDa/G+yRF65xP12I9 Oat005Y2QjHgw2r1V6K3s28zwdhgZ4CDo58C4sGNdHGyN6i5DrEo7wjalc/RcYhOIuMb jTzoZ1+HdrDPgy0XwJXhJk81gNw5gKcBfvbFdBs4W3xolZkJczVq253fUJa4cT7p6Uo6 j6ckwAfaMlrB3jxA37dHNqr2B6tzNvYghLCyG3/SJcPEh1/CvN3F/iNRLK0Qd9SJuc0t rbcw== X-Gm-Message-State: APjAAAUDG00fmkThq5ZhqCJdSOpcnvJfk0NJCnAk/NSVVDvumkDiGhHZ 6+mbTgH0zQEjzrGykPOB9uU= 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 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: Tue, 05 Nov 2019 12:50:45 +0100 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, Joel Stanley , Uwe =?iso-8859-1?q?Kleine-K=F6nig?= , 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 , Andrew Jeffery , "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 Subject: [alsa-devel] [PATCH 62/62] gpiolib: Nag for INPUT direction values other than GPIO_LINE_DIRECTION_IN X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" 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);