]> www.infradead.org Git - users/sagi/libnvme.git/commitdiff
ioctl: add nvme_get_features_timestamp2()
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_timestamp2()
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 e5dd410d5c2e0d5b8361b983d3f81f2501f2dab6..1a2b5a91137a21cb48ecaea13b634c0187b28f14 100644 (file)
@@ -14,6 +14,7 @@ LIBNVME_1.9 {
                nvme_set_features_host_behavior2;
                nvme_set_features_host_id2;
                nvme_set_features_iocs_profile2;
+               nvme_get_features_timestamp2;
 };
 
 LIBNVME_1_8 {
index 34080274a41d4e8df33f2c749fb00a4e30cf3256..ab36a4b5b4b4628536f2ddc5c7cf7073ded23016 100644 (file)
@@ -1042,6 +1042,18 @@ int nvme_get_features_host_mem_buf2(int fd, enum nvme_get_features_sel sel,
 
 int nvme_get_features_timestamp(int fd, enum nvme_get_features_sel sel,
                                struct nvme_timestamp *ts)
+{
+       __u32 result = 0;
+       int err;
+
+       err = nvme_get_features_timestamp2(fd, sel, ts, &result);
+       if (err && result)
+               err = result;
+       return err;
+}
+
+int nvme_get_features_timestamp2(int fd, enum nvme_get_features_sel sel,
+                                struct nvme_timestamp *ts, __u32 *result)
 {
        struct nvme_get_features_args args = {
                .args_size = sizeof(args),
@@ -1054,7 +1066,7 @@ int nvme_get_features_timestamp(int fd, enum nvme_get_features_sel sel,
                .data_len = sizeof(*ts),
                .data = ts,
                .timeout = NVME_DEFAULT_IOCTL_TIMEOUT,
-               .result = NULL,
+               .result = result,
        };
 
        return nvme_get_features(&args);
index fdf0556257d40f4450815ea6fd6374b08a2bca12..5183b8cfdcbc0a6c7e4477c434c058374e38fb04 100644 (file)
@@ -3318,6 +3318,20 @@ int nvme_get_features_host_mem_buf2(int fd, enum nvme_get_features_sel sel,
 int nvme_get_features_timestamp(int fd, enum nvme_get_features_sel sel,
                                struct nvme_timestamp *ts);
 
+/**
+ * nvme_get_features_timestamp2() - Get timestamp feature
+ * @fd:                File descriptor of nvme device
+ * @sel:       Select which type of attribute to return, see
+ *             &enum nvme_get_features_sel
+ * @ts:                Current timestamp
+ * @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_timestamp2(int fd, enum nvme_get_features_sel sel,
+                                struct nvme_timestamp *ts, __u32 *result);
+
 /**
  * nvme_get_features_kato() - Get keep alive timeout feature
  * @fd:                File descriptor of nvme device