summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTom Yan <tom.ty89@gmail.com>2016-07-14 23:09:02 +0200
committerTejun Heo <tj@kernel.org>2016-07-19 00:25:00 +0200
commit35303d5c36415754680f953aa6128b8b907d0543 (patch)
treee29885191e8119a5a6944d1693903389b0fb224c
parentlibata-scsi: minor cleanup for ata_scsi_zbc_out_xlat (diff)
downloadlinux-35303d5c36415754680f953aa6128b8b907d0543.tar.xz
linux-35303d5c36415754680f953aa6128b8b907d0543.zip
ata: make lba_{28,48}_ok() use ATA_MAX_SECTORS{,_LBA48}
Since we set ATA_MAX_SECTORS_LBA48 to 65535 to avoid the corner case in some drives that commands with "count" set to 0000h (which reprsents 65536) does not work as expected, lba_48_ok(), which is used for number-of-blocks checking when libata pack commands, should use the same limit as well. In fact, there is no reason for the two functions not to use the macros anyway. Signed-off-by: Tom Yan <tom.ty89@gmail.com> Signed-off-by: Tejun Heo <tj@kernel.org>
-rw-r--r--include/linux/ata.h6
1 files changed, 3 insertions, 3 deletions
diff --git a/include/linux/ata.h b/include/linux/ata.h
index 35857d1f15c8..5b67ff407ec2 100644
--- a/include/linux/ata.h
+++ b/include/linux/ata.h
@@ -46,7 +46,7 @@ enum {
ATA_MAX_SECTORS_128 = 128,
ATA_MAX_SECTORS = 256,
ATA_MAX_SECTORS_1024 = 1024,
- ATA_MAX_SECTORS_LBA48 = 65535,/* TODO: 65536? */
+ ATA_MAX_SECTORS_LBA48 = 65535,/* avoid count to be 0000h */
ATA_MAX_SECTORS_TAPE = 65535,
ATA_MAX_TRIM_RNUM = 64, /* 512-byte payload / (6-byte LBA + 2-byte range per entry) */
@@ -1100,13 +1100,13 @@ static inline bool ata_ok(u8 status)
static inline bool lba_28_ok(u64 block, u32 n_block)
{
/* check the ending block number: must be LESS THAN 0x0fffffff */
- return ((block + n_block) < ((1 << 28) - 1)) && (n_block <= 256);
+ return ((block + n_block) < ((1 << 28) - 1)) && (n_block <= ATA_MAX_SECTORS);
}
static inline bool lba_48_ok(u64 block, u32 n_block)
{
/* check the ending block number */
- return ((block + n_block - 1) < ((u64)1 << 48)) && (n_block <= 65536);
+ return ((block + n_block - 1) < ((u64)1 << 48)) && (n_block <= ATA_MAX_SECTORS_LBA48);
}
#define sata_pmp_gscr_vendor(gscr) ((gscr)[SATA_PMP_GSCR_PROD_ID] & 0xffff)