Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755155AbcDDKK7 (ORCPT ); Mon, 4 Apr 2016 06:10:59 -0400 Received: from mail-sn1nam02on0051.outbound.protection.outlook.com ([104.47.36.51]:13968 "EHLO NAM02-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754268AbcDDKK4 (ORCPT ); Mon, 4 Apr 2016 06:10:56 -0400 X-Greylist: delayed 872 seconds by postgrey-1.27 at vger.kernel.org; Mon, 04 Apr 2016 06:10:56 EDT Authentication-Results: spf=pass (sender IP is 149.199.60.83) smtp.mailfrom=xilinx.com; vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=bestguesspass action=none header.from=xilinx.com; From: Nava kishore Manne To: , , , , CC: , Subject: [LINUX PATCH v2] gpio_keys: Added support to read the IRQ_FLAGS from devicetree Date: Mon, 4 Apr 2016 15:26:10 +0530 Message-ID: <1459763770-2296-1-git-send-email-navam@xilinx.com> X-Mailer: git-send-email 2.1.2 X-RCIS-Action: ALLOW X-TM-AS-Product-Ver: IMSS-7.1.0.1224-8.0.0.1202-22238.005 X-TM-AS-User-Approved-Sender: Yes;Yes X-EOPAttributedMessage: 0 X-Forefront-Antispam-Report: CIP:149.199.60.83;IPV:NLI;CTRY:US;EFV:NLI;SFV:NSPM;SFS:(10009020)(6009001)(2980300002)(438002)(189002)(199003)(19580395003)(19580405001)(5001770100001)(48376002)(50226001)(50466002)(52956003)(11100500001)(86362001)(92566002)(36386004)(42186005)(189998001)(87936001)(229853001)(50986999)(33646002)(81166005)(2906002)(5008740100001)(5003940100001)(106466001)(2201001)(4326007)(45336002)(6806005)(103686003)(36756003)(586003)(1096002)(1220700001)(63266004)(46386002)(90966002)(107986001)(217873001);DIR:OUT;SFP:1101;SCL:1;SRVR:SN1NAM02HT254;H:xsj-pvapsmtpgw01;FPR:;SPF:Pass;MLV:sfv;MX:1;A:1;LANG:en; MIME-Version: 1.0 Content-Type: text/plain X-MS-Office365-Filtering-Correlation-Id: 76875a3b-ece5-405b-cc50-08d35c6f60fd X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(8251501002);SRVR:SN1NAM02HT254; X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(601004)(2401047)(13015025)(13024025)(13023025)(8121501046)(13018025)(5005006)(13017025)(3002001)(10201501046);SRVR:SN1NAM02HT254;BCL:0;PCL:0;RULEID:;SRVR:SN1NAM02HT254; X-Forefront-PRVS: 0902222726 X-OriginatorOrg: xilinx.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Apr 2016 09:56:22.5242 (UTC) X-MS-Exchange-CrossTenant-Id: 657af505-d5df-48d0-8300-c31994686c5c X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=657af505-d5df-48d0-8300-c31994686c5c;Ip=[149.199.60.83];Helo=[xsj-pvapsmtpgw01] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN1NAM02HT254 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2251 Lines: 87 This patch adds the support to read the IRQ_FLAGS from the device instead of hard code the flags in gpio_keys_setup_key(). example gpio-keys DT node: gpio-keys { compatible = "gpio-keys"; #address-cells = <1>; #size-cells = <0>; autorepeat; sw14 { label = "sw14"; gpios = <&gpio0 12 1>; /* * Triggering Type: * * 1 - edge rising * 2 - edge falling * 4 - level active high * 8 - level active low * */ linux,code = <108>; /* down */ gpio-key,wakeup; autorepeat; }; }; Signed-off-by: Nava kishore Manne --- Changes for v2: -None drivers/input/keyboard/gpio_keys.c | 8 ++++---- include/linux/gpio_keys.h | 1 + 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/input/keyboard/gpio_keys.c b/drivers/input/keyboard/gpio_keys.c index bef317f..07b50ad 100644 --- a/drivers/input/keyboard/gpio_keys.c +++ b/drivers/input/keyboard/gpio_keys.c @@ -497,7 +497,7 @@ static int gpio_keys_setup_key(struct platform_device *pdev, INIT_DELAYED_WORK(&bdata->work, gpio_keys_gpio_work_func); isr = gpio_keys_gpio_isr; - irqflags = IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING; + irqflags = button->irq_flags; } else { if (!button->irq) { @@ -630,11 +630,10 @@ gpio_keys_get_devtree_pdata(struct device *dev) i = 0; for_each_child_of_node(node, pp) { - enum of_gpio_flags flags; button = &pdata->buttons[i++]; - button->gpio = of_get_gpio_flags(pp, 0, &flags); + button->gpio = of_get_gpio_flags(pp, 0, &button->irq_flags); if (button->gpio < 0) { error = button->gpio; if (error != -ENOENT) { @@ -645,7 +644,8 @@ gpio_keys_get_devtree_pdata(struct device *dev) return ERR_PTR(error); } } else { - button->active_low = flags & OF_GPIO_ACTIVE_LOW; + button->active_low = button->irq_flags + & OF_GPIO_ACTIVE_LOW; } button->irq = irq_of_parse_and_map(pp, 0); diff --git a/include/linux/gpio_keys.h b/include/linux/gpio_keys.h index ee2d8c6..0aeecea 100644 --- a/include/linux/gpio_keys.h +++ b/include/linux/gpio_keys.h @@ -31,6 +31,7 @@ struct gpio_keys_button { bool can_disable; int value; unsigned int irq; + unsigned int irq_flags; struct gpio_desc *gpiod; }; -- 2.1.2