From: Daniel Wagner Date: Fri, 12 Apr 2024 11:03:27 +0000 (+0200) Subject: Revert "ioctl: Update stub functions to match documentation" X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=0e5c80a71280ee4482b39a48b5edfbd438938191;p=users%2Fsagi%2Flibnvme.git Revert "ioctl: Update stub functions to match documentation" This reverts commit 4eb7c9e662751d4fb5d1837b8d700e33aef7ab9f. The result field is undefined for many commands and thus can have random values. Thus we can't blindly evaluate these for all commands. Signed-off-by: Daniel Wagner --- diff --git a/src/nvme/ioctl.h b/src/nvme/ioctl.h index d3eeb5ea..89130132 100644 --- a/src/nvme/ioctl.h +++ b/src/nvme/ioctl.h @@ -575,13 +575,11 @@ int nvme_get_nsid(int fd, __u32 *nsid); */ int nvme_identify(struct nvme_identify_args *args); -static inline int nvme_identify_cns_nsid(int fd, - enum nvme_identify_cns cns, __u32 nsid, void *data) +static inline int nvme_identify_cns_nsid(int fd, enum nvme_identify_cns cns, + __u32 nsid, void *data) { - __u32 result = 0; - int err; struct nvme_identify_args args = { - .result = &result, + .result = NULL, .data = data, .args_size = sizeof(args), .fd = fd, @@ -594,10 +592,7 @@ static inline int nvme_identify_cns_nsid(int fd, .uuidx = NVME_UUID_NONE, }; - err = nvme_identify(&args); - if (err < 0 && result) - err = result; - return err; + return nvme_identify(&args); } /** @@ -723,8 +718,6 @@ static inline int nvme_identify_allocated_ns_list(int fd, __u32 nsid, static inline int nvme_identify_ctrl_list(int fd, __u16 cntid, struct nvme_ctrl_list *cntlist) { - __u32 result = 0; - int err; struct nvme_identify_args args = { .result = NULL, .data = cntlist, @@ -739,10 +732,7 @@ static inline int nvme_identify_ctrl_list(int fd, __u16 cntid, .uuidx = NVME_UUID_NONE, }; - err = nvme_identify(&args); - if (err && result) - err = result; - return err; + return nvme_identify(&args); } /** @@ -761,13 +751,11 @@ static inline int nvme_identify_ctrl_list(int fd, __u16 cntid, * Return: The nvme command status if a response was received (see * &enum nvme_status_field) or -1 */ -static inline int nvme_identify_nsid_ctrl_list(int fd, __u32 nsid, - __u16 cntid, struct nvme_ctrl_list *cntlist) +static inline int nvme_identify_nsid_ctrl_list(int fd, __u32 nsid, __u16 cntid, + struct nvme_ctrl_list *cntlist) { - __u32 result = 0; - int err; struct nvme_identify_args args = { - .result = &result, + .result = NULL, .data = cntlist, .args_size = sizeof(args), .fd = fd, @@ -780,10 +768,7 @@ static inline int nvme_identify_nsid_ctrl_list(int fd, __u32 nsid, .uuidx = NVME_UUID_NONE, }; - err = nvme_identify(&args); - if (err && result) - err = result; - return err; + return nvme_identify(&args); } /** @@ -829,10 +814,8 @@ static inline int nvme_identify_ns_descs(int fd, __u32 nsid, static inline int nvme_identify_nvmset_list(int fd, __u16 nvmsetid, struct nvme_id_nvmset_list *nvmset) { - __u32 result = 0; - int err; struct nvme_identify_args args = { - .result = &result, + .result = NULL, .data = nvmset, .args_size = sizeof(args), .fd = fd, @@ -845,10 +828,7 @@ static inline int nvme_identify_nvmset_list(int fd, __u16 nvmsetid, .uuidx = NVME_UUID_NONE, }; - err = nvme_identify(&args); - if (err && result) - err = result; - return err; + return nvme_identify(&args); } /** @@ -866,10 +846,8 @@ static inline int nvme_identify_nvmset_list(int fd, __u16 nvmsetid, static inline int nvme_identify_primary_ctrl(int fd, __u16 cntid, struct nvme_primary_ctrl_cap *cap) { - __u32 result = 0; - int err; struct nvme_identify_args args = { - .result = &result, + .result = NULL, .data = cap, .args_size = sizeof(args), .fd = fd, @@ -882,10 +860,7 @@ static inline int nvme_identify_primary_ctrl(int fd, __u16 cntid, .uuidx = NVME_UUID_NONE, }; - err = nvme_identify(&args); - if (err && result) - err = result; - return err; + return nvme_identify(&args); } /** @@ -908,10 +883,8 @@ static inline int nvme_identify_primary_ctrl(int fd, __u16 cntid, static inline int nvme_identify_secondary_ctrl_list(int fd, __u16 cntid, struct nvme_secondary_ctrl_list *sc_list) { - __u32 result = 0; - int err; struct nvme_identify_args args = { - .result = &result, + .result = NULL, .data = sc_list, .args_size = sizeof(args), .fd = fd, @@ -924,10 +897,7 @@ static inline int nvme_identify_secondary_ctrl_list(int fd, .uuidx = NVME_UUID_NONE, }; - err = nvme_identify(&args); - if (err && result) - err = result; - return err; + return nvme_identify(&args); } /** @@ -990,10 +960,8 @@ static inline int nvme_identify_uuid(int fd, static inline int nvme_identify_ns_csi(int fd, __u32 nsid, __u8 uuidx, enum nvme_csi csi, void *data) { - __u32 result; - int err; struct nvme_identify_args args = { - .result = &result, + .result = NULL, .data = data, .args_size = sizeof(args), .fd = fd, @@ -1006,10 +974,7 @@ static inline int nvme_identify_ns_csi(int fd, __u32 nsid, __u8 uuidx, .uuidx = uuidx, }; - err = nvme_identify(&args); - if (err && result) - err = result; - return err; + return nvme_identify(&args); } /** @@ -1025,13 +990,10 @@ static inline int nvme_identify_ns_csi(int fd, __u32 nsid, __u8 uuidx, * Return: The nvme command status if a response was received (see * &enum nvme_status_field) or -1 with errno set otherwise. */ -static inline int nvme_identify_ctrl_csi(int fd, enum nvme_csi csi, - void *data) +static inline int nvme_identify_ctrl_csi(int fd, enum nvme_csi csi, void *data) { - __u32 result; - int err; struct nvme_identify_args args = { - .result = &result, + .result = NULL, .data = data, .args_size = sizeof(args), .fd = fd, @@ -1044,10 +1006,7 @@ static inline int nvme_identify_ctrl_csi(int fd, enum nvme_csi csi, .uuidx = NVME_UUID_NONE, }; - err = nvme_identify(&args); - if (err && result) - err = result; - return err; + return nvme_identify(&args); } /** @@ -1070,10 +1029,8 @@ static inline int nvme_identify_ctrl_csi(int fd, enum nvme_csi csi, static inline int nvme_identify_active_ns_list_csi(int fd, __u32 nsid, enum nvme_csi csi, struct nvme_ns_list *ns_list) { - __u32 result; - int err; struct nvme_identify_args args = { - .result = &result, + .result = NULL, .data = ns_list, .args_size = sizeof(args), .fd = fd, @@ -1086,10 +1043,7 @@ static inline int nvme_identify_active_ns_list_csi(int fd, __u32 nsid, .uuidx = NVME_UUID_NONE, }; - err = nvme_identify(&args); - if (err && result) - err = result; - return err; + return nvme_identify(&args); } /** @@ -1112,10 +1066,8 @@ static inline int nvme_identify_active_ns_list_csi(int fd, __u32 nsid, static inline int nvme_identify_allocated_ns_list_csi(int fd, __u32 nsid, enum nvme_csi csi, struct nvme_ns_list *ns_list) { - __u32 result = 0; - int err; struct nvme_identify_args args = { - .result = &result, + .result = NULL, .data = ns_list, .args_size = sizeof(args), .fd = fd, @@ -1128,10 +1080,7 @@ static inline int nvme_identify_allocated_ns_list_csi(int fd, __u32 nsid, .uuidx = NVME_UUID_NONE, }; - err = nvme_identify(&args); - if (err && result) - err = result; - return err; + return nvme_identify(&args); } /** @@ -1172,10 +1121,8 @@ static inline int nvme_identify_ns_csi_user_data_format(int fd, __u16 user_data_format, __u8 uuidx, enum nvme_csi csi, void *data) { - __u32 result = 0; - int err; struct nvme_identify_args args = { - .result = &result, + .result = NULL, .data = data, .args_size = sizeof(args), .fd = fd, @@ -1188,10 +1135,7 @@ static inline int nvme_identify_ns_csi_user_data_format(int fd, .uuidx = uuidx, }; - err = nvme_identify(&args); - if (err && result) - err = result; - return err; + return nvme_identify(&args); } /** @@ -1213,10 +1157,8 @@ static inline int nvme_identify_iocs_ns_csi_user_data_format(int fd, __u16 user_data_format, __u8 uuidx, enum nvme_csi csi, void *data) { - __u32 result = 0; - int err; struct nvme_identify_args args = { - .result = &result, + .result = NULL, .data = data, .args_size = sizeof(args), .fd = fd, @@ -1229,10 +1171,7 @@ static inline int nvme_identify_iocs_ns_csi_user_data_format(int fd, .uuidx = uuidx, }; - err = nvme_identify(&args); - if (err && result) - err = result; - return err; + return nvme_identify(&args); } /** @@ -1270,10 +1209,8 @@ static inline int nvme_nvm_identify_ctrl(int fd, struct nvme_id_ctrl_nvm *id) static inline int nvme_identify_domain_list(int fd, __u16 domid, struct nvme_id_domain_list *list) { - __u32 result = 0; - int err; struct nvme_identify_args args = { - .result = &result, + .result = NULL, .data = list, .args_size = sizeof(args), .fd = fd, @@ -1286,10 +1223,7 @@ static inline int nvme_identify_domain_list(int fd, __u16 domid, .uuidx = NVME_UUID_NONE, }; - err = nvme_identify(&args); - if (err && result) - err = result; - return err; + return nvme_identify(&args); } /** @@ -1304,10 +1238,8 @@ static inline int nvme_identify_domain_list(int fd, __u16 domid, static inline int nvme_identify_endurance_group_list(int fd, __u16 endgrp_id, struct nvme_id_endurance_group_list *list) { - __u32 result = 0; - int err; struct nvme_identify_args args = { - .result = &result, + .result = NULL, .data = list, .args_size = sizeof(args), .fd = fd, @@ -1320,10 +1252,7 @@ static inline int nvme_identify_endurance_group_list(int fd, __u16 endgrp_id, .uuidx = NVME_UUID_NONE, }; - err = nvme_identify(&args); - if (err && result) - err = result; - return err; + return nvme_identify(&args); } /** @@ -1341,10 +1270,8 @@ static inline int nvme_identify_endurance_group_list(int fd, __u16 endgrp_id, static inline int nvme_identify_iocs(int fd, __u16 cntlid, struct nvme_id_iocs *iocs) { - __u32 result; - int err; struct nvme_identify_args args = { - .result = &result, + .result = NULL, .data = iocs, .args_size = sizeof(args), .fd = fd, @@ -1357,10 +1284,7 @@ static inline int nvme_identify_iocs(int fd, __u16 cntlid, .uuidx = NVME_UUID_NONE, }; - err = nvme_identify(&args); - if (err && result) - err = result; - return err; + return nvme_identify(&args); } /** @@ -1414,11 +1338,9 @@ static inline int nvme_get_nsid_log(int fd, bool rae, enum nvme_cmd_get_log_lid lid, __u32 nsid, __u32 len, void *log) { - __u32 result = 0; - int err; struct nvme_get_log_args args = { .lpo = 0, - .result = &result, + .result = NULL, .log = log, .args_size = sizeof(args), .fd = fd, @@ -1434,14 +1356,11 @@ static inline int nvme_get_nsid_log(int fd, bool rae, .ot = false, }; - err = nvme_get_log_page(fd, NVME_LOG_PAGE_PDU_SIZE, &args); - if (err && result) - err = result; - return err; + return nvme_get_log_page(fd, NVME_LOG_PAGE_PDU_SIZE, &args); } -static inline int nvme_get_log_simple(int fd, - enum nvme_cmd_get_log_lid lid, __u32 len, void *log) +static inline int nvme_get_log_simple(int fd, enum nvme_cmd_get_log_lid lid, + __u32 len, void *log) { return nvme_get_nsid_log(fd, false, lid, NVME_NSID_ALL, len, log); } @@ -1563,11 +1482,9 @@ static inline int nvme_get_log_changed_ns_list(int fd, bool rae, static inline int nvme_get_log_cmd_effects(int fd, enum nvme_csi csi, struct nvme_cmd_effects_log *effects_log) { - __u32 result = 0; - int err; struct nvme_get_log_args args = { .lpo = 0, - .result = &result, + .result = NULL, .log = effects_log, .args_size = sizeof(args), .fd = fd, @@ -1582,11 +1499,7 @@ static inline int nvme_get_log_cmd_effects(int fd, enum nvme_csi csi, .rae = false, .ot = false, }; - - err = nvme_get_log_page(fd, NVME_LOG_PAGE_PDU_SIZE, &args); - if (err && result) - err = result; - return err; + return nvme_get_log_page(fd, NVME_LOG_PAGE_PDU_SIZE, &args); } /** @@ -1619,11 +1532,9 @@ static inline int nvme_get_log_device_self_test(int fd, static inline int nvme_get_log_create_telemetry_host(int fd, struct nvme_telemetry_log *log) { - __u32 result = 0; - int err; struct nvme_get_log_args args = { .lpo = 0, - .result = &result, + .result = NULL, .log = log, .args_size = sizeof(args), .fd = fd, @@ -1638,11 +1549,7 @@ static inline int nvme_get_log_create_telemetry_host(int fd, .rae = false, .ot = false, }; - - err = nvme_get_log_page(fd, NVME_LOG_PAGE_PDU_SIZE, &args); - if (err && result) - err = result; - return err; + return nvme_get_log_page(fd, NVME_LOG_PAGE_PDU_SIZE, &args); } /** @@ -1661,11 +1568,9 @@ static inline int nvme_get_log_create_telemetry_host(int fd, static inline int nvme_get_log_telemetry_host(int fd, __u64 offset, __u32 len, void *log) { - __u32 result; - int err; struct nvme_get_log_args args = { .lpo = offset, - .result = &result, + .result = NULL, .log = log, .args_size = sizeof(args), .fd = fd, @@ -1680,11 +1585,7 @@ static inline int nvme_get_log_telemetry_host(int fd, __u64 offset, .rae = false, .ot = false, }; - - err = nvme_get_log_page(fd, NVME_LOG_PAGE_PDU_SIZE, &args); - if (err && result) - err = result; - return err; + return nvme_get_log_page(fd, NVME_LOG_PAGE_PDU_SIZE, &args); } /** @@ -1704,11 +1605,9 @@ static inline int nvme_get_log_telemetry_host(int fd, __u64 offset, static inline int nvme_get_log_telemetry_ctrl(int fd, bool rae, __u64 offset, __u32 len, void *log) { - __u32 result; - int err; struct nvme_get_log_args args = { .lpo = offset, - .result = &result, + .result = NULL, .log = log, .args_size = sizeof(args), .fd = fd, @@ -1723,11 +1622,7 @@ static inline int nvme_get_log_telemetry_ctrl(int fd, bool rae, .rae = rae, .ot = false, }; - - err = nvme_get_log_page(fd, NVME_LOG_PAGE_PDU_SIZE, &args); - if (err && result) - err = result; - return err; + return nvme_get_log_page(fd, NVME_LOG_PAGE_PDU_SIZE, &args); } /** @@ -1749,11 +1644,9 @@ static inline int nvme_get_log_telemetry_ctrl(int fd, bool rae, static inline int nvme_get_log_endurance_group(int fd, __u16 endgid, struct nvme_endurance_group_log *log) { - __u32 result = 0; - int err; struct nvme_get_log_args args = { .lpo = 0, - .result = &result, + .result = NULL, .log = log, .args_size = sizeof(args), .fd = fd, @@ -1768,11 +1661,7 @@ static inline int nvme_get_log_endurance_group(int fd, __u16 endgid, .rae = false, .ot = false, }; - - err = nvme_get_log_page(fd, NVME_LOG_PAGE_PDU_SIZE, &args); - if (err && result) - err = result; - return err; + return nvme_get_log_page(fd, NVME_LOG_PAGE_PDU_SIZE, &args); } /** @@ -1787,11 +1676,9 @@ static inline int nvme_get_log_endurance_group(int fd, __u16 endgid, static inline int nvme_get_log_predictable_lat_nvmset(int fd, __u16 nvmsetid, struct nvme_nvmset_predictable_lat_log *log) { - __u32 result = 0; - int err; struct nvme_get_log_args args = { .lpo = 0, - .result = &result, + .result = NULL, .log = log, .args_size = sizeof(args), .fd = fd, @@ -1806,11 +1693,7 @@ static inline int nvme_get_log_predictable_lat_nvmset(int fd, __u16 nvmsetid, .rae = false, .ot = false, }; - - err = nvme_get_log_page(fd, NVME_LOG_PAGE_PDU_SIZE, &args); - if (err && result) - err = result; - return err; + return nvme_get_log_page(fd, NVME_LOG_PAGE_PDU_SIZE, &args); } /** @@ -1827,11 +1710,9 @@ static inline int nvme_get_log_predictable_lat_nvmset(int fd, __u16 nvmsetid, static inline int nvme_get_log_predictable_lat_event(int fd, bool rae, __u32 offset, __u32 len, void *log) { - __u32 result = 0; - int err; struct nvme_get_log_args args = { .lpo = offset, - .result = &result, + .result = NULL, .log = log, .args_size = sizeof(args), .fd = fd, @@ -1846,10 +1727,7 @@ static inline int nvme_get_log_predictable_lat_event(int fd, bool rae, .rae = rae, .ot = false, }; - err = nvme_get_log_page(fd, NVME_LOG_PAGE_PDU_SIZE, &args); - if (err && result) - err = result; - return err; + return nvme_get_log_page(fd, NVME_LOG_PAGE_PDU_SIZE, &args); } /** @@ -1859,18 +1737,13 @@ static inline int nvme_get_log_predictable_lat_event(int fd, bool rae, * @offset: Offset into log page * @len: Length (in bytes) of provided user buffer to hold the log data * @log: Log page data buffer - * - * Return: The nvme command status if a response was received (see - * &enum nvme_status_field) or -1 with errno set otherwise. */ static inline int nvme_get_log_fdp_configurations(int fd, __u16 egid, __u32 offset, __u32 len, void *log) { - __u32 result = 0; - int err; struct nvme_get_log_args args = { .lpo = offset, - .result = &result, + .result = NULL, .log = log, .args_size = sizeof(args), .fd = fd, @@ -1884,10 +1757,7 @@ static inline int nvme_get_log_fdp_configurations(int fd, __u16 egid, .uuidx = NVME_UUID_NONE, }; - err = nvme_get_log(&args); - if (err && result) - err = result; - return err; + return nvme_get_log(&args); } /** @@ -1897,18 +1767,13 @@ static inline int nvme_get_log_fdp_configurations(int fd, __u16 egid, * @offset: Offset into log page * @len: Length (in bytes) of provided user buffer to hold the log data * @log: Log page data buffer - * - * Return: The nvme command status if a response was received (see - * &enum nvme_status_field) or -1 with errno set otherwise. */ static inline int nvme_get_log_reclaim_unit_handle_usage(int fd, __u16 egid, __u32 offset, __u32 len, void *log) { - __u32 result = 0; - int err; struct nvme_get_log_args args = { .lpo = offset, - .result = &result, + .result = NULL, .log = log, .args_size = sizeof(args), .fd = fd, @@ -1922,10 +1787,7 @@ static inline int nvme_get_log_reclaim_unit_handle_usage(int fd, __u16 egid, .uuidx = NVME_UUID_NONE, }; - err = nvme_get_log(&args); - if (err && result) - err = result; - return err; + return nvme_get_log(&args); } /** @@ -1935,18 +1797,12 @@ static inline int nvme_get_log_reclaim_unit_handle_usage(int fd, __u16 egid, * @offset: Offset into log page * @len: Length (in bytes) of provided user buffer to hold the log data * @log: Log page data buffer - * - * Return: The nvme command status if a response was received (see - * &enum nvme_status_field) or -1 with errno set otherwise. */ -static inline int nvme_get_log_fdp_stats(int fd, __u16 egid, __u32 offset, - __u32 len, void *log) +static inline int nvme_get_log_fdp_stats(int fd, __u16 egid, __u32 offset, __u32 len, void *log) { - __u32 result = 0; - int err; struct nvme_get_log_args args = { .lpo = offset, - .result = &result, + .result = NULL, .log = log, .args_size = sizeof(args), .fd = fd, @@ -1960,10 +1816,7 @@ static inline int nvme_get_log_fdp_stats(int fd, __u16 egid, __u32 offset, .uuidx = NVME_UUID_NONE, }; - err = nvme_get_log(&args); - if (err && result) - err = result; - return err; + return nvme_get_log(&args); } /** @@ -1974,18 +1827,13 @@ static inline int nvme_get_log_fdp_stats(int fd, __u16 egid, __u32 offset, * @offset: Offset into log page * @len: Length (in bytes) of provided user buffer to hold the log data * @log: Log page data buffer - * - * Return: The nvme command status if a response was received (see - * &enum nvme_status_field) or -1 with errno set otherwise. */ -static inline int nvme_get_log_fdp_events(int fd, __u16 egid, bool host_events, - __u32 offset, __u32 len, void *log) +static inline int nvme_get_log_fdp_events(int fd, __u16 egid, bool host_events, __u32 offset, + __u32 len, void *log) { - __u32 result = 0; - int err; struct nvme_get_log_args args = { .lpo = offset, - .result = &result, + .result = NULL, .log = log, .args_size = sizeof(args), .fd = fd, @@ -1999,10 +1847,7 @@ static inline int nvme_get_log_fdp_events(int fd, __u16 egid, bool host_events, .uuidx = NVME_UUID_NONE, }; - err = nvme_get_log(&args); - if (err && result) - err = result; - return err; + return nvme_get_log(&args); } /** @@ -2026,11 +1871,9 @@ static inline int nvme_get_log_fdp_events(int fd, __u16 egid, bool host_events, static inline int nvme_get_log_ana(int fd, enum nvme_log_ana_lsp lsp, bool rae, __u64 offset, __u32 len, void *log) { - __u32 result = 0; - int err; struct nvme_get_log_args args = { .lpo = offset, - .result = &result, + .result = NULL, .log = log, .args_size = sizeof(args), .fd = fd, @@ -2045,10 +1888,7 @@ static inline int nvme_get_log_ana(int fd, enum nvme_log_ana_lsp lsp, bool rae, .rae = false, .ot = false, }; - err = nvme_get_log_page(fd, NVME_LOG_PAGE_PDU_SIZE, &args); - if (err && result) - err = result; - return err; + return nvme_get_log_page(fd, NVME_LOG_PAGE_PDU_SIZE, &args); } /** @@ -2084,11 +1924,9 @@ static inline int nvme_get_log_ana_groups(int fd, bool rae, __u32 len, static inline int nvme_get_log_lba_status(int fd, bool rae, __u64 offset, __u32 len, void *log) { - __u32 result = 0; - int err; struct nvme_get_log_args args = { .lpo = offset, - .result = &result, + .result = NULL, .log = log, .args_size = sizeof(args), .fd = fd, @@ -2103,11 +1941,7 @@ static inline int nvme_get_log_lba_status(int fd, bool rae, .rae = rae, .ot = false, }; - - err = nvme_get_log_page(fd, NVME_LOG_PAGE_PDU_SIZE, &args); - if (err && result) - err = result; - return err; + return nvme_get_log_page(fd, NVME_LOG_PAGE_PDU_SIZE, &args); } /** @@ -2124,11 +1958,9 @@ static inline int nvme_get_log_lba_status(int fd, bool rae, static inline int nvme_get_log_endurance_grp_evt(int fd, bool rae, __u32 offset, __u32 len, void *log) { - __u32 result = 0; - int err; struct nvme_get_log_args args = { .lpo = offset, - .result = &result, + .result = NULL, .log = log, .args_size = sizeof(args), .fd = fd, @@ -2143,11 +1975,7 @@ static inline int nvme_get_log_endurance_grp_evt(int fd, bool rae, .rae = rae, .ot = false, }; - - err = nvme_get_log_page(fd, NVME_LOG_PAGE_PDU_SIZE, &args); - if (err && result) - err = result; - return err; + return nvme_get_log_page(fd, NVME_LOG_PAGE_PDU_SIZE, &args); } /** @@ -2197,11 +2025,9 @@ static inline int nvme_get_log_mi_cmd_supported_effects(int fd, bool rae, static inline int nvme_get_log_boot_partition(int fd, bool rae, __u8 lsp, __u32 len, struct nvme_boot_partition *part) { - __u32 result = 0; - int err; struct nvme_get_log_args args = { .lpo = 0, - .result = &result, + .result = NULL, .log = part, .args_size = sizeof(args), .fd = fd, @@ -2216,11 +2042,7 @@ static inline int nvme_get_log_boot_partition(int fd, bool rae, .rae = rae, .ot = false, }; - - err = nvme_get_log_page(fd, NVME_LOG_PAGE_PDU_SIZE, &args); - if (err && result) - err = result; - return err; + return nvme_get_log_page(fd, NVME_LOG_PAGE_PDU_SIZE, &args); } /** @@ -2238,11 +2060,9 @@ static inline int nvme_get_log_boot_partition(int fd, bool rae, static inline int nvme_get_log_phy_rx_eom(int fd, __u8 lsp, __u16 controller, __u32 len, struct nvme_phy_rx_eom_log *log) { - __u32 result = 0; - int err; struct nvme_get_log_args args = { .lpo = 0, - .result = &result, + .result = NULL, .log = log, .args_size = sizeof(args), .fd = fd, @@ -2257,11 +2077,7 @@ static inline int nvme_get_log_phy_rx_eom(int fd, __u8 lsp, __u16 controller, .rae = false, .ot = false, }; - - err = nvme_get_log_page(fd, NVME_LOG_PAGE_PDU_SIZE, &args); - if (err && result) - err = result; - return err; + return nvme_get_log_page(fd, NVME_LOG_PAGE_PDU_SIZE, &args); } /** @@ -2281,11 +2097,9 @@ static inline int nvme_get_log_phy_rx_eom(int fd, __u8 lsp, __u16 controller, static inline int nvme_get_log_discovery(int fd, bool rae, __u32 offset, __u32 len, void *log) { - __u32 result = 0; - int err; struct nvme_get_log_args args = { .lpo = offset, - .result = &result, + .result = NULL, .log = log, .args_size = sizeof(args), .fd = fd, @@ -2300,11 +2114,7 @@ static inline int nvme_get_log_discovery(int fd, bool rae, .rae = rae, .ot = false, }; - - err = nvme_get_log_page(fd, NVME_LOG_PAGE_PDU_SIZE, &args); - if (err && result) - err = result; - return err; + return nvme_get_log_page(fd, NVME_LOG_PAGE_PDU_SIZE, &args); } /** @@ -2319,11 +2129,9 @@ static inline int nvme_get_log_discovery(int fd, bool rae, static inline int nvme_get_log_media_unit_stat(int fd, __u16 domid, struct nvme_media_unit_stat_log *mus) { - __u32 result = 0; - int err; struct nvme_get_log_args args = { .lpo = 0, - .result = &result, + .result = NULL, .log = mus, .args_size = sizeof(args), .fd = fd, @@ -2338,11 +2146,7 @@ static inline int nvme_get_log_media_unit_stat(int fd, __u16 domid, .rae = false, .ot = false, }; - - err = nvme_get_log_page(fd, NVME_LOG_PAGE_PDU_SIZE, &args); - if (err && result) - err = result; - return err; + return nvme_get_log_page(fd, NVME_LOG_PAGE_PDU_SIZE, &args); } /** @@ -2357,11 +2161,9 @@ static inline int nvme_get_log_media_unit_stat(int fd, __u16 domid, static inline int nvme_get_log_support_cap_config_list(int fd, __u16 domid, struct nvme_supported_cap_config_list_log *cap) { - __u32 result = 0; - int err; struct nvme_get_log_args args = { .lpo = 0, - .result = &result, + .result = NULL, .log = cap, .args_size = sizeof(args), .fd = fd, @@ -2376,11 +2178,7 @@ static inline int nvme_get_log_support_cap_config_list(int fd, __u16 domid, .rae = false, .ot = false, }; - - err = nvme_get_log_page(fd, NVME_LOG_PAGE_PDU_SIZE, &args); - if (err && result) - err = result; - return err; + return nvme_get_log_page(fd, NVME_LOG_PAGE_PDU_SIZE, &args); } /** @@ -2433,11 +2231,9 @@ static inline int nvme_get_log_sanitize(int fd, bool rae, static inline int nvme_get_log_zns_changed_zones(int fd, __u32 nsid, bool rae, struct nvme_zns_changed_zone_log *log) { - __u32 result = 0; - int err; struct nvme_get_log_args args = { .lpo = 0, - .result = &result, + .result = NULL, .log = log, .args_size = sizeof(args), .fd = fd, @@ -2452,10 +2248,7 @@ static inline int nvme_get_log_zns_changed_zones(int fd, __u32 nsid, bool rae, .rae = rae, .ot = false, }; - err = nvme_get_log_page(fd, NVME_LOG_PAGE_PDU_SIZE, &args); - if (err && result) - err = result; - return err; + return nvme_get_log_page(fd, NVME_LOG_PAGE_PDU_SIZE, &args); } /** @@ -2472,11 +2265,9 @@ static inline int nvme_get_log_persistent_event(int fd, enum nvme_pevent_log_action action, __u32 size, void *pevent_log) { - __u32 result = 0; - int err; struct nvme_get_log_args args = { .lpo = 0, - .result = &result, + .result = NULL, .log = pevent_log, .args_size = sizeof(args), .fd = fd, @@ -2491,10 +2282,7 @@ static inline int nvme_get_log_persistent_event(int fd, .rae = false, .ot = false, }; - err = nvme_get_log_page(fd, NVME_LOG_PAGE_PDU_SIZE, &args); - if (err && result) - err = result; - return err; + return nvme_get_log_page(fd, NVME_LOG_PAGE_PDU_SIZE, &args); } /** @@ -3540,10 +3328,8 @@ static inline int nvme_ns_mgmt_create(int fd, struct nvme_id_ns *ns, __u32 *nsid, __u32 timeout, __u8 csi, struct nvme_ns_mgmt_host_sw_specified *data) { - __u32 result = 0; - int err; struct nvme_ns_mgmt_args args = { - .result = &result, + .result = nsid, .ns = ns, .args_size = sizeof(args), .fd = fd, @@ -3556,12 +3342,7 @@ static inline int nvme_ns_mgmt_create(int fd, struct nvme_id_ns *ns, .data = data, }; - err = nvme_ns_mgmt(&args); - if (!err) - *nsid = result; - else if (result) - err = result; - return err; + return nvme_ns_mgmt(&args); } /** @@ -3580,10 +3361,8 @@ static inline int nvme_ns_mgmt_create(int fd, struct nvme_id_ns *ns, */ static inline int nvme_ns_mgmt_delete_timeout(int fd, __u32 nsid, __u32 timeout) { - __u32 result = 0; - int err; struct nvme_ns_mgmt_args args = { - .result = &result, + .result = NULL, .ns = NULL, .args_size = sizeof(args), .fd = fd, @@ -3596,10 +3375,7 @@ static inline int nvme_ns_mgmt_delete_timeout(int fd, __u32 nsid, __u32 timeout) .data = NULL, }; - err = nvme_ns_mgmt(&args); - if (err && result) - err = result; - return err; + return nvme_ns_mgmt(&args); } /** @@ -3640,10 +3416,8 @@ int nvme_ns_attach(struct nvme_ns_attach_args *args); static inline int nvme_ns_attach_ctrls(int fd, __u32 nsid, struct nvme_ctrl_list *ctrlist) { - __u32 result = 0; - int err; struct nvme_ns_attach_args args = { - .result = &result, + .result = NULL, .ctrlist = ctrlist, .args_size = sizeof(args), .fd = fd, @@ -3652,10 +3426,7 @@ static inline int nvme_ns_attach_ctrls(int fd, __u32 nsid, .sel = NVME_NS_ATTACH_SEL_CTRL_ATTACH, }; - err = nvme_ns_attach(&args); - if (err && result) - err = result; - return err; + return nvme_ns_attach(&args); } /** @@ -3670,10 +3441,8 @@ static inline int nvme_ns_attach_ctrls(int fd, __u32 nsid, static inline int nvme_ns_detach_ctrls(int fd, __u32 nsid, struct nvme_ctrl_list *ctrlist) { - __u32 result = 0; - int err; struct nvme_ns_attach_args args = { - .result = &result, + .result = NULL, .ctrlist = ctrlist, .args_size = sizeof(args), .fd = fd, @@ -3682,10 +3451,7 @@ static inline int nvme_ns_detach_ctrls(int fd, __u32 nsid, .sel = NVME_NS_ATTACH_SEL_CTRL_DEATTACH, }; - err = nvme_ns_attach(&args); - if (err && result) - err = result; - return err; + return nvme_ns_attach(&args); } /** @@ -3800,10 +3566,8 @@ int nvme_directive_send_id_endir(int fd, __u32 nsid, bool endir, static inline int nvme_directive_send_stream_release_identifier(int fd, __u32 nsid, __u16 stream_id) { - __u32 result = 0; - int err; struct nvme_directive_send_args args = { - .result = &result, + .result = NULL, .data = NULL, .args_size = sizeof(args), .fd = fd, @@ -3816,10 +3580,7 @@ static inline int nvme_directive_send_stream_release_identifier(int fd, .dspec = stream_id, }; - err = nvme_directive_send(&args); - if (err && result) - err = result; - return err; + return nvme_directive_send(&args); } /** @@ -3832,10 +3593,8 @@ static inline int nvme_directive_send_stream_release_identifier(int fd, */ static inline int nvme_directive_send_stream_release_resource(int fd, __u32 nsid) { - __u32 result = 0; - int err; struct nvme_directive_send_args args = { - .result = &result, + .result = NULL, .data = NULL, .args_size = sizeof(args), .fd = fd, @@ -3848,10 +3607,7 @@ static inline int nvme_directive_send_stream_release_resource(int fd, __u32 nsid .dspec = 0, }; - err = nvme_directive_send(&args); - if (err && result) - err = result; - return err; + return nvme_directive_send(&args); } /** @@ -3875,10 +3631,8 @@ int nvme_directive_recv(struct nvme_directive_recv_args *args); static inline int nvme_directive_recv_identify_parameters(int fd, __u32 nsid, struct nvme_id_directives *id) { - __u32 result = 0; - int err; struct nvme_directive_recv_args args = { - .result = &result, + .result = NULL, .data = id, .args_size = sizeof(args), .fd = fd, @@ -3891,10 +3645,7 @@ static inline int nvme_directive_recv_identify_parameters(int fd, __u32 nsid, .dspec = 0, }; - err = nvme_directive_recv(&args); - if (err && result) - err = result; - return err; + return nvme_directive_recv(&args); } /** @@ -3909,10 +3660,8 @@ static inline int nvme_directive_recv_identify_parameters(int fd, __u32 nsid, static inline int nvme_directive_recv_stream_parameters(int fd, __u32 nsid, struct nvme_streams_directive_params *parms) { - __u32 result = 0; - int err; struct nvme_directive_recv_args args = { - .result = &result, + .result = NULL, .data = parms, .args_size = sizeof(args), .fd = fd, @@ -3925,10 +3674,7 @@ static inline int nvme_directive_recv_stream_parameters(int fd, __u32 nsid, .dspec = 0, }; - err = nvme_directive_recv(&args); - if (err && result) - err = result; - return err; + return nvme_directive_recv(&args); } /** @@ -3945,10 +3691,8 @@ static inline int nvme_directive_recv_stream_status(int fd, __u32 nsid, unsigned int nr_entries, struct nvme_streams_directive_status *id) { - __u32 result = 0; - int err; struct nvme_directive_recv_args args = { - .result = &result, + .result = NULL, .data = id, .args_size = sizeof(args), .fd = fd, @@ -3961,10 +3705,7 @@ static inline int nvme_directive_recv_stream_status(int fd, __u32 nsid, .dspec = 0, }; - err = nvme_directive_recv(&args); - if (err && result) - err = result; - return err; + return nvme_directive_recv(&args); } /** @@ -4102,16 +3843,11 @@ int nvme_virtual_mgmt(struct nvme_virtual_mgmt_args *args); static inline int nvme_flush(int fd, __u32 nsid) { struct nvme_passthru_cmd cmd = {}; - __u32 result = 0; - int err; cmd.opcode = nvme_cmd_flush; cmd.nsid = nsid; - err = nvme_submit_io_passthru(fd, &cmd, &result); - if (err && result) - err = result; - return err; + return nvme_submit_io_passthru(fd, &cmd, NULL); } /**