Do that in preparation to re-use ufshcd_issue_tm_cmd code.

Signed-off-by: Avri Altman <avri.alt...@wdc.com>
---
 drivers/scsi/ufs/ufshcd.c | 50 +++++++++++++++++++++++++++--------------------
 1 file changed, 29 insertions(+), 21 deletions(-)

diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
index c2ae406..4206bab 100644
--- a/drivers/scsi/ufs/ufshcd.c
+++ b/drivers/scsi/ufs/ufshcd.c
@@ -5597,6 +5597,32 @@ static int ufshcd_clear_tm_cmd(struct ufs_hba *hba, int 
tag)
        return err;
 }
 
+static void ufshcd_fill_tm_req(struct utp_task_req_desc *task_req_descp,
+                              int lun_id, int task_id, u8 tm_function,
+                              int task_tag)
+{
+       struct utp_upiu_task_req *task_req_upiup;
+
+       /* Configure task request descriptor */
+       task_req_descp->header.dword_0 = cpu_to_le32(UTP_REQ_DESC_INT_CMD);
+       task_req_descp->header.dword_2 =
+                       cpu_to_le32(OCS_INVALID_COMMAND_STATUS);
+
+       task_req_upiup =
+               (struct utp_upiu_task_req *)task_req_descp->task_req_upiu;
+       task_req_upiup->header.dword_0 =
+               UPIU_HEADER_DWORD(UPIU_TRANSACTION_TASK_REQ, 0, lun_id,
+                                 task_tag);
+       task_req_upiup->header.dword_1 = UPIU_HEADER_DWORD(0, tm_function, 0,
+                                                          0);
+       /*
+        * The host shall provide the same value for LUN field in the basic
+        * header and for Input Parameter.
+        */
+       task_req_upiup->input_param1 = cpu_to_be32(lun_id);
+       task_req_upiup->input_param2 = cpu_to_be32(task_id);
+}
+
 /**
  * ufshcd_issue_tm_cmd - issues task management commands to controller
  * @hba: per adapter instance
@@ -5611,7 +5637,6 @@ static int ufshcd_issue_tm_cmd(struct ufs_hba *hba, int 
lun_id, int task_id,
                u8 tm_function, u8 *tm_response)
 {
        struct utp_task_req_desc *task_req_descp;
-       struct utp_upiu_task_req *task_req_upiup;
        struct Scsi_Host *host;
        unsigned long flags;
        int free_slot;
@@ -5631,27 +5656,10 @@ static int ufshcd_issue_tm_cmd(struct ufs_hba *hba, int 
lun_id, int task_id,
        spin_lock_irqsave(host->host_lock, flags);
        task_req_descp = hba->utmrdl_base_addr;
        task_req_descp += free_slot;
-
-       /* Configure task request descriptor */
-       task_req_descp->header.dword_0 = cpu_to_le32(UTP_REQ_DESC_INT_CMD);
-       task_req_descp->header.dword_2 =
-                       cpu_to_le32(OCS_INVALID_COMMAND_STATUS);
-
-       /* Configure task request UPIU */
-       task_req_upiup =
-               (struct utp_upiu_task_req *) task_req_descp->task_req_upiu;
        task_tag = hba->nutrs + free_slot;
-       task_req_upiup->header.dword_0 =
-               UPIU_HEADER_DWORD(UPIU_TRANSACTION_TASK_REQ, 0,
-                                             lun_id, task_tag);
-       task_req_upiup->header.dword_1 =
-               UPIU_HEADER_DWORD(0, tm_function, 0, 0);
-       /*
-        * The host shall provide the same value for LUN field in the basic
-        * header and for Input Parameter.
-        */
-       task_req_upiup->input_param1 = cpu_to_be32(lun_id);
-       task_req_upiup->input_param2 = cpu_to_be32(task_id);
+
+       ufshcd_fill_tm_req(task_req_descp, lun_id, task_id, tm_function,
+                          task_tag);
 
        ufshcd_vops_setup_task_mgmt(hba, free_slot, tm_function);
 
-- 
1.9.1

Reply via email to