}
 
 /*
- * Clear all the requests from the controller for which a bit has been set in
- * @mask and wait until the controller confirms that these requests have been
- * cleared.
+ * Clear the pending command in the controller and wait until
+ * the controller confirms that the command has been cleared.
+ * @hba: per adapter instance
+ * @task_tag: The tag number of the command to be cleared.
  */
-static int ufshcd_clear_cmds(struct ufs_hba *hba, u32 mask)
+static int ufshcd_clear_cmd(struct ufs_hba *hba, u32 task_tag)
 {
        unsigned long flags;
+       u32 mask = 1U << task_tag;
 
        /* clear outstanding transaction before retry */
        spin_lock_irqsave(hba->host->host_lock, flags);
                err = -ETIMEDOUT;
                dev_dbg(hba->dev, "%s: dev_cmd request timedout, tag %d\n",
                        __func__, lrbp->task_tag);
-               if (ufshcd_clear_cmds(hba, 1U << lrbp->task_tag) == 0) {
+               if (ufshcd_clear_cmd(hba, lrbp->task_tag) == 0) {
                        /* successfully cleared the command, retry if needed */
                        err = -EAGAIN;
                        /*
        unsigned long flags, pending_reqs = 0, not_cleared = 0;
        struct Scsi_Host *host;
        struct ufs_hba *hba;
-       u32 pos;
+       u32 pos, not_cleared_mask = 0;
        int err;
        u8 resp = 0xF, lun;
 
        hba->outstanding_reqs &= ~pending_reqs;
        spin_unlock_irqrestore(&hba->outstanding_lock, flags);
 
-       if (ufshcd_clear_cmds(hba, pending_reqs) < 0) {
-               spin_lock_irqsave(&hba->outstanding_lock, flags);
-               not_cleared = pending_reqs &
-                       ufshcd_readl(hba, REG_UTP_TRANSFER_REQ_DOOR_BELL);
-               hba->outstanding_reqs |= not_cleared;
-               spin_unlock_irqrestore(&hba->outstanding_lock, flags);
+       for_each_set_bit(pos, &pending_reqs, hba->nutrs) {
+               if (ufshcd_clear_cmd(hba, pos) < 0) {
+                       spin_lock_irqsave(&hba->outstanding_lock, flags);
+                       not_cleared = 1U << pos &
+                               ufshcd_readl(hba, REG_UTP_TRANSFER_REQ_DOOR_BELL);
+                       hba->outstanding_reqs |= not_cleared;
+                       not_cleared_mask |= not_cleared;
+                       spin_unlock_irqrestore(&hba->outstanding_lock, flags);
 
-               dev_err(hba->dev, "%s: failed to clear requests %#lx\n",
-                       __func__, not_cleared);
+                       dev_err(hba->dev, "%s: failed to clear request %d\n",
+                               __func__, pos);
+               }
        }
-       __ufshcd_transfer_req_compl(hba, pending_reqs & ~not_cleared);
+       __ufshcd_transfer_req_compl(hba, pending_reqs & ~not_cleared_mask);
 
 out:
        hba->req_abort_count = 0;
                goto out;
        }
 
-       err = ufshcd_clear_cmds(hba, 1U << tag);
+       err = ufshcd_clear_cmd(hba, tag);
        if (err)
                dev_err(hba->dev, "%s: Failed clearing cmd at tag %d, err %d\n",
                        __func__, tag, err);