[PATCH 1/3] nvme: split __nvme_submit_sync_cmd()

Hannes Reinecke hare at suse.de
Wed Feb 8 07:03:57 PST 2023


On 2/8/23 15:10, Kanchan Joshi wrote:
> On Wed, Feb 08, 2023 at 09:49:37AM +0100, Hannes Reinecke wrote:
>> Split a __nvme_alloc_rq() function from __nvme_submit_sync_cmd()
>> to reduce the number of arguments.
>>
>> Signed-off-by: Hannes Reinecke <hare at suse.de>
>> ---
>> drivers/nvme/host/auth.c       |  9 ++++--
>> drivers/nvme/host/core.c       | 59 ++++++++++++++++++++++------------
>> drivers/nvme/host/fabrics.c    | 42 ++++++++++++++++++------
>> drivers/nvme/host/nvme.h       |  8 ++---
>> drivers/nvme/host/pci.c        |  8 ++---
>> drivers/nvme/target/passthru.c |  3 +-
>> 6 files changed, 85 insertions(+), 44 deletions(-)
>>
>> diff --git a/drivers/nvme/host/auth.c b/drivers/nvme/host/auth.c
>> index 787537454f7f..cbb6f1cb2046 100644
>> --- a/drivers/nvme/host/auth.c
>> +++ b/drivers/nvme/host/auth.c
>> @@ -62,6 +62,7 @@ static int nvme_auth_submit(struct nvme_ctrl *ctrl, 
>> int qid,
>>     struct nvme_command cmd = {};
>>     blk_mq_req_flags_t flags = nvme_auth_flags_from_qid(qid);
>>     struct request_queue *q = nvme_auth_queue_from_qid(ctrl, qid);
>> +    struct request *req;
>>     int ret;
>>
>>     cmd.auth_common.opcode = nvme_fabrics_command;
>> @@ -76,9 +77,11 @@ static int nvme_auth_submit(struct nvme_ctrl *ctrl, 
>> int qid,
>>         cmd.auth_receive.al = cpu_to_le32(data_len);
>>     }
>>
>> -    ret = __nvme_submit_sync_cmd(q, &cmd, NULL, data, data_len,
>> -                     qid == 0 ? NVME_QID_ANY : qid,
>> -                     0, flags);
>> +    req = __nvme_alloc_rq(q, &cmd, qid == 0 ? NVME_QID_ANY : qid, 
>> flags);
>> +    if (IS_ERR(req))
>> +        return PTR_ERR(req);
>> +
>> +    ret = __nvme_submit_sync_cmd(q, req, NULL, data, data_len, 0);
> 
> First argument 'q' of above can also be killed.
> 
Indeed.

Cheers,

Hannes



More information about the Linux-nvme mailing list