diff options
author | Damien Le Moal <damien.lemoal@wdc.com> | 2017-04-24 09:51:10 +0200 |
---|---|---|
committer | Martin K. Petersen <martin.petersen@oracle.com> | 2017-04-25 01:00:29 +0200 |
commit | 6eadc61224666dcc79763dc21749b5f809d82140 (patch) | |
tree | b14107bc46373d10b1727c2b0f348de0b5ad7e50 /drivers/scsi/sd.h | |
parent | scsi: sd: Fix function descriptions (diff) | |
download | linux-6eadc61224666dcc79763dc21749b5f809d82140.tar.xz linux-6eadc61224666dcc79763dc21749b5f809d82140.zip |
scsi: sd: Improve sd_completed_bytes
Re-shuffle the code to be more efficient by not initializing variables
upfront (i.e. do it only when necessary). Also replace the do_div calls
with calls to sectors_to_logical().
No functional change is introduced by this patch.
[mkp: bytes_to_logical()]
Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Diffstat (limited to 'drivers/scsi/sd.h')
-rw-r--r-- | drivers/scsi/sd.h | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/drivers/scsi/sd.h b/drivers/scsi/sd.h index 0cf9680cb469..e6241c445878 100644 --- a/drivers/scsi/sd.h +++ b/drivers/scsi/sd.h @@ -169,6 +169,11 @@ static inline unsigned int logical_to_bytes(struct scsi_device *sdev, sector_t b return blocks * sdev->sector_size; } +static inline sector_t bytes_to_logical(struct scsi_device *sdev, unsigned int bytes) +{ + return bytes >> ilog2(sdev->sector_size); +} + static inline sector_t sectors_to_logical(struct scsi_device *sdev, sector_t sector) { return sector >> (ilog2(sdev->sector_size) - 9); |