diff mbox

[RFC] GPIO keys

Message ID 1280300530-17096-1-git-send-email-shubhrajyoti@ti.com (mailing list archive)
State New, archived
Headers show

Commit Message

Shubhrajyoti Datta July 28, 2010, 7:02 a.m. UTC
None
diff mbox

Patch

diff --git a/drivers/input/keyboard/gpio_keys.c b/drivers/input/keyboard/gpio_keys.c
index b8213fd..d06644d 100644
--- a/drivers/input/keyboard/gpio_keys.c
+++ b/drivers/input/keyboard/gpio_keys.c
@@ -38,6 +38,8 @@  struct gpio_keys_drvdata {
 	struct input_dev *input;
 	struct mutex disable_lock;
 	unsigned int n_buttons;
+	void (*enable)(void);
+	void (*disable)(void);
 	struct gpio_button_data data[0];
 };
 
@@ -414,6 +416,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();
+	return 0;
+}
+
+static void gpio_keys_close(struct input_dev *dev)
+{
+	struct gpio_keys_drvdata *ddata;
+
+	ddata = input_get_drvdata(dev);
+	if (ddata->disable)
+		ddata->disable();
+}
+
 static int __devinit gpio_keys_probe(struct platform_device *pdev)
 {
 	struct gpio_keys_platform_data *pdata = pdev->dev.platform_data;
@@ -435,13 +455,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..5089b1b 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 */
+	void (*enable)(void);
+	void (*disable)(void);
 };
 
 #endif