NFC: port100: Make port100_abort_cmd() synchronous
authorThierry Escande <thierry.escande@collabora.com>
Thu, 16 Jun 2016 18:25:22 +0000 (20:25 +0200)
committerSamuel Ortiz <sameo@linux.intel.com>
Wed, 6 Jul 2016 08:02:08 +0000 (10:02 +0200)
This patch makes the abort_cmd function synchronous. This allows the
caller to immediately send a new command after abort_cmd() returns.

Signed-off-by: Thierry Escande <thierry.escande@collabora.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
drivers/nfc/port100.c

index 909e3df2c16a98e186877188739ac4f695380020..481cb435e19f3e240c6a7601c3e5ec40bd4b69c8 100644 (file)
@@ -472,6 +472,7 @@ struct port100 {
        struct port100_cmd *cmd;
 
        bool cmd_cancel;
+       struct completion cmd_cancel_done;
 };
 
 struct port100_cmd {
@@ -728,6 +729,8 @@ static int port100_send_ack(struct port100 *dev)
 
        mutex_lock(&dev->out_urb_lock);
 
+       init_completion(&dev->cmd_cancel_done);
+
        usb_kill_urb(dev->out_urb);
 
        dev->out_urb->transfer_buffer = ack_frame;
@@ -742,6 +745,9 @@ static int port100_send_ack(struct port100 *dev)
 
        mutex_unlock(&dev->out_urb_lock);
 
+       if (!rc)
+               wait_for_completion(&dev->cmd_cancel_done);
+
        return rc;
 }
 
@@ -921,7 +927,10 @@ static void port100_send_complete(struct urb *urb)
 {
        struct port100 *dev = urb->context;
 
-       dev->cmd_cancel = false;
+       if (dev->cmd_cancel) {
+               dev->cmd_cancel = false;
+               complete(&dev->cmd_cancel_done);
+       }
 
        switch (urb->status) {
        case 0: