From patchwork Mon Feb 17 16:57:25 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Genoud X-Patchwork-Id: 3664031 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 59ED09F1EE for ; Mon, 17 Feb 2014 17:01:42 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 7B6BF201F7 for ; Mon, 17 Feb 2014 17:01:41 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (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 75C35201FB for ; Mon, 17 Feb 2014 17:01:40 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WFRXq-0002wy-UZ; Mon, 17 Feb 2014 16:59:52 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1WFRXT-0004kw-Ht; Mon, 17 Feb 2014 16:59:27 +0000 Received: from mail-wi0-x236.google.com ([2a00:1450:400c:c05::236]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WFRWY-0004dW-EI for linux-arm-kernel@lists.infradead.org; Mon, 17 Feb 2014 16:58:40 +0000 Received: by mail-wi0-f182.google.com with SMTP id f8so2616380wiw.9 for ; Mon, 17 Feb 2014 08:58:08 -0800 (PST) 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=rlYpprgRizHrz9xFnWbvjpbX8qtoFdpTZlkm92wW7+Y=; b=z5QeIMs0UrBilJ7f/AHeR2hnQC6T376PdkaFQHbkWNqJ6K1YiUE6Ok0+69jO7oue+p 1O9vUtPG4nSSfQL9DaDDmtr0pJO+8b/Z8l9nNif89xVyHjOjigSQlNfn63VTLoiJRxL8 XM6C9nQKOqdKpClHoL/WFSmSsX3XXHlHcT8/GA2jiA+sdaA5fNmsqXp0/n9kagNZnbXu +pPcBLyd0zD7XmWCuZlQ/8nj0YgkRO+F/YaCyoNoHZ5TJ4PPGJA/D0mthH6WjDvIEaTD OT7Mv9LHgthNp1swUwRFfh5QwkbnsUb4O+kLP7iZFFrf736WNDBE07Wq7yja+t4q6vXX FD/g== X-Received: by 10.194.71.116 with SMTP id t20mr3138037wju.51.1392656288692; Mon, 17 Feb 2014 08:58:08 -0800 (PST) Received: from lnx-rg.pr (lyon.paratronic.fr. [213.41.177.106]) by mx.google.com with ESMTPSA id cm5sm33980500wid.5.2014.02.17.08.58.06 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 17 Feb 2014 08:58:07 -0800 (PST) From: Richard Genoud To: Greg Kroah-Hartman Subject: [PATCH v3 5/7] ARM: at91: gpio: implement get_direction Date: Mon, 17 Feb 2014 17:57:25 +0100 Message-Id: <1392656247-3351-6-git-send-email-richard.genoud@gmail.com> X-Mailer: git-send-email 1.8.5 In-Reply-To: <1392656247-3351-1-git-send-email-richard.genoud@gmail.com> References: <1392656247-3351-1-git-send-email-richard.genoud@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140217_115830_690074_E5C76E81 X-CRM114-Status: GOOD ( 11.16 ) X-Spam-Score: -2.0 (--) Cc: Alexander Shiyan , Richard Genoud , Linus Walleij , Nicolas Ferre , linux-serial@vger.kernel.org, =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= , Jean-Christophe Plagniol-Villard , 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=-4.6 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=unavailable 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) {