Skip to content

Commit 94b1e14

Browse files
committed
src: drop result argument from submit API
The command submit API doesn't need to return explicitly the return value, it's already in struct nvme_passthru_cmd. Signed-off-by: Daniel Wagner <[email protected]>
1 parent b73c4a4 commit 94b1e14

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+803
-930
lines changed

libnvme/examples/mi-mctp-csi-test.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ int do_get_log_page(nvme_mi_ep_t ep, int argc, char **argv)
9191

9292
nvme_init_get_log(&cmd, NVME_NSID_NONE, lid, NVME_CSI_NVM,
9393
buf, sizeof(buf));
94-
rc = nvme_get_log(hdl, &cmd, false, NVME_LOG_PAGE_PDU_SIZE, NULL);
94+
rc = nvme_get_log(hdl, &cmd, false, NVME_LOG_PAGE_PDU_SIZE);
9595
if (rc) {
9696
warn("can't perform Get Log page command");
9797
return -1;

libnvme/examples/mi-mctp.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ int do_identify(nvme_mi_ep_t ep, int argc, char **argv)
216216
if (partial)
217217
cmd.data_len = offsetof(struct nvme_id_ctrl, rab);
218218

219-
rc = nvme_submit_admin_passthru(hdl, &cmd, NULL);
219+
rc = nvme_submit_admin_passthru(hdl, &cmd);
220220
if (rc) {
221221
warn("can't perform Admin Identify command");
222222
return -1;
@@ -399,7 +399,7 @@ int do_get_log_page(nvme_mi_ep_t ep, int argc, char **argv)
399399

400400
nvme_init_get_log(&cmd, NVME_NSID_NONE, lid, NVME_CSI_NVM,
401401
buf, sizeof(buf));
402-
rc = nvme_get_log(hdl, &cmd, true, NVME_LOG_PAGE_PDU_SIZE, NULL);
402+
rc = nvme_get_log(hdl, &cmd, true, NVME_LOG_PAGE_PDU_SIZE);
403403
if (rc) {
404404
warn("can't perform Get Log page command");
405405
return -1;
@@ -566,7 +566,7 @@ int do_security_info(nvme_mi_ep_t ep, int argc, char **argv)
566566
}
567567

568568
nvme_init_security_receive(&cmd, 0, 0, 0, 0, 0, data, data_len);
569-
rc = nvme_submit_admin_passthru(hdl, &cmd, NULL);
569+
rc = nvme_submit_admin_passthru(hdl, &cmd);
570570
if (rc) {
571571
warnx("can't perform Security Receive command: rc %d", rc);
572572
return -1;

libnvme/libnvme/nvme.i

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -824,7 +824,7 @@ struct nvme_ns {
824824

825825
Py_BEGIN_ALLOW_THREADS /* Release Python GIL */
826826
nvme_init_get_log_supported_log_pages(&cmd, NVME_CSI_NVM, &log);
827-
ret = nvme_get_log(nvme_ctrl_get_transport_handle($self), &cmd, rae, NVME_LOG_PAGE_PDU_SIZE, NULL);
827+
ret = nvme_get_log(nvme_ctrl_get_transport_handle($self), &cmd, rae, NVME_LOG_PAGE_PDU_SIZE);
828828
Py_END_ALLOW_THREADS /* Reacquire Python GIL */
829829

830830
if (ret) {

libnvme/src/nvme/fabrics.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1134,7 +1134,7 @@ static int nvme_discovery_log(const struct nvme_get_discovery_args *args,
11341134
nvme_msg(ctx, LOG_DEBUG, "%s: get header (try %d/%d)\n",
11351135
name, retries, args->max_retries);
11361136
nvme_init_get_log_discovery(&cmd, 0, log, DISCOVERY_HEADER_LEN);
1137-
err = nvme_get_log(hdl, &cmd, false, DISCOVERY_HEADER_LEN, NULL);
1137+
err = nvme_get_log(hdl, &cmd, false, DISCOVERY_HEADER_LEN);
11381138
if (err) {
11391139
nvme_msg(ctx, LOG_INFO,
11401140
"%s: discover try %d/%d failed, errno %d status 0x%x\n",
@@ -1168,8 +1168,7 @@ static int nvme_discovery_log(const struct nvme_get_discovery_args *args,
11681168
cmd.cdw10 |= NVME_FIELD_ENCODE(args->lsp,
11691169
NVME_LOG_CDW10_LSP_SHIFT,
11701170
NVME_LOG_CDW10_LSP_MASK);
1171-
err = nvme_get_log(hdl, &cmd, false,
1172-
NVME_LOG_PAGE_PDU_SIZE, NULL);
1171+
err = nvme_get_log(hdl, &cmd, false, NVME_LOG_PAGE_PDU_SIZE);
11731172
if (err) {
11741173
nvme_msg(ctx, LOG_INFO,
11751174
"%s: discover try %d/%d failed, errno %d status 0x%x\n",
@@ -1184,7 +1183,7 @@ static int nvme_discovery_log(const struct nvme_get_discovery_args *args,
11841183
nvme_msg(ctx, LOG_DEBUG, "%s: get header again\n", name);
11851184

11861185
nvme_init_get_log_discovery(&cmd, 0, log, DISCOVERY_HEADER_LEN);
1187-
err = nvme_get_log(hdl, &cmd, false, DISCOVERY_HEADER_LEN, NULL);
1186+
err = nvme_get_log(hdl, &cmd, false, DISCOVERY_HEADER_LEN);
11881187
if (err) {
11891188
nvme_msg(ctx, LOG_INFO,
11901189
"%s: discover try %d/%d failed, errno %d status 0x%x\n",
@@ -1669,7 +1668,7 @@ static int nvmf_dim(nvme_ctrl_t c, enum nvmf_dim_tas tas, __u8 trtype,
16691668
nvmf_fill_die(die, c->s->h, tel, trtype, adrfam, reg_addr, tsas);
16701669

16711670
nvme_init_dim_send(&cmd, tas, dim, tdl);
1672-
return nvme_submit_admin_passthru(hdl, &cmd, NULL);
1671+
return nvme_submit_admin_passthru(hdl, &cmd);
16731672
}
16741673

16751674
/**

libnvme/src/nvme/ioctl.c

Lines changed: 13 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,7 @@ bool __nvme_decide_retry(struct nvme_transport_handle *hdl,
119119
* compatibility keep a 32 version.
120120
*/
121121
static int nvme_submit_passthru32(struct nvme_transport_handle *hdl,
122-
unsigned long ioctl_cmd, struct nvme_passthru_cmd *cmd,
123-
__u64 *result)
122+
unsigned long ioctl_cmd, struct nvme_passthru_cmd *cmd)
124123
{
125124
struct linux_passthru_cmd32 cmd32;
126125
void *user_data;
@@ -142,9 +141,6 @@ static int nvme_submit_passthru32(struct nvme_transport_handle *hdl,
142141

143142
out:
144143
cmd->result = cmd32.result;
145-
if (err >= 0 && result)
146-
*result = cmd->result;
147-
148144
hdl->submit_exit(hdl, cmd, err, user_data);
149145
return err;
150146
}
@@ -154,8 +150,7 @@ static int nvme_submit_passthru32(struct nvme_transport_handle *hdl,
154150
* 65e68edce0db ("nvme: allow 64-bit results in passthru commands")
155151
*/
156152
static int nvme_submit_passthru64(struct nvme_transport_handle *hdl,
157-
unsigned long ioctl_cmd, struct nvme_passthru_cmd *cmd,
158-
__u64 *result)
153+
unsigned long ioctl_cmd, struct nvme_passthru_cmd *cmd)
159154
{
160155
void *user_data;
161156
int err = 0;
@@ -176,36 +171,32 @@ static int nvme_submit_passthru64(struct nvme_transport_handle *hdl,
176171
} while (hdl->decide_retry(hdl, cmd, err));
177172

178173
out:
179-
if (err >= 0 && result)
180-
*result = cmd->result;
181-
182174
hdl->submit_exit(hdl, cmd, err, user_data);
183175
return err;
184176
}
185177

186178
int nvme_submit_io_passthru(struct nvme_transport_handle *hdl,
187-
struct nvme_passthru_cmd *cmd, __u64 *result)
179+
struct nvme_passthru_cmd *cmd)
188180
{
189181
if (hdl->ioctl64)
190-
return nvme_submit_passthru64(hdl,
191-
NVME_IOCTL_IO64_CMD, cmd, result);
192-
return nvme_submit_passthru32(hdl, NVME_IOCTL_IO_CMD, cmd, result);
182+
return nvme_submit_passthru64(hdl, NVME_IOCTL_IO64_CMD, cmd);
183+
return nvme_submit_passthru32(hdl, NVME_IOCTL_IO_CMD, cmd);
193184
}
194185

195186
int nvme_submit_admin_passthru(struct nvme_transport_handle *hdl,
196-
struct nvme_passthru_cmd *cmd, __u64 *result)
187+
struct nvme_passthru_cmd *cmd)
197188
{
198189
switch (hdl->type) {
199190
case NVME_TRANSPORT_HANDLE_TYPE_DIRECT:
200191
if (hdl->ioctl64)
201192
return nvme_submit_passthru64(hdl,
202-
NVME_IOCTL_ADMIN64_CMD, cmd, result);
193+
NVME_IOCTL_ADMIN64_CMD, cmd);
203194
if (cmd->opcode == nvme_admin_fabrics)
204195
return -ENOTSUP;
205196
return nvme_submit_passthru32(hdl,
206-
NVME_IOCTL_ADMIN_CMD, cmd, result);
197+
NVME_IOCTL_ADMIN_CMD, cmd);
207198
case NVME_TRANSPORT_HANDLE_TYPE_MI:
208-
return nvme_mi_admin_admin_passthru(hdl, cmd, result);
199+
return nvme_mi_admin_admin_passthru(hdl, cmd);
209200
default:
210201
break;
211202
}
@@ -332,7 +323,7 @@ static bool nvme_uring_is_usable(struct nvme_transport_handle *hdl)
332323

333324
int nvme_get_log(struct nvme_transport_handle *hdl,
334325
struct nvme_passthru_cmd *cmd, bool rae,
335-
__u32 xfer_len, __u64 *result)
326+
__u32 xfer_len)
336327
{
337328
__u64 offset = 0, xfer, data_len = cmd->data_len;
338329
__u64 start = (__u64)cmd->cdw13 << 32 | cmd->cdw12;
@@ -407,12 +398,12 @@ int nvme_get_log(struct nvme_transport_handle *hdl,
407398
if (ret)
408399
nvme_uring_cmd_exit(&ring);
409400
} else {
410-
ret = nvme_submit_admin_passthru(hdl, cmd, result);
401+
ret = nvme_submit_admin_passthru(hdl, cmd);
411402
if (ret)
412403
return ret;
413404
}
414405
#else /* CONFIG_LIBURING */
415-
ret = nvme_submit_admin_passthru(hdl, cmd, result);
406+
ret = nvme_submit_admin_passthru(hdl, cmd);
416407
#endif /* CONFIG_LIBURING */
417408
if (ret)
418409
return ret;
@@ -446,7 +437,7 @@ static int read_ana_chunk(struct nvme_transport_handle *hdl, enum nvme_log_ana_l
446437
int ret;
447438

448439
nvme_init_get_log_ana(&cmd, lsp, *read - log, *read, len);
449-
ret = nvme_get_log(hdl, &cmd, rae, NVME_LOG_PAGE_PDU_SIZE, NULL);
440+
ret = nvme_get_log(hdl, &cmd, rae, NVME_LOG_PAGE_PDU_SIZE);
450441
if (ret)
451442
return ret;
452443

0 commit comments

Comments
 (0)