]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
nvme: Export get and set features
authorKeith Busch <keith.busch@intel.com>
Sun, 26 May 2019 16:29:01 +0000 (01:29 +0900)
committerKleber Sacilotto de Souza <kleber.souza@canonical.com>
Tue, 2 Jul 2019 12:18:49 +0000 (14:18 +0200)
BugLink: https://bugs.launchpad.net/bugs/1808957
Future use intends to make use of both, so export these functions. And
since their implementation is identical except for the opcode, provide a
new function that implement both.

[akinobu.mita@gmail.com>: fix line over 80 characters]
Signed-off-by: Keith Busch <keith.busch@intel.com>
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Reviewed-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
Reviewed-by: Minwoo Im <minwoo.im.dev@gmail.com>
Signed-off-by: Sagi Grimberg <sagi@grimberg.me>
(backported from commit 82b17aebf68d572d73359a68376024ec1b5294c5 git://git.infradead.org/nvme nvme-5.3)
Signed-off-by: Kai-Heng Feng <kai.heng.feng@canonical.com>
Acked-by: Timo Aaltonen <tjaalton@ubuntu.com>
Acked-by: Stefan Bader <stefan.bader@canonical.com>
Signed-off-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
drivers/nvme/host/core.c
drivers/nvme/host/nvme.h

index 2602830eb9f461978c24c1d0ec0a74e10efcf2e9..016768a67001945ce36fde8e67418094903af218 100644 (file)
@@ -930,15 +930,15 @@ static struct nvme_id_ns *nvme_identify_ns(struct nvme_ctrl *ctrl,
        return id;
 }
 
-static int nvme_set_features(struct nvme_ctrl *dev, unsigned fid, unsigned dword11,
-                     void *buffer, size_t buflen, u32 *result)
+static int nvme_features(struct nvme_ctrl *dev, u8 op, unsigned int fid,
+               unsigned int dword11, void *buffer, size_t buflen, u32 *result)
 {
        struct nvme_command c;
        union nvme_result res;
        int ret;
 
        memset(&c, 0, sizeof(c));
-       c.features.opcode = nvme_admin_set_features;
+       c.features.opcode = op;
        c.features.fid = cpu_to_le32(fid);
        c.features.dword11 = cpu_to_le32(dword11);
 
@@ -949,6 +949,24 @@ static int nvme_set_features(struct nvme_ctrl *dev, unsigned fid, unsigned dword
        return ret;
 }
 
+int nvme_set_features(struct nvme_ctrl *dev, unsigned int fid,
+                     unsigned int dword11, void *buffer, size_t buflen,
+                     u32 *result)
+{
+       return nvme_features(dev, nvme_admin_set_features, fid, dword11, buffer,
+                            buflen, result);
+}
+EXPORT_SYMBOL_GPL(nvme_set_features);
+
+int nvme_get_features(struct nvme_ctrl *dev, unsigned int fid,
+                     unsigned int dword11, void *buffer, size_t buflen,
+                     u32 *result)
+{
+       return nvme_features(dev, nvme_admin_get_features, fid, dword11, buffer,
+                            buflen, result);
+}
+EXPORT_SYMBOL_GPL(nvme_get_features);
+
 int nvme_set_queue_count(struct nvme_ctrl *ctrl, int *count)
 {
        u32 q_count = (*count - 1) | ((*count - 1) << 16);
index e31702af458981a62a409781f87c45f0634f6ff5..32417432563873fc0494b098679f98fe2b0fc729 100644 (file)
@@ -400,6 +400,12 @@ int __nvme_submit_sync_cmd(struct request_queue *q, struct nvme_command *cmd,
                union nvme_result *result, void *buffer, unsigned bufflen,
                unsigned timeout, int qid, int at_head,
                blk_mq_req_flags_t flags);
+int nvme_set_features(struct nvme_ctrl *dev, unsigned int fid,
+                     unsigned int dword11, void *buffer, size_t buflen,
+                     u32 *result);
+int nvme_get_features(struct nvme_ctrl *dev, unsigned int fid,
+                     unsigned int dword11, void *buffer, size_t buflen,
+                     u32 *result);
 int nvme_set_queue_count(struct nvme_ctrl *ctrl, int *count);
 void nvme_start_keep_alive(struct nvme_ctrl *ctrl);
 void nvme_stop_keep_alive(struct nvme_ctrl *ctrl);