]> www.infradead.org Git - users/sagi/libnvme.git/commitdiff
ioctl: add nvme_set_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 'set features' commands have an 'result' field as the last
argument, so add an alternative function nvme_set_features_host_id2()
to follow the same calling convention.

Signed-off-by: Hannes Reinecke <hare@suse.de>
src/libnvme.map
src/nvme/ioctl.c
src/nvme/ioctl.h

index c2a23e3aa434a805a112b5a613df4952e5459eec..85f4a4a17a589bbab6c42a322fc6057f9ef34ff9 100644 (file)
@@ -12,6 +12,7 @@ LIBNVME_1.9 {
                nvme_ctrl_get_cntlid;
                nvme_set_features_timestamp2;
                nvme_set_features_host_behavior2;
+               nvme_set_features_host_id2;
 };
 
 LIBNVME_1_8 {
index d54b367ccfc024fada5f54cac83da79bd272e57a..dfd17e46d78eca1efd91ed6b32f4daf77693c181 100644 (file)
@@ -717,6 +717,18 @@ int nvme_set_features_sw_progress(int fd, __u8 pbslc, bool save,
 }
 
 int nvme_set_features_host_id(int fd, bool exhid, bool save, __u8 *hostid)
+{
+       __u32 result = 0;
+       int err;
+
+       err = nvme_set_features_host_id2(fd, exhid, save, hostid, &result);
+       if (err && result)
+               err = result;
+       return err;
+}
+
+int nvme_set_features_host_id2(int fd, bool exhid, bool save, __u8 *hostid,
+                              __u32 *result)
 {
        __u32 len = exhid ? 16 : 8;
        __u32 value = !!exhid;
@@ -733,7 +745,7 @@ int nvme_set_features_host_id(int fd, bool exhid, bool save, __u8 *hostid)
                .data_len = len,
                .data = hostid,
                .timeout = NVME_DEFAULT_IOCTL_TIMEOUT,
-               .result = NULL,
+               .result = result,
        };
 
        return nvme_set_features(&args);
index a952a7610ff59bdfcf36f1ee526b24196b2986cc..e3f6450c302f2a0daf30486bbd7e4bac065cb9fe 100644 (file)
@@ -2903,6 +2903,20 @@ int nvme_set_features_sw_progress(int fd, __u8 pbslc, bool save,
  */
 int nvme_set_features_host_id(int fd, bool exhid, bool save, __u8 *hostid);
 
+/**
+ * nvme_set_features_host_id2() - Set enable extended host identifiers feature
+ * @fd:                File descriptor of nvme device
+ * @exhid:     Enable Extended Host Identifier
+ * @save:      Save value across power states
+ * @hostid:    Host ID to set
+ * @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_set_features_host_id2(int fd, bool exhid, bool save, __u8 *hostid,
+                              __u32 *result);
+
 /**
  * nvme_set_features_resv_mask() - Set reservation notification mask feature
  *