Input: fix formatting to better follow CodingStyle
[linux-2.6.git] / drivers / input / input.c
index 3038c26..7570a3f 100644 (file)
@@ -29,6 +29,7 @@ MODULE_DESCRIPTION("Input core");
 MODULE_LICENSE("GPL");
 
 EXPORT_SYMBOL(input_allocate_device);
+EXPORT_SYMBOL(input_free_device);
 EXPORT_SYMBOL(input_register_device);
 EXPORT_SYMBOL(input_unregister_device);
 EXPORT_SYMBOL(input_register_handler);
@@ -63,11 +64,13 @@ void input_event(struct input_dev *dev, unsigned int type, unsigned int code, in
                case EV_SYN:
                        switch (code) {
                                case SYN_CONFIG:
-                                       if (dev->event) dev->event(dev, type, code, value);
+                                       if (dev->event)
+                                               dev->event(dev, type, code, value);
                                        break;
 
                                case SYN_REPORT:
-                                       if (dev->sync) return;
+                                       if (dev->sync)
+                                               return;
                                        dev->sync = 1;
                                        break;
                        }
@@ -136,7 +139,8 @@ void input_event(struct input_dev *dev, unsigned int type, unsigned int code, in
                        if (code > MSC_MAX || !test_bit(code, dev->mscbit))
                                return;
 
-                       if (dev->event) dev->event(dev, type, code, value);
+                       if (dev->event)
+                               dev->event(dev, type, code, value);
 
                        break;
 
@@ -146,7 +150,9 @@ void input_event(struct input_dev *dev, unsigned int type, unsigned int code, in
                                return;
 
                        change_bit(code, dev->led);
-                       if (dev->event) dev->event(dev, type, code, value);
+
+                       if (dev->event)
+                               dev->event(dev, type, code, value);
 
                        break;
 
@@ -158,21 +164,25 @@ void input_event(struct input_dev *dev, unsigned int type, unsigned int code, in
                        if (!!test_bit(code, dev->snd) != !!value)
                                change_bit(code, dev->snd);
 
-                       if (dev->event) dev->event(dev, type, code, value);
+                       if (dev->event)
+                               dev->event(dev, type, code, value);
 
                        break;
 
                case EV_REP:
 
-                       if (code > REP_MAX || value < 0 || dev->rep[code] == value) return;
+                       if (code > REP_MAX || value < 0 || dev->rep[code] == value)
+                               return;
 
                        dev->rep[code] = value;
-                       if (dev->event) dev->event(dev, type, code, value);
+                       if (dev->event)
+                               dev->event(dev, type, code, value);
 
                        break;
 
                case EV_FF:
-                       if (dev->event) dev->event(dev, type, code, value);
+                       if (dev->event)
+                               dev->event(dev, type, code, value);
                        break;
        }
 
@@ -335,9 +345,11 @@ static inline void input_wakeup_procfs_readers(void)
 static unsigned int input_proc_devices_poll(struct file *file, poll_table *wait)
 {
        int state = input_devices_state;
+
        poll_wait(file, &input_devices_poll_wait, wait);
        if (state != input_devices_state)
                return POLLIN | POLLRDNORM;
+
        return 0;
 }
 
@@ -629,7 +641,7 @@ static ssize_t input_dev_show_modalias(struct class_device *dev, char *buf)
 
        len = input_print_modalias(buf, PAGE_SIZE, id, 1);
 
-       return max_t(int, len, PAGE_SIZE);
+       return min_t(int, len, PAGE_SIZE);
 }
 static CLASS_DEVICE_ATTR(modalias, S_IRUGO, input_dev_show_modalias, NULL);
 
@@ -872,6 +884,7 @@ struct input_dev *input_allocate_device(void)
                dev->dynalloc = 1;
                dev->cdev.class = &input_class;
                class_device_initialize(&dev->cdev);
+               mutex_init(&dev->mutex);
                INIT_LIST_HEAD(&dev->h_list);
                INIT_LIST_HEAD(&dev->node);
        }
@@ -879,6 +892,18 @@ struct input_dev *input_allocate_device(void)
        return dev;
 }
 
+void input_free_device(struct input_dev *dev)
+{
+       if (dev) {
+
+               mutex_lock(&dev->mutex);
+               dev->name = dev->phys = dev->uniq = NULL;
+               mutex_unlock(&dev->mutex);
+
+               input_put_device(dev);
+       }
+}
+
 int input_register_device(struct input_dev *dev)
 {
        static atomic_t input_no = ATOMIC_INIT(0);
@@ -895,7 +920,6 @@ int input_register_device(struct input_dev *dev)
                return -EINVAL;
        }
 
-       mutex_init(&dev->mutex);
        set_bit(EV_SYN, dev->evbit);
 
        /*
@@ -959,9 +983,10 @@ int input_register_device(struct input_dev *dev)
 
 void input_unregister_device(struct input_dev *dev)
 {
-       struct list_head * node, * next;
+       struct list_head *node, *next;
 
-       if (!dev) return;
+       if (!dev)
+               return;
 
        del_timer_sync(&dev->timer);
 
@@ -979,6 +1004,10 @@ void input_unregister_device(struct input_dev *dev)
        sysfs_remove_group(&dev->cdev.kobj, &input_dev_attr_group);
        class_device_unregister(&dev->cdev);
 
+       mutex_lock(&dev->mutex);
+       dev->name = dev->phys = dev->uniq = NULL;
+       mutex_unlock(&dev->mutex);
+
        input_wakeup_procfs_readers();
 }
 
@@ -988,7 +1017,8 @@ void input_register_handler(struct input_handler *handler)
        struct input_handle *handle;
        struct input_device_id *id;
 
-       if (!handler) return;
+       if (!handler)
+               return;
 
        INIT_LIST_HEAD(&handler->h_list);
 
@@ -1008,7 +1038,7 @@ void input_register_handler(struct input_handler *handler)
 
 void input_unregister_handler(struct input_handler *handler)
 {
-       struct list_head * node, * next;
+       struct list_head *node, *next;
 
        list_for_each_safe(node, next, &handler->h_list) {
                struct input_handle * handle = to_handle_h(node);