From 063cc6d5591ea9c0631b81ac5c7b829d99738b2f Mon Sep 17 00:00:00 2001 From: Matthew Wilcox Date: Wed, 27 Mar 2013 21:28:22 -0400 Subject: NVMe: Abstract out sector to block number conversion Introduce nvme_block_nr() to help convert sectors to block numbers. This fixes an integer overflow in the SCSI conversion layer, and it's slightly less typing than opencoding it. Signed-off-by: Matthew Wilcox Acked-by: Keith Busch --- include/linux/nvme.h | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'include') diff --git a/include/linux/nvme.h b/include/linux/nvme.h index aa575033dbe7..09f419d4da4e 100644 --- a/include/linux/nvme.h +++ b/include/linux/nvme.h @@ -566,6 +566,11 @@ struct nvme_iod { struct scatterlist sg[0]; }; +static inline u64 nvme_block_nr(struct nvme_ns *ns, sector_t sector) +{ + return (sector >> (ns->lba_shift - 9)); +} + /** * nvme_free_iod - frees an nvme_iod * @dev: The device that the I/O was submitted to -- cgit v1.2.3