diff options
author | Damien Le Moal <damien.lemoal@wdc.com> | 2019-10-21 05:40:04 +0200 |
---|---|---|
committer | Jens Axboe <axboe@kernel.dk> | 2019-11-04 18:56:41 +0100 |
commit | e08f2ae850929d40e66268ee47e443e7ea56eeb7 (patch) | |
tree | fa7600498204fb0c479510dcfd3d084c1fc5b868 /drivers/nvme/host/nvme.h | |
parent | nvme: Cleanup and rename nvme_block_nr() (diff) | |
download | linux-e08f2ae850929d40e66268ee47e443e7ea56eeb7.tar.xz linux-e08f2ae850929d40e66268ee47e443e7ea56eeb7.zip |
nvme: Introduce nvme_lba_to_sect()
Introduce the new helper function nvme_lba_to_sect() to convert a device
logical block number to a 512B sector number. Use this new helper in
obvious places, cleaning up the code.
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
Signed-off-by: Keith Busch <kbusch@kernel.org>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'drivers/nvme/host/nvme.h')
-rw-r--r-- | drivers/nvme/host/nvme.h | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/drivers/nvme/host/nvme.h b/drivers/nvme/host/nvme.h index 37eb94fb797d..2637d9dd278f 100644 --- a/drivers/nvme/host/nvme.h +++ b/drivers/nvme/host/nvme.h @@ -426,6 +426,14 @@ static inline u64 nvme_sect_to_lba(struct nvme_ns *ns, sector_t sector) return sector >> (ns->lba_shift - SECTOR_SHIFT); } +/* + * Convert a device logical block number to a 512B sector number. + */ +static inline sector_t nvme_lba_to_sect(struct nvme_ns *ns, u64 lba) +{ + return lba << (ns->lba_shift - SECTOR_SHIFT); +} + static inline void nvme_end_request(struct request *req, __le16 status, union nvme_result result) { |