include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit...
[safe/jmp/linux-2.6] / drivers / hid / usbhid / hid-pidff.c
index f5a90e9..ef381d7 100644 (file)
@@ -25,6 +25,7 @@
 #define debug(format, arg...) pr_debug("hid-pidff: " format "\n" , ## arg)
 
 #include <linux/input.h>
+#include <linux/slab.h>
 #include <linux/usb.h>
 
 #include <linux/hid.h>
@@ -397,7 +398,6 @@ static void pidff_set_condition_report(struct pidff_device *pidff,
                          effect->u.condition[i].left_saturation);
                pidff_set(&pidff->set_condition[PID_DEAD_BAND],
                          effect->u.condition[i].deadband);
-               usbhid_wait_io(pidff->hid);
                usbhid_submit_report(pidff->hid, pidff->reports[PID_SET_CONDITION],
                                  USB_DIR_OUT);
        }
@@ -512,7 +512,6 @@ static void pidff_playback_pid(struct pidff_device *pidff, int pid_id, int n)
                pidff->effect_operation[PID_LOOP_COUNT].value[0] = n;
        }
 
-       usbhid_wait_io(pidff->hid);
        usbhid_submit_report(pidff->hid, pidff->reports[PID_EFFECT_OPERATION],
                          USB_DIR_OUT);
 }
@@ -548,6 +547,9 @@ static int pidff_erase_effect(struct input_dev *dev, int effect_id)
        int pid_id = pidff->pid_id[effect_id];
 
        debug("starting to erase %d/%d", effect_id, pidff->pid_id[effect_id]);
+       /* Wait for the queue to clear. We do not want a full fifo to
+          prevent the effect removal. */
+       usbhid_wait_io(pidff->hid);
        pidff_playback_pid(pidff, pid_id, 0);
        pidff_erase_pid(pidff, pid_id);
 
@@ -738,6 +740,7 @@ static void pidff_autocenter(struct pidff_device *pidff, u16 magnitude)
        pidff->set_effect[PID_TRIGGER_BUTTON].value[0] = 0;
        pidff->set_effect[PID_TRIGGER_REPEAT_INT].value[0] = 0;
        pidff_set(&pidff->set_effect[PID_GAIN], magnitude);
+       pidff->set_effect[PID_DIRECTION_ENABLE].value[0] = 1;
        pidff->set_effect[PID_START_DELAY].value[0] = 0;
 
        usbhid_submit_report(pidff->hid, pidff->reports[PID_SET_EFFECT],
@@ -1179,12 +1182,11 @@ static void pidff_reset(struct pidff_device *pidff)
        usbhid_wait_io(hid);
 
        if (pidff->pool[PID_SIMULTANEOUS_MAX].value) {
-               int sim_effects = pidff->pool[PID_SIMULTANEOUS_MAX].value[0];
-               while (sim_effects < 2) {
+               while (pidff->pool[PID_SIMULTANEOUS_MAX].value[0] < 2) {
                        if (i++ > 20) {
                                printk(KERN_WARNING "hid-pidff: device reports "
                                       "%d simultaneous effects\n",
-                                      sim_effects);
+                                      pidff->pool[PID_SIMULTANEOUS_MAX].value[0]);
                                break;
                        }
                        debug("pid_pool requested again");