From mboxrd@z Thu Jan 1 00:00:00 1970 From: Dmitry Torokhov Subject: Re: [RFC][PATCH] GPIO keys Date: Tue, 27 Jul 2010 10:00:48 -0700 Message-ID: <20100727170047.GC5961@core.coreip.homeip.net> References: <0680EC522D0CC943BC586913CF3768C003B37D1C39@dbde02.ent.ti.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Received: from mail-px0-f174.google.com ([209.85.212.174]:52923 "EHLO mail-px0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751098Ab0G0RA5 (ORCPT ); Tue, 27 Jul 2010 13:00:57 -0400 Received: by pxi14 with SMTP id 14so541975pxi.19 for ; Tue, 27 Jul 2010 10:00:56 -0700 (PDT) Content-Disposition: inline In-Reply-To: <0680EC522D0CC943BC586913CF3768C003B37D1C39@dbde02.ent.ti.com> Sender: linux-input-owner@vger.kernel.org List-Id: linux-input@vger.kernel.org To: "Datta, Shubhrajyoti" Cc: "linux-input@vger.kernel.org" Hi Shubhrajyoti, On Tue, Jul 27, 2010 at 08:11:31PM +0530, Datta, Shubhrajyoti wrote: > > Allowing the call of open and close functions. > If the gpio-keys device has some initialization > to be done allow the call of platform functions. > An example would be to enable the device. > Makes sense, although I'd prefer 2 separate methods. Also, make sure you run you patch through scripts/checkpatch.pl - I see a coupe of small formatting issues (note that I do not care strongly about 80 column limit). Thanks. > Signed-off-by: Shubhrajyoti D > --- > drivers/input/keyboard/gpio_keys.c | 23 +++++++++++++++++++++++ > include/linux/gpio_keys.h | 1 + > 2 files changed, 24 insertions(+), 0 deletions(-) > > 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 > -- > 1.5.4.7 > > -- > To unsubscribe from this list: send the line "unsubscribe linux-input" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html -- Dmitry