From: Hannes Reinecke Date: Fri, 5 Apr 2024 14:31:25 +0000 (+0200) Subject: ioctl: add nvme_get_features_host_id2() X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=3d9ab1d2217af69a0285efde2c0c0ee211bdca60;p=users%2Fsagi%2Flibnvme.git ioctl: add nvme_get_features_host_id2() All 'get features' commands have an 'result' field as the last argument, so add an alternative function nvme_get_features_host_id2() to follow the same calling convention. Signed-off-by: Hannes Reinecke --- diff --git a/src/nvme/ioctl.c b/src/nvme/ioctl.c index ab36a4b5..ba475496 100644 --- a/src/nvme/ioctl.c +++ b/src/nvme/ioctl.c @@ -1194,7 +1194,19 @@ int nvme_get_features_sw_progress(int fd, enum nvme_get_features_sel sel, } int nvme_get_features_host_id(int fd, enum nvme_get_features_sel sel, - bool exhid, __u32 len, __u8 *hostid) + bool exhid, __u32 len, __u8 *hostid) +{ + __u32 result = 0; + int err; + + err = nvme_get_features_host_id2(fd, sel, exhid, len, hostid, &result); + if (err && result) + err = result; + return err; +} + +int nvme_get_features_host_id2(int fd, enum nvme_get_features_sel sel, + bool exhid, __u32 len, __u8 *hostid, __u32 *result) { struct nvme_get_features_args args = { .args_size = sizeof(args), @@ -1207,7 +1219,7 @@ int nvme_get_features_host_id(int fd, enum nvme_get_features_sel sel, .data_len = len, .data = hostid, .timeout = NVME_DEFAULT_IOCTL_TIMEOUT, - .result = NULL, + .result = result, }; return nvme_get_features(&args); diff --git a/src/nvme/ioctl.h b/src/nvme/ioctl.h index 5183b8cf..99179080 100644 --- a/src/nvme/ioctl.h +++ b/src/nvme/ioctl.h @@ -3479,7 +3479,22 @@ int nvme_get_features_sw_progress(int fd, enum nvme_get_features_sel sel, * &enum nvme_status_field) or -1 with errno set otherwise. */ int nvme_get_features_host_id(int fd, enum nvme_get_features_sel sel, - bool exhid, __u32 len, __u8 *hostid); + bool exhid, __u32 len, __u8 *hostid); + +/** + * nvme_get_features_host_id2() - Get host id feature + * @fd: File descriptor of nvme device + * @sel: Select which type of attribute to return, see &enum nvme_get_features_sel + * @exhid: Enable Extended Host Identifier + * @len: Length of @hostid + * @hostid: Buffer for returned host ID + * @result: The command completion result from CQE dword0 + * + * Return: 0 if the ioctl was successful, -1 with errno set to EPROTO when + * a non-zero state is returned in @result, or -1 with errno set otherwise. + */ +int nvme_get_features_host_id2(int fd, enum nvme_get_features_sel sel, + bool exhid, __u32 len, __u8 *hostid, __u32 *result); /** * nvme_get_features_resv_mask() - Get reservation mask feature