nvme: enforce 64bit offset for nvme_get_log_ext fn
authorMatias Bjørling <mb@lightnvm.io>
Thu, 12 Apr 2018 15:16:03 +0000 (09:16 -0600)
committerJens Axboe <axboe@kernel.dk>
Thu, 12 Apr 2018 15:58:27 +0000 (09:58 -0600)
Compiling on 32 bits system produces a warning for the shift width
when shifting 32 bit integer with 64bit integer.

Make sure that offset always is 64bit, and use macros for retrieving
lower and upper bits of the offset.

Signed-off-by: Matias Bjørling <mb@lightnvm.io>
Signed-off-by: Keith Busch <keith.busch@intel.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
drivers/nvme/host/core.c
drivers/nvme/host/nvme.h

index 197a6ba..1bdd010 100644 (file)
@@ -2220,7 +2220,7 @@ out_unlock:
 
 int nvme_get_log_ext(struct nvme_ctrl *ctrl, struct nvme_ns *ns,
                     u8 log_page, void *log,
-                    size_t size, size_t offset)
+                    size_t size, u64 offset)
 {
        struct nvme_command c = { };
        unsigned long dwlen = size / 4 - 1;
@@ -2235,8 +2235,8 @@ int nvme_get_log_ext(struct nvme_ctrl *ctrl, struct nvme_ns *ns,
        c.get_log_page.lid = log_page;
        c.get_log_page.numdl = cpu_to_le16(dwlen & ((1 << 16) - 1));
        c.get_log_page.numdu = cpu_to_le16(dwlen >> 16);
-       c.get_log_page.lpol = cpu_to_le32(offset & ((1ULL << 32) - 1));
-       c.get_log_page.lpou = cpu_to_le32(offset >> 32ULL);
+       c.get_log_page.lpol = cpu_to_le32(lower_32_bits(offset));
+       c.get_log_page.lpou = cpu_to_le32(upper_32_bits(offset));
 
        return nvme_submit_sync_cmd(ctrl->admin_q, &c, log, size);
 }
index cf93690..09d47b1 100644 (file)
@@ -430,7 +430,7 @@ int nvme_delete_ctrl(struct nvme_ctrl *ctrl);
 int nvme_delete_ctrl_sync(struct nvme_ctrl *ctrl);
 
 int nvme_get_log_ext(struct nvme_ctrl *ctrl, struct nvme_ns *ns,
-               u8 log_page, void *log, size_t size, size_t offset);
+               u8 log_page, void *log, size_t size, u64 offset);
 
 extern const struct attribute_group nvme_ns_id_attr_group;
 extern const struct block_device_operations nvme_ns_head_ops;