Skip to content

Commit 971bd53

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 af5c79c commit 971bd53

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

+806
-931
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: 16 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,7 @@ bool nvme_decide_retry(struct nvme_transport_handle *hdl,
122122
* compatiblity keep a 32 version.
123123
*/
124124
static int nvme_submit_passthru32(struct nvme_transport_handle *hdl,
125-
unsigned long ioctl_cmd, struct nvme_passthru_cmd *cmd,
126-
__u64 *result)
125+
unsigned long ioctl_cmd, struct nvme_passthru_cmd *cmd)
127126
{
128127
struct linux_passthru_cmd32 cmd32;
129128
void *user_data;
@@ -143,8 +142,6 @@ static int nvme_submit_passthru32(struct nvme_transport_handle *hdl,
143142
} while (nvme_decide_retry(hdl, cmd, -errno));
144143

145144
cmd->result = cmd32.result;
146-
if (err >= 0 && result)
147-
*result = cmd->result;
148145
if (err < 0)
149146
err = -errno;
150147

@@ -158,8 +155,7 @@ static int nvme_submit_passthru32(struct nvme_transport_handle *hdl,
158155
* 65e68edce0db ("nvme: allow 64-bit results in passthru commands")
159156
*/
160157
static int nvme_submit_passthru64(struct nvme_transport_handle *hdl,
161-
unsigned long ioctl_cmd, struct nvme_passthru_cmd *cmd,
162-
__u64 *result)
158+
unsigned long ioctl_cmd, struct nvme_passthru_cmd *cmd)
163159
{
164160
void *user_data;
165161
int err = 0;
@@ -178,39 +174,36 @@ static int nvme_submit_passthru64(struct nvme_transport_handle *hdl,
178174
break;
179175
} while (nvme_decide_retry(hdl, cmd, -errno));
180176

177+
if (err < 0)
178+
err = -errno;
179+
181180
out:
182181
nvme_submit_exit(hdl, cmd, err, user_data);
183-
184-
if (err >= 0 && result)
185-
*result = cmd->result;
186-
if (err < 0)
187-
return -errno;
188182
return err;
189183
}
190184

191185
int nvme_submit_io_passthru(struct nvme_transport_handle *hdl,
192-
struct nvme_passthru_cmd *cmd, __u64 *result)
186+
struct nvme_passthru_cmd *cmd)
193187
{
194188
if (hdl->ioctl64)
195-
return nvme_submit_passthru64(hdl,
196-
NVME_IOCTL_IO64_CMD, cmd, result);
197-
return nvme_submit_passthru32(hdl, NVME_IOCTL_IO_CMD, cmd, result);
189+
return nvme_submit_passthru64(hdl, NVME_IOCTL_IO64_CMD, cmd);
190+
return nvme_submit_passthru32(hdl, NVME_IOCTL_IO_CMD, cmd);
198191
}
199192

200193
int nvme_submit_admin_passthru(struct nvme_transport_handle *hdl,
201-
struct nvme_passthru_cmd *cmd, __u64 *result)
194+
struct nvme_passthru_cmd *cmd)
202195
{
203196
switch (hdl->type) {
204197
case NVME_TRANSPORT_HANDLE_TYPE_DIRECT:
205198
if (hdl->ioctl64)
206199
return nvme_submit_passthru64(hdl,
207-
NVME_IOCTL_ADMIN64_CMD, cmd, result);
200+
NVME_IOCTL_ADMIN64_CMD, cmd);
208201
if (cmd->opcode == nvme_admin_fabrics)
209202
return -ENOTSUP;
210203
return nvme_submit_passthru32(hdl,
211-
NVME_IOCTL_ADMIN_CMD, cmd, result);
204+
NVME_IOCTL_ADMIN_CMD, cmd);
212205
case NVME_TRANSPORT_HANDLE_TYPE_MI:
213-
return nvme_mi_admin_admin_passthru(hdl, cmd, result);
206+
return nvme_mi_admin_admin_passthru(hdl, cmd);
214207
default:
215208
break;
216209
}
@@ -337,7 +330,7 @@ static bool nvme_uring_is_usable(struct nvme_transport_handle *hdl)
337330

338331
int nvme_get_log(struct nvme_transport_handle *hdl,
339332
struct nvme_passthru_cmd *cmd, bool rae,
340-
__u32 xfer_len, __u64 *result)
333+
__u32 xfer_len)
341334
{
342335
__u64 offset = 0, xfer, data_len = cmd->data_len;
343336
__u64 start = (__u64)cmd->cdw13 << 32 | cmd->cdw12;
@@ -412,12 +405,12 @@ int nvme_get_log(struct nvme_transport_handle *hdl,
412405
if (ret)
413406
nvme_uring_cmd_exit(&ring);
414407
} else {
415-
ret = nvme_submit_admin_passthru(hdl, cmd, result);
408+
ret = nvme_submit_admin_passthru(hdl, cmd);
416409
if (ret)
417410
return ret;
418411
}
419412
#else /* CONFIG_LIBURING */
420-
ret = nvme_submit_admin_passthru(hdl, cmd, result);
413+
ret = nvme_submit_admin_passthru(hdl, cmd);
421414
#endif /* CONFIG_LIBURING */
422415
if (ret)
423416
return ret;
@@ -451,7 +444,7 @@ static int read_ana_chunk(struct nvme_transport_handle *hdl, enum nvme_log_ana_l
451444
int ret;
452445

453446
nvme_init_get_log_ana(&cmd, lsp, *read - log, *read, len);
454-
ret = nvme_get_log(hdl, &cmd, rae, NVME_LOG_PAGE_PDU_SIZE, NULL);
447+
ret = nvme_get_log(hdl, &cmd, rae, NVME_LOG_PAGE_PDU_SIZE);
455448
if (ret)
456449
return ret;
457450

0 commit comments

Comments
 (0)