include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit...
[safe/jmp/linux-2.6] / drivers / input / input-polldev.c
index 6a2eb39..10c9b0a 100644 (file)
@@ -9,6 +9,7 @@
  */
 
 #include <linux/jiffies.h>
+#include <linux/slab.h>
 #include <linux/mutex.h>
 #include <linux/input-polldev.h>
 
@@ -100,6 +101,12 @@ static void input_close_polled_device(struct input_dev *input)
        struct input_polled_dev *dev = input_get_drvdata(input);
 
        cancel_delayed_work_sync(&dev->work);
+       /*
+        * Clean up work struct to remove references to the workqueue.
+        * It may be destroyed by the next call. This causes problems
+        * at next device open-close in case of poll_interval == 0.
+        */
+       INIT_DELAYED_WORK(&dev->work, dev->work.work.func);
        input_polldev_stop_workqueue();
 
        if (dev->close)
@@ -212,7 +219,7 @@ EXPORT_SYMBOL(input_allocate_polled_device);
  * @dev: device to free
  *
  * The function frees memory allocated for polling device and drops
- * reference to the associated input device (if present).
+ * reference to the associated input device.
  */
 void input_free_polled_device(struct input_polled_dev *dev)
 {
@@ -258,6 +265,15 @@ int input_register_polled_device(struct input_polled_dev *dev)
                return error;
        }
 
+       /*
+        * Take extra reference to the underlying input device so
+        * that it survives call to input_unregister_polled_device()
+        * and is deleted only after input_free_polled_device()
+        * has been invoked. This is needed to ease task of freeing
+        * sparse keymaps.
+        */
+       input_get_device(input);
+
        return 0;
 }
 EXPORT_SYMBOL(input_register_polled_device);
@@ -269,8 +285,6 @@ EXPORT_SYMBOL(input_register_polled_device);
  * The function unregisters previously registered polled input
  * device from input layer. Polling is stopped and device is
  * ready to be freed with call to input_free_polled_device().
- * Callers should not attempt to access dev->input pointer
- * after calling this function.
  */
 void input_unregister_polled_device(struct input_polled_dev *dev)
 {
@@ -278,7 +292,6 @@ void input_unregister_polled_device(struct input_polled_dev *dev)
                           &input_polldev_attribute_group);
 
        input_unregister_device(dev->input);
-       dev->input = NULL;
 }
 EXPORT_SYMBOL(input_unregister_polled_device);