scsi: ufs: core: Simplify ufshcd_execute_start_stop()

Use scsi_execute_cmd() instead of open-coding it.

Link: https://lore.kernel.org/r/20230210193258.4004923-4-bvanassche@acm.org
Cc: Mike Christie <michael.christie@oracle.com>
Cc: John Garry <john.g.garry@oracle.com>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Reviewed-by: John Garry <john.g.garry@oracle.com>
Reviewed-by: Asutosh Das <quic_asutoshd@quicinc.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
This commit is contained in:
Bart Van Assche 2023-02-10 11:32:58 -08:00 committed by Martin K. Petersen
parent 93bc4a5d00
commit 2702812ae3

View File

@ -9134,34 +9134,15 @@ static int ufshcd_execute_start_stop(struct scsi_device *sdev,
enum ufs_dev_pwr_mode pwr_mode,
struct scsi_sense_hdr *sshdr)
{
unsigned char cdb[6] = { START_STOP, 0, 0, 0, pwr_mode << 4, 0 };
struct request *req;
struct scsi_cmnd *scmd;
int ret;
const unsigned char cdb[6] = { START_STOP, 0, 0, 0, pwr_mode << 4, 0 };
const struct scsi_exec_args args = {
.sshdr = sshdr,
.req_flags = BLK_MQ_REQ_PM,
.scmd_flags = SCMD_FAIL_IF_RECOVERING,
};
req = scsi_alloc_request(sdev->request_queue, REQ_OP_DRV_IN,
BLK_MQ_REQ_PM);
if (IS_ERR(req))
return PTR_ERR(req);
scmd = blk_mq_rq_to_pdu(req);
scmd->cmd_len = COMMAND_SIZE(cdb[0]);
memcpy(scmd->cmnd, cdb, scmd->cmd_len);
scmd->allowed = 0/*retries*/;
scmd->flags |= SCMD_FAIL_IF_RECOVERING;
req->timeout = 1 * HZ;
req->rq_flags |= RQF_QUIET;
blk_execute_rq(req, /*at_head=*/true);
if (sshdr)
scsi_normalize_sense(scmd->sense_buffer, scmd->sense_len,
sshdr);
ret = scmd->result;
blk_mq_free_request(req);
return ret;
return scsi_execute_cmd(sdev, cdb, REQ_OP_DRV_IN, /*buffer=*/NULL,
/*bufflen=*/0, /*timeout=*/HZ, /*retries=*/0, &args);
}
/**