From patchwork Tue May 24 13:13:45 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laxman Dewangan X-Patchwork-Id: 625628 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3rDblb2kCZz9t61 for ; Tue, 24 May 2016 23:26:18 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752133AbcEXN0E (ORCPT ); Tue, 24 May 2016 09:26:04 -0400 Received: from hqemgate14.nvidia.com ([216.228.121.143]:18426 "EHLO hqemgate14.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751634AbcEXN0E (ORCPT ); Tue, 24 May 2016 09:26:04 -0400 Received: from hqnvupgp08.nvidia.com (Not Verified[216.228.121.13]) by hqemgate14.nvidia.com id ; Tue, 24 May 2016 06:26:02 -0700 Received: from HQMAIL106.nvidia.com ([172.18.146.12]) by hqnvupgp08.nvidia.com (PGP Universal service); Tue, 24 May 2016 06:24:30 -0700 X-PGP-Universal: processed; by hqnvupgp08.nvidia.com on Tue, 24 May 2016 06:24:30 -0700 Received: from BGMAIL102.nvidia.com (10.25.59.11) by HQMAIL106.nvidia.com (172.18.146.12) with Microsoft SMTP Server (TLS) id 15.0.1130.7; Tue, 24 May 2016 13:26:01 +0000 Received: from HQMAIL104.nvidia.com (172.18.146.11) by bgmail102.nvidia.com (10.25.59.11) with Microsoft SMTP Server (TLS) id 15.0.1130.7; Tue, 24 May 2016 13:25:57 +0000 Received: from ldewanganubuntu-System-Product-Name.nvidia.com (172.20.13.39) by HQMAIL104.nvidia.com (172.18.146.11) with Microsoft SMTP Server id 15.0.1130.7 via Frontend Transport; Tue, 24 May 2016 13:25:55 +0000 From: Laxman Dewangan To: , CC: , , "Laxman Dewangan" Subject: [PATCH 2/3] gpio: max77620: Implement gpio_get_direction callback Date: Tue, 24 May 2016 18:43:45 +0530 Message-ID: <1464095626-28424-2-git-send-email-ldewangan@nvidia.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1464095626-28424-1-git-send-email-ldewangan@nvidia.com> References: <1464095626-28424-1-git-send-email-ldewangan@nvidia.com> MIME-Version: 1.0 Sender: linux-gpio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org Implement gpio_get_direction() callback for MAX77620 GPIO. This is useful for debugfs and the userspace ABI. Signed-off-by: Laxman Dewangan --- drivers/gpio/gpio-max77620.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/drivers/gpio/gpio-max77620.c b/drivers/gpio/gpio-max77620.c index 35f365c..0bb6d93 100644 --- a/drivers/gpio/gpio-max77620.c +++ b/drivers/gpio/gpio-max77620.c @@ -9,6 +9,7 @@ */ #include +#include #include #include #include @@ -152,6 +153,23 @@ static int max77620_gpio_dir_output(struct gpio_chip *gc, unsigned int offset, return ret; } +static int max77620_gpio_get_direction(struct gpio_chip *gc, + unsigned int offset) +{ + struct max77620_gpio *mgpio = gpiochip_get_data(gc); + unsigned int val; + int ret; + + ret = regmap_read(mgpio->rmap, GPIO_REG_ADDR(offset), &val); + if (ret < 0) { + dev_err(mgpio->dev, "GPIO register read failed: %d\n", ret); + return ret; + } + + return (val & MAX77620_CNFG_GPIO_DIR_MASK) ? + GPIOF_DIR_IN : GPIOF_DIR_OUT; +} + static int max77620_gpio_set_debounce(struct gpio_chip *gc, unsigned int offset, unsigned int debounce) @@ -236,6 +254,7 @@ static int max77620_gpio_probe(struct platform_device *pdev) mgpio->gpio_chip.direction_input = max77620_gpio_dir_input; mgpio->gpio_chip.get = max77620_gpio_get; mgpio->gpio_chip.direction_output = max77620_gpio_dir_output; + mgpio->gpio_chip.get_direction = max77620_gpio_get_direction; mgpio->gpio_chip.set_debounce = max77620_gpio_set_debounce; mgpio->gpio_chip.set = max77620_gpio_set; mgpio->gpio_chip.to_irq = max77620_gpio_to_irq;