]> www.infradead.org Git - users/sagi/libnvme.git/commitdiff
ioctl: add nvme_set_features_host_behavior2()
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_behavior2()
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 b3c872019de7c07dbb831547b280cd4a755092e4..c2a23e3aa434a805a112b5a613df4952e5459eec 100644 (file)
@@ -11,6 +11,7 @@ LIBNVME_1.9 {
                nvme_update_key;
                nvme_ctrl_get_cntlid;
                nvme_set_features_timestamp2;
+               nvme_set_features_host_behavior2;
 };
 
 LIBNVME_1_8 {
index 726171e44e2679f7413e8ff1d2236a482dbd9784..d54b367ccfc024fada5f54cac83da79bd272e57a 100644 (file)
@@ -661,7 +661,19 @@ int nvme_set_features_lba_sts_interval(int fd, __u16 lsiri, __u16 lsipi,
 }
 
 int nvme_set_features_host_behavior(int fd, bool save,
-       struct nvme_feat_host_behavior *data)
+               struct nvme_feat_host_behavior *data)
+{
+       __u32 result = 0;
+       int err;
+
+       err = nvme_set_features_host_behavior2(fd, save, data, &result);
+       if (err && result)
+               err = result;
+       return err;
+}
+
+int nvme_set_features_host_behavior2(int fd, bool save,
+               struct nvme_feat_host_behavior *data, __u32 *result)
 {
        struct nvme_set_features_args args = {
                .args_size = sizeof(args),
@@ -676,7 +688,7 @@ int nvme_set_features_host_behavior(int fd, bool save,
                .data_len = sizeof(*data),
                .data = data,
                .timeout = NVME_DEFAULT_IOCTL_TIMEOUT,
-               .result = NULL,
+               .result = result,
        };
 
        return nvme_set_features(&args);
index d9987f6b3ef0339eea3e285a7a2a04bb9e7dbe15..a952a7610ff59bdfcf36f1ee526b24196b2986cc 100644 (file)
@@ -2833,10 +2833,24 @@ int nvme_set_features_lba_sts_interval(int fd, __u16 lsiri, __u16 lsipi,
  * @save:      Save value across power states
  * @data:      Pointer to structure nvme_feat_host_behavior
  *
- * Return: 0 if the ioctl was successful or -1 with errno set otherwise.
+ * Return: The nvme command status if a response was received (see
+ * &enum nvme_status_field) or -1 with errno set otherwise.
  */
 int nvme_set_features_host_behavior(int fd, bool save,
-                                   struct nvme_feat_host_behavior *data);
+                       struct nvme_feat_host_behavior *data);
+
+/**
+ * nvme_set_features_host_behavior2() - Set host behavior feature
+ * @fd:                File descriptor of nvme device
+ * @save:      Save value across power states
+ * @data:      Pointer to structure nvme_feat_host_behavior
+ * @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_behavior2(int fd, bool save,
+                       struct nvme_feat_host_behavior *data, __u32 *result);
 
 /**
  * nvme_set_features_sanitize() - Set sanitize feature
@@ -2847,7 +2861,6 @@ int nvme_set_features_host_behavior(int fd, bool save,
  *
  * 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.
- * Return: 0 if the ioctl was successful or -1 with errno set otherwise.
  */
 int nvme_set_features_sanitize(int fd, bool nodrm, bool save, __u32 *result);