]> www.infradead.org Git - users/sagi/libnvme.git/commitdiff
ioctl: add nvme_set_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 'set features' commands have an 'result' field as the last
argument, so add an alternative function nvme_set_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 8710c41f5d7ab06db87af990c875af7a63079ba8..b3c872019de7c07dbb831547b280cd4a755092e4 100644 (file)
@@ -10,6 +10,7 @@ LIBNVME_1.9 {
                nvme_submit_passthru64;
                nvme_update_key;
                nvme_ctrl_get_cntlid;
+               nvme_set_features_timestamp2;
 };
 
 LIBNVME_1_8 {
index fa7d70d844bf04e0cc255dd9b3b2c2f8ab208b31..726171e44e2679f7413e8ff1d2236a482dbd9784 100644 (file)
@@ -530,6 +530,18 @@ int nvme_set_features_auto_pst(int fd, bool apste, bool save,
 }
 
 int nvme_set_features_timestamp(int fd, bool save, __u64 timestamp)
+{
+       __u32 result = 0;
+       int err;
+
+       err = nvme_set_features_timestamp2(fd, save, timestamp, &result);
+       if (err && result)
+               err = result;
+       return err;
+}
+
+int nvme_set_features_timestamp2(int fd, bool save, __u64 timestamp,
+               __u32 *result)
 {
        __le64 t = cpu_to_le64(timestamp);
        struct nvme_timestamp ts = {};
@@ -546,7 +558,7 @@ int nvme_set_features_timestamp(int fd, bool save, __u64 timestamp)
                .data_len = sizeof(ts),
                .data = &ts,
                .timeout = NVME_DEFAULT_IOCTL_TIMEOUT,
-               .result = NULL,
+               .result = result,
        };
 
        memcpy(ts.timestamp, &t, sizeof(ts.timestamp));
index e65de04cc60cdf396b4bdfdeadeee296ac67c8cd..d9987f6b3ef0339eea3e285a7a2a04bb9e7dbe15 100644 (file)
@@ -2730,6 +2730,19 @@ int nvme_set_features_auto_pst(int fd, bool apste, bool save,
  */
 int nvme_set_features_timestamp(int fd, bool save, __u64 timestamp);
 
+/**
+ * nvme_set_features_timestamp2() - Set timestamp feature
+ * @fd:                File descriptor of nvme device
+ * @save:      Save value across power states
+ * @timestamp: The current timestamp value to assign to this feature
+ * @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_timestamp2(int fd, bool save, __u64 timestamp,
+               __u32 *result);
+
 /**
  * nvme_set_features_hctm() - Set thermal management feature
  * @fd:                File descriptor of nvme device