From 99d5e26bb4014830a4a5649bd200f9fcc199990b Mon Sep 17 00:00:00 2001 From: Hannes Reinecke Date: Fri, 5 Apr 2024 16:31:25 +0200 Subject: [PATCH] ioctl: add nvme_set_features_timestamp2() 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 --- src/libnvme.map | 1 + src/nvme/ioctl.c | 14 +++++++++++++- src/nvme/ioctl.h | 13 +++++++++++++ 3 files changed, 27 insertions(+), 1 deletion(-) diff --git a/src/libnvme.map b/src/libnvme.map index 8710c41f..b3c87201 100644 --- a/src/libnvme.map +++ b/src/libnvme.map @@ -10,6 +10,7 @@ LIBNVME_1.9 { nvme_submit_passthru64; nvme_update_key; nvme_ctrl_get_cntlid; + nvme_set_features_timestamp2; }; LIBNVME_1_8 { diff --git a/src/nvme/ioctl.c b/src/nvme/ioctl.c index fa7d70d8..726171e4 100644 --- a/src/nvme/ioctl.c +++ b/src/nvme/ioctl.c @@ -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)); diff --git a/src/nvme/ioctl.h b/src/nvme/ioctl.h index e65de04c..d9987f6b 100644 --- a/src/nvme/ioctl.h +++ b/src/nvme/ioctl.h @@ -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 -- 2.50.1