Input: add open and close methods for polled devices
authorSamu Onkalo <samu.p.onkalo@nokia.com>
Sun, 18 Oct 2009 07:38:57 +0000 (00:38 -0700)
committerDmitry Torokhov <dmitry.torokhov@gmail.com>
Sun, 18 Oct 2009 07:46:49 +0000 (00:46 -0700)
Optional open and close methods for preparing and closing
the device.

Signed-off-by: Samu Onkalo <samu.p.onkalo@nokia.com>
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
drivers/input/input-polldev.c
drivers/input/misc/wistron_btns.c
include/linux/input-polldev.h

index 0d3ce7a..910220c 100644 (file)
@@ -80,8 +80,8 @@ static int input_open_polled_device(struct input_dev *input)
        if (error)
                return error;
 
-       if (dev->flush)
-               dev->flush(dev);
+       if (dev->open)
+               dev->open(dev);
 
        queue_delayed_work(polldev_wq, &dev->work,
                           msecs_to_jiffies(dev->poll_interval));
@@ -95,6 +95,9 @@ static void input_close_polled_device(struct input_dev *input)
 
        cancel_delayed_work_sync(&dev->work);
        input_polldev_stop_workqueue();
+
+       if (dev->close)
+               dev->close(dev);
 }
 
 /**
index a932179..00eb9d6 100644 (file)
@@ -1263,7 +1263,7 @@ static int __devinit setup_input_dev(void)
        if (!wistron_idev)
                return -ENOMEM;
 
-       wistron_idev->flush = wistron_flush;
+       wistron_idev->open = wistron_flush;
        wistron_idev->poll = wistron_poll;
        wistron_idev->poll_interval = POLL_INTERVAL_DEFAULT;
 
index 597a007..5c0ec68 100644 (file)
 
 /**
  * struct input_polled_dev - simple polled input device
- * @private: private driver data
- * @flush: driver-supplied method that flushes device's state upon
- *     opening (optional)
+ * @private: private driver data.
+ * @open: driver-supplied method that prepares device for polling
+ *     (enabled the device and maybe flushes device state).
+ * @close: driver-supplied method that is called when device is no
+ *     longer being polled. Used to put device into low power mode.
  * @poll: driver-supplied method that polls the device and posts
  *     input events (mandatory).
  * @poll_interval: specifies how often the poll() method shoudl be called.
@@ -30,7 +32,8 @@
 struct input_polled_dev {
        void *private;
 
-       void (*flush)(struct input_polled_dev *dev);
+       void (*open)(struct input_polled_dev *dev);
+       void (*close)(struct input_polled_dev *dev);
        void (*poll)(struct input_polled_dev *dev);
        unsigned int poll_interval; /* msec */