From patchwork Sat Dec 5 22:38:14 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cory Maccarrone X-Patchwork-Id: 65082 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id nB5McVIr030049 for ; Sat, 5 Dec 2009 22:38:31 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756104AbZLEWiV (ORCPT ); Sat, 5 Dec 2009 17:38:21 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1756559AbZLEWiV (ORCPT ); Sat, 5 Dec 2009 17:38:21 -0500 Received: from mail-pz0-f171.google.com ([209.85.222.171]:36619 "EHLO mail-pz0-f171.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755929AbZLEWiU (ORCPT ); Sat, 5 Dec 2009 17:38:20 -0500 Received: by pzk1 with SMTP id 1so586125pzk.33 for ; Sat, 05 Dec 2009 14:38:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:from:to:cc:subject:date :message-id:x-mailer; bh=PqRYSXNfe8gdndgsjoGDN7T4lgejgq6F3RrPYCNJYjQ=; b=QUnKclDnhuk2j3a8lnLXVf6AUvbz0el5pFD0vvASeorBnfQCQkkaSSL5LLxliBOUHH 9F/EDbZcGZNkWxC/exM12DgNREk98Y1Rg3muar11srEZxwQ8wxcV/+MDtHMIeasmJf6j /2QP4ZLN/8hVTBhKP/d7vC6a+r4gkEv1f56AE= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer; b=EQJi8mzyyWCNOr9SOe7kfweQXhMKAmzy/eP8RqeZJpVxMtCgKvAV7412u70jj6bVex Z3OIZdxbhc+V6BUD1gJ9CG8r51r0+WAyKio5ovIXcsRWys4dhaoNgvAE7CwCv4sO/Jop DTRxjC2qg84bHd1LuUzmK/Y5VhJts1/4L8E5Y= Received: by 10.115.66.35 with SMTP id t35mr7497900wak.87.1260052706713; Sat, 05 Dec 2009 14:38:26 -0800 (PST) Received: from localhost (97-126-116-159.tukw.qwest.net [97.126.116.159]) by mx.google.com with ESMTPS id 23sm3672136pzk.4.2009.12.05.14.38.26 (version=TLSv1/SSLv3 cipher=RC4-MD5); Sat, 05 Dec 2009 14:38:26 -0800 (PST) From: Cory Maccarrone To: linux-input@vger.kernel.org, linux-omap@vger.kernel.org Cc: Cory Maccarrone Subject: [PATCH] Input: gpio-keys: Support for one-directional interrupts Date: Sat, 5 Dec 2009 14:38:14 -0800 Message-Id: <1260052694-17223-1-git-send-email-darkstar6262@gmail.com> X-Mailer: git-send-email 1.6.3.3 Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org diff --git a/drivers/input/keyboard/gpio_keys.c b/drivers/input/keyboard/gpio_keys.c index 77d1309..05c599a 100644 --- a/drivers/input/keyboard/gpio_keys.c +++ b/drivers/input/keyboard/gpio_keys.c @@ -45,7 +45,18 @@ static void gpio_keys_report_event(struct work_struct *work) struct gpio_keys_button *button = bdata->button; struct input_dev *input = bdata->input; unsigned int type = button->type ?: EV_KEY; - int state = (gpio_get_value(button->gpio) ? 1 : 0) ^ button->active_low; + int state = gpio_get_value(button->gpio) ? 1 : 0; + + /* If the hardware can't do both edges, set the appropriate + * interrupt control */ + if (button->not_both_edges) { + if (state) + set_irq_type(gpio_to_irq(button->gpio), IRQ_TYPE_EDGE_FALLING); + else + set_irq_type(gpio_to_irq(button->gpio), IRQ_TYPE_EDGE_RISING); + } + + state ^= button->active_low; input_event(input, type, button->code, !!state); input_sync(input); @@ -79,7 +90,7 @@ static int __devinit gpio_keys_probe(struct platform_device *pdev) struct gpio_keys_platform_data *pdata = pdev->dev.platform_data; struct gpio_keys_drvdata *ddata; struct input_dev *input; - int i, error; + int i, error, trigger; int wakeup = 0; ddata = kzalloc(sizeof(struct gpio_keys_drvdata) + @@ -146,9 +157,17 @@ static int __devinit gpio_keys_probe(struct platform_device *pdev) goto fail2; } + if (button->not_both_edges) { + if (gpio_get_value(button->gpio)) + trigger = IRQF_TRIGGER_FALLING; + else + trigger = IRQF_TRIGGER_RISING; + } else { + trigger = IRQF_TRIGGER_FALLING | IRQF_TRIGGER_RISING; + } + error = request_irq(irq, gpio_keys_isr, - IRQF_SHARED | - IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING, + IRQF_SHARED | trigger, button->desc ? button->desc : "gpio_keys", bdata); if (error) { diff --git a/include/linux/gpio_keys.h b/include/linux/gpio_keys.h index 1289fa7..493426d 100644 --- a/include/linux/gpio_keys.h +++ b/include/linux/gpio_keys.h @@ -10,6 +10,7 @@ struct gpio_keys_button { int type; /* input event type (EV_KEY, EV_SW) */ int wakeup; /* configure the button as a wake-up source */ int debounce_interval; /* debounce ticks interval in msecs */ + int not_both_edges; /* some hardware can't do interrupts on both edges */ }; struct gpio_keys_platform_data {