[PATCH 3/3] nvmet-auth: use helper for auth send/recv cmd prep
Chaitanya Kulkarni
kch at nvidia.com
Mon May 22 01:37:13 PDT 2023
Add a common helper to factor out secp/spsp values check and transfer
buffer allocation in nvmet_execute_auth_send() and
nvmet_execute_auth_receive().
Signed-off-by: Chaitanya Kulkarni <kch at nvidia.com>
---
drivers/nvme/target/fabrics-cmd-auth.c | 17 +++++++++--------
1 file changed, 9 insertions(+), 8 deletions(-)
diff --git a/drivers/nvme/target/fabrics-cmd-auth.c b/drivers/nvme/target/fabrics-cmd-auth.c
index ad8e914ae56f..8200265734e1 100644
--- a/drivers/nvme/target/fabrics-cmd-auth.c
+++ b/drivers/nvme/target/fabrics-cmd-auth.c
@@ -41,6 +41,13 @@ static u16 nvmet_auth_alloc_transfer_buffer(struct nvmet_req *req, void **buf,
return *buf ? NVME_SC_SUCCESS : NVME_SC_INTERNAL;
}
+static u16 nvmet_auth_common_prep(struct nvmet_req *req, void **buf, u32 *len)
+{
+ u16 sts = nvmet_auth_check_secp_spsp(req);
+
+ return sts ? sts : nvmet_auth_alloc_transfer_buffer(req, buf, len);
+}
+
static void nvmet_auth_expired_work(struct work_struct *work)
{
struct nvmet_sq *sq = container_of(to_delayed_work(work),
@@ -216,10 +223,7 @@ void nvmet_execute_auth_send(struct nvmet_req *req)
u32 tl;
u16 status;
- status = nvmet_auth_check_secp_spsp(req);
- if (status)
- goto done;
- status = nvmet_auth_alloc_transfer_buffer(req, &d, &tl);
+ status = nvmet_auth_common_prep(req, &d, &tl);
if (status)
goto done;
@@ -440,10 +444,7 @@ void nvmet_execute_auth_receive(struct nvmet_req *req)
u32 al;
u16 status;
- status = nvmet_auth_check_secp_spsp(req);
- if (status)
- goto done;
- status = nvmet_auth_alloc_transfer_buffer(req, &d, &al);
+ status = nvmet_auth_common_prep(req, &d, &al);
if (status)
goto done;
if (!nvmet_check_transfer_len(req, al)) {
--
2.40.0
More information about the Linux-nvme
mailing list