diff mbox series

[v2] scsi: fix the return value of scsi_logical_block_count

Message ID 20240813053534.7720-1-chaotian.jing@mediatek.com
State New
Headers show
Series [v2] scsi: fix the return value of scsi_logical_block_count | expand

Commit Message

Chaotian Jing (井朝天) Aug. 13, 2024, 5:34 a.m. UTC
scsi_logical_block_count() should return the block count of scsi device,
but the original code has a wrong implement.

Cc: stable@vger.kernel.org
Fixes: 6a20e21ae1e2 ("scsi: core: Add helper to return number of logical
blocks in a request")
Signed-off-by: Chaotian Jing <chaotian.jing@mediatek.com>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
---
 include/scsi/scsi_cmnd.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Martin K. Petersen Aug. 17, 2024, 1:28 a.m. UTC | #1
On Tue, 13 Aug 2024 13:34:10 +0800, Chaotian Jing wrote:

> scsi_logical_block_count() should return the block count of scsi device,
> but the original code has a wrong implement.
> 
> 

Applied to 6.11/scsi-fixes, thanks!

[1/1] scsi: fix the return value of scsi_logical_block_count
      https://git.kernel.org/mkp/scsi/c/f03e94f23b04
diff mbox series

Patch

diff --git a/include/scsi/scsi_cmnd.h b/include/scsi/scsi_cmnd.h
index 45c40d200154..8ecfb94049db 100644
--- a/include/scsi/scsi_cmnd.h
+++ b/include/scsi/scsi_cmnd.h
@@ -234,7 +234,7 @@  static inline sector_t scsi_get_lba(struct scsi_cmnd *scmd)
 
 static inline unsigned int scsi_logical_block_count(struct scsi_cmnd *scmd)
 {
-	unsigned int shift = ilog2(scmd->device->sector_size) - SECTOR_SHIFT;
+	unsigned int shift = ilog2(scmd->device->sector_size);
 
 	return blk_rq_bytes(scsi_cmd_to_rq(scmd)) >> shift;
 }