diff mbox series

[1/2] nvme: Cleanup nvme_block_nr()

Message ID 20191020234220.14888-2-damien.lemoal@wdc.com (mailing list archive)
State New, archived
Headers show
Series Small cleanups | expand

Commit Message

Damien Le Moal Oct. 20, 2019, 11:42 p.m. UTC
Use SECTOR_SHIFT instead of its hard coded value 9. Also add a comment
to decribe this helper.

Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
---
 drivers/nvme/host/nvme.h | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Comments

Bart Van Assche Oct. 21, 2019, 2:13 a.m. UTC | #1
On 2019-10-20 16:42, Damien Le Moal wrote:
> Use SECTOR_SHIFT instead of its hard coded value 9. Also add a comment
> to decribe this helper.
> 
> Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
> ---
>  drivers/nvme/host/nvme.h | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/nvme/host/nvme.h b/drivers/nvme/host/nvme.h
> index 22e8401352c2..a979b62ea4b2 100644
> --- a/drivers/nvme/host/nvme.h
> +++ b/drivers/nvme/host/nvme.h
> @@ -419,9 +419,12 @@ static inline int nvme_reset_subsystem(struct nvme_ctrl *ctrl)
>  	return ctrl->ops->reg_write32(ctrl, NVME_REG_NSSR, 0x4E564D65);
>  }
>  
> +/*
> + * Convert a 512B sector number to a block number.
> + */
>  static inline u64 nvme_block_nr(struct nvme_ns *ns, sector_t sector)
>  {
> -	return (sector >> (ns->lba_shift - 9));
> +	return sector >> (ns->lba_shift - SECTOR_SHIFT);
>  }

Has it been considered to rename nvme_block_nr() into
nvme_sect_to_lba()? I think the latter name is more clear.

Thanks,

Bart.
diff mbox series

Patch

diff --git a/drivers/nvme/host/nvme.h b/drivers/nvme/host/nvme.h
index 22e8401352c2..a979b62ea4b2 100644
--- a/drivers/nvme/host/nvme.h
+++ b/drivers/nvme/host/nvme.h
@@ -419,9 +419,12 @@  static inline int nvme_reset_subsystem(struct nvme_ctrl *ctrl)
 	return ctrl->ops->reg_write32(ctrl, NVME_REG_NSSR, 0x4E564D65);
 }
 
+/*
+ * Convert a 512B sector number to a block number.
+ */
 static inline u64 nvme_block_nr(struct nvme_ns *ns, sector_t sector)
 {
-	return (sector >> (ns->lba_shift - 9));
+	return sector >> (ns->lba_shift - SECTOR_SHIFT);
 }
 
 static inline void nvme_end_request(struct request *req, __le16 status,