From patchwork Tue Jul 27 14:41:31 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shubhrajyoti Datta X-Patchwork-Id: 114544 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.4/8.14.3) with ESMTP id o6REfbGC022621 for ; Tue, 27 Jul 2010 14:41:37 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756251Ab0G0Olg (ORCPT ); Tue, 27 Jul 2010 10:41:36 -0400 Received: from devils.ext.ti.com ([198.47.26.153]:35935 "EHLO devils.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756177Ab0G0Olf convert rfc822-to-8bit (ORCPT ); Tue, 27 Jul 2010 10:41:35 -0400 Received: from dbdp20.itg.ti.com ([172.24.170.38]) by devils.ext.ti.com (8.13.7/8.13.7) with ESMTP id o6REfWaw006759 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Tue, 27 Jul 2010 09:41:35 -0500 Received: from dbde71.ent.ti.com (localhost [127.0.0.1]) by dbdp20.itg.ti.com (8.13.8/8.13.8) with ESMTP id o6REfWEt001229 for ; Tue, 27 Jul 2010 20:11:32 +0530 (IST) Received: from dbde02.ent.ti.com ([172.24.170.145]) by dbde71.ent.ti.com ([172.24.170.149]) with mapi; Tue, 27 Jul 2010 20:11:32 +0530 From: "Datta, Shubhrajyoti" To: "linux-input@vger.kernel.org" Date: Tue, 27 Jul 2010 20:11:31 +0530 Subject: [RFC][PATCH] GPIO keys Thread-Topic: [RFC][PATCH] GPIO keys Thread-Index: AcstmWSw8iiB5cbhS+SIf9+1D0/digAAEoJg Message-ID: <0680EC522D0CC943BC586913CF3768C003B37D1C39@dbde02.ent.ti.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: acceptlanguage: en-US MIME-Version: 1.0 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Tue, 27 Jul 2010 14:41:37 +0000 (UTC) diff --git a/drivers/input/keyboard/gpio_keys.c b/drivers/input/keyboard/gpio_keys.c index b8213fd..f459f38 100644 --- a/drivers/input/keyboard/gpio_keys.c +++ b/drivers/input/keyboard/gpio_keys.c @@ -38,6 +38,7 @@ struct gpio_keys_drvdata { struct input_dev *input; struct mutex disable_lock; unsigned int n_buttons; + void (*enable)(int state); struct gpio_button_data data[0]; }; @@ -414,6 +415,24 @@ fail2: return error; } +static int gpio_keys_open(struct input_dev *dev) +{ + struct gpio_keys_drvdata *ddata; + ddata = input_get_drvdata(dev); + if (ddata->enable) + ddata->enable(1); + return 0; +} + +static void gpio_keys_close(struct input_dev *dev) +{ + struct gpio_keys_drvdata *ddata; + + ddata = input_get_drvdata(dev); + if (ddata->enable) + ddata->enable(0); +} + static int __devinit gpio_keys_probe(struct platform_device *pdev) { struct gpio_keys_platform_data *pdata = pdev->dev.platform_data; @@ -435,13 +454,17 @@ static int __devinit gpio_keys_probe(struct platform_device *pdev) ddata->input = input; ddata->n_buttons = pdata->nbuttons; + ddata->enable = pdata->enable; mutex_init(&ddata->disable_lock); platform_set_drvdata(pdev, ddata); + input_set_drvdata(input , ddata); input->name = pdev->name; input->phys = "gpio-keys/input0"; input->dev.parent = &pdev->dev; + input->open = gpio_keys_open; + input->close = gpio_keys_close; input->id.bustype = BUS_HOST; input->id.vendor = 0x0001; diff --git a/include/linux/gpio_keys.h b/include/linux/gpio_keys.h index cd0b3f3..5645996 100644 --- a/include/linux/gpio_keys.h +++ b/include/linux/gpio_keys.h @@ -17,6 +17,7 @@ struct gpio_keys_platform_data { struct gpio_keys_button *buttons; int nbuttons; unsigned int rep:1; /* enable input subsystem auto repeat */ + void (*enable)(int state); }; #endif