From patchwork Tue Aug 3 08:15:51 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Torokhov X-Patchwork-Id: 116697 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 o738FxJJ018758 for ; Tue, 3 Aug 2010 08:15:59 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754281Ab0HCIP6 (ORCPT ); Tue, 3 Aug 2010 04:15:58 -0400 Received: from mail-pz0-f46.google.com ([209.85.210.46]:53119 "EHLO mail-pz0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752171Ab0HCIP5 (ORCPT ); Tue, 3 Aug 2010 04:15:57 -0400 Received: by pzk26 with SMTP id 26so1567447pzk.19 for ; Tue, 03 Aug 2010 01:15:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:date:from:to:cc:subject :message-id:references:mime-version:content-type:content-disposition :in-reply-to:user-agent; bh=8Qn0jsjpTHW25DXEYFFUMFFcWtB9xFr2KVjGQt2UArU=; b=Jo5d/rAzQv7iDTeVJ71SdYzEXVyStyE+CFvcMfvsOE+yYyHfUJGgq3X9nRhRc+9tvA k4mM1R7YBGiORYBa68TK0S6xEfsOVtsjS0CgVyYB3vKQAzX3wTdBoQoiowi0gZ6BALrs sZ1AdH1JFh2ioepSNnHLNK0WIjvi9tQPiSyQo= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=date:from:to:cc:subject:message-id:references:mime-version :content-type:content-disposition:in-reply-to:user-agent; b=FoitVNoJh9zpOVb1ogHZ3fcT1vZ8ozC51+HQcgG7neDXuNMgdTqnnkNbU0apN4sE4N VmraividN/IXglfLrn+tB94zTyY82y+Kkgrky8M+sVlGsP0IYETsBSCoBYef2Frm87nE 5ZhKyG8AOFv1oT4gL+H2uFUdQf3q86JQcZUBk= Received: by 10.114.208.20 with SMTP id f20mr8619747wag.69.1280823357079; Tue, 03 Aug 2010 01:15:57 -0700 (PDT) Received: from mailhub.coreip.homeip.net (c-24-6-153-206.hsd1.ca.comcast.net [24.6.153.206]) by mx.google.com with ESMTPS id q6sm13134834waj.22.2010.08.03.01.15.54 (version=TLSv1/SSLv3 cipher=RC4-MD5); Tue, 03 Aug 2010 01:15:54 -0700 (PDT) Date: Tue, 3 Aug 2010 01:15:51 -0700 From: Dmitry Torokhov To: Shubhrajyoti D Cc: linux-input@vger.kernel.org Subject: Re: [RFC][PATCH] GPIO keys Message-ID: <20100803081551.GA16029@core.coreip.homeip.net> References: <1280300530-17096-1-git-send-email-shubhrajyoti@ti.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1280300530-17096-1-git-send-email-shubhrajyoti@ti.com> User-Agent: Mutt/1.5.20 (2009-12-10) 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, 03 Aug 2010 08:15:59 +0000 (UTC) diff --git a/drivers/input/keyboard/gpio_keys.c b/drivers/input/keyboard/gpio_keys.c index a9fd147..6069abe 100644 --- a/drivers/input/keyboard/gpio_keys.c +++ b/drivers/input/keyboard/gpio_keys.c @@ -39,6 +39,8 @@ struct gpio_keys_drvdata { struct input_dev *input; struct mutex disable_lock; unsigned int n_buttons; + int (*enable)(struct device *dev); + void (*disable)(struct device *dev); struct gpio_button_data data[0]; }; @@ -423,6 +425,21 @@ fail2: return error; } +static int gpio_keys_open(struct input_dev *input) +{ + struct gpio_keys_drvdata *ddata = input_get_drvdata(input); + + return ddata->enable ? ddata->enable(input->dev.parent) : 0; +} + +static void gpio_keys_close(struct input_dev *input) +{ + struct gpio_keys_drvdata *ddata = input_get_drvdata(input); + + if (ddata->disable) + ddata->disable(input->dev.parent); +} + static int __devinit gpio_keys_probe(struct platform_device *pdev) { struct gpio_keys_platform_data *pdata = pdev->dev.platform_data; @@ -444,13 +461,18 @@ static int __devinit gpio_keys_probe(struct platform_device *pdev) ddata->input = input; ddata->n_buttons = pdata->nbuttons; + ddata->enable = pdata->enable; + ddata->disable = pdata->disable; 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..ce73a30 100644 --- a/include/linux/gpio_keys.h +++ b/include/linux/gpio_keys.h @@ -17,6 +17,8 @@ struct gpio_keys_platform_data { struct gpio_keys_button *buttons; int nbuttons; unsigned int rep:1; /* enable input subsystem auto repeat */ + int (*enable)(struct device *dev); + void (*disable)(struct device *dev); }; #endif