From patchwork Fri Apr 25 14:52:38 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Genoud X-Patchwork-Id: 4063711 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 1C93EBFF02 for ; Fri, 25 Apr 2014 14:56:02 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 4A2732037A for ; Fri, 25 Apr 2014 14:56:01 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 7F5932037D for ; Fri, 25 Apr 2014 14:56:00 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1WdhVn-0003RM-Ac; Fri, 25 Apr 2014 14:53:59 +0000 Received: from mail-wg0-x22e.google.com ([2a00:1450:400c:c00::22e]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WdhVY-00036j-CZ for linux-arm-kernel@lists.infradead.org; Fri, 25 Apr 2014 14:53:45 +0000 Received: by mail-wg0-f46.google.com with SMTP id b13so3759394wgh.29 for ; Fri, 25 Apr 2014 07:53:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=q2NlK3+Fok4iNZQFzLzu5uIgkgLKkqYTdwfOFZmEDk0=; b=QPA99HfhuDFiT2pRPqVpVjf1wdpU2uW5xWAj1IPk+pl1KFhSLA2aI2SLkMPp95WOMS WsvEa5rEUWUaAitGcumew08slGbxPVYP/JUr1qPOnAkYesBZwzg4T/UifMTK1xoe+g9P 7imp69LAvsSYrDqsIPNWiqoVb/VOqqpLgW5p6m322GM0iMGmR/dHrQBAkg75Wy+3V+tA Ab9ESEyUeROQnLMjQx8ls/HnllJKiAdc3pmbSIe7WEBn8bygG4Ls+V0Z3B3turMMmn+S rI/mWw2eDxDQpPSA9xZHIjoYYKyo6063ZQV65eu+cSdFfhD8stmix43dur9l0PCvBH6o O9/Q== X-Received: by 10.180.74.203 with SMTP id w11mr4031791wiv.27.1398437600270; Fri, 25 Apr 2014 07:53:20 -0700 (PDT) Received: from localhost (lyon.paratronic.fr. [213.41.177.106]) by mx.google.com with ESMTPSA id mw4sm6367286wib.12.2014.04.25.07.53.18 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Fri, 25 Apr 2014 07:53:19 -0700 (PDT) From: Richard Genoud To: Greg Kroah-Hartman Subject: [PATCH 2/5] ARM: at91: gpio: implement get_direction Date: Fri, 25 Apr 2014 16:52:38 +0200 Message-Id: <1398437561-4289-3-git-send-email-richard.genoud@gmail.com> X-Mailer: git-send-email 1.8.5.5 In-Reply-To: <1398437561-4289-1-git-send-email-richard.genoud@gmail.com> References: <1398437561-4289-1-git-send-email-richard.genoud@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140425_075344_611117_147632B7 X-CRM114-Status: GOOD ( 10.80 ) X-Spam-Score: -0.1 (/) Cc: Alexander Shiyan , Richard Genoud , Linus Walleij , Nicolas Ferre , linux-serial@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-2.4 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This is needed for gpiod_get_direction(). Otherwise, it returns -EINVAL. Signed-off-by: Richard Genoud Acked-by: Linus Walleij --- arch/arm/mach-at91/gpio.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/arch/arm/mach-at91/gpio.c b/arch/arm/mach-at91/gpio.c index a5afcf76550e..afbe34027e62 100644 --- a/arch/arm/mach-at91/gpio.c +++ b/arch/arm/mach-at91/gpio.c @@ -49,6 +49,7 @@ static int at91_gpiolib_request(struct gpio_chip *chip, unsigned offset); static void at91_gpiolib_dbg_show(struct seq_file *s, struct gpio_chip *chip); static void at91_gpiolib_set(struct gpio_chip *chip, unsigned offset, int val); static int at91_gpiolib_get(struct gpio_chip *chip, unsigned offset); +static int at91_gpiolib_get_direction(struct gpio_chip *chip, unsigned offset); static int at91_gpiolib_direction_output(struct gpio_chip *chip, unsigned offset, int val); static int at91_gpiolib_direction_input(struct gpio_chip *chip, @@ -60,6 +61,7 @@ static int at91_gpiolib_to_irq(struct gpio_chip *chip, unsigned offset); .chip = { \ .label = name, \ .request = at91_gpiolib_request, \ + .get_direction = at91_gpiolib_get_direction, \ .direction_input = at91_gpiolib_direction_input, \ .direction_output = at91_gpiolib_direction_output, \ .get = at91_gpiolib_get, \ @@ -799,6 +801,17 @@ static int at91_gpiolib_request(struct gpio_chip *chip, unsigned offset) return 0; } +static int at91_gpiolib_get_direction(struct gpio_chip *chip, unsigned offset) +{ + struct at91_gpio_chip *at91_gpio = to_at91_gpio_chip(chip); + void __iomem *pio = at91_gpio->regbase; + unsigned mask = 1 << offset; + u32 osr; + + osr = __raw_readl(pio + PIO_OSR); + return !(osr & mask); +} + static int at91_gpiolib_direction_input(struct gpio_chip *chip, unsigned offset) {