From patchwork Tue May 13 18:20:42 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Genoud X-Patchwork-Id: 4169901 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 7EB339F3AE for ; Tue, 13 May 2014 18:24:40 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 9AF0D20340 for ; Tue, 13 May 2014 18:24:39 +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 B520D202FF for ; Tue, 13 May 2014 18:24:38 +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 1WkHKZ-0005wR-M1; Tue, 13 May 2014 18:21:35 +0000 Received: from mail-we0-x230.google.com ([2a00:1450:400c:c03::230]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WkHKV-0005qD-I0 for linux-arm-kernel@lists.infradead.org; Tue, 13 May 2014 18:21:32 +0000 Received: by mail-we0-f176.google.com with SMTP id q59so794679wes.35 for ; Tue, 13 May 2014 11:21:09 -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=QCz4iLwzBYmdHsKIeSnsfmFmYzVDhlsym1ikhuWtKc8=; b=enR/InjnzaeOuLl5dPtmPmhpc5eBVRcUpiUKR/EEzkE6/KOjPKV+ZLxptyShkGy6M8 BfrkZfB92QQhiM0beI+6P8w8fYjDH3+gsAvjqiLYt0v3kqi+gtptTZq6zWn55P1NCa4r 1f6AxGqZMoqNcMQu3G5dbcQZt6vjj+pmvhRe1VMbSjrf8UrX3gAhcf5+oeZh4kZp13RZ m9JCwyZ4nxm+KRF5pelveWAkMUkXoN5Mfjuo5pPZtN5rjGZFDZgL5TqM7E60isw8ijQS wRyveiSc4pO8y/RnwBsOaDo9Vrxw6hj91Br53rZe//DvVto9s40WZpKQO1blpJQ3OXet PQhA== X-Received: by 10.180.93.226 with SMTP id cx2mr22419772wib.16.1400005269423; Tue, 13 May 2014 11:21:09 -0700 (PDT) Received: from localhost.localdomain (128.240.98.84.rev.sfr.net. [84.98.240.128]) by mx.google.com with ESMTPSA id fw13sm23231816wic.6.2014.05.13.11.21.07 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 13 May 2014 11:21:07 -0700 (PDT) From: Richard Genoud To: Greg Kroah-Hartman Subject: [PATCH RESEND 2/5] ARM: at91: gpio: implement get_direction Date: Tue, 13 May 2014 20:20:42 +0200 Message-Id: <1400005245-11943-3-git-send-email-richard.genoud@gmail.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1400005245-11943-1-git-send-email-richard.genoud@gmail.com> References: <1400005245-11943-1-git-send-email-richard.genoud@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140513_112131_744272_826C8E64 X-CRM114-Status: GOOD ( 11.80 ) X-Spam-Score: -0.1 (/) Cc: Alexander Shiyan , Richard Genoud , Linus Walleij , Nicolas Ferre , Yegor Yefremov , 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 a5afcf7..afbe340 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) {