]> www.infradead.org Git - users/sagi/libnvme.git/commitdiff
ioctl: add nvme_get_features_host_id2()
authorHannes Reinecke <hare@suse.de>
Fri, 5 Apr 2024 14:31:25 +0000 (16:31 +0200)
committerDaniel Wagner <wagi@monom.org>
Tue, 9 Apr 2024 12:47:59 +0000 (14:47 +0200)
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 <hare@suse.de>
src/nvme/ioctl.c
src/nvme/ioctl.h

index ab36a4b5b4b4628536f2ddc5c7cf7073ded23016..ba475496f651f44371950c4a985b2528283894d5 100644 (file)
@@ -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);
index 5183b8cfdcbc0a6c7e4477c434c058374e38fb04..99179080289a128e3ef9742d70900b866f257285 100644 (file)
@@ -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