aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/ata.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/ata.h')
-rw-r--r--include/linux/ata.h20
1 files changed, 10 insertions, 10 deletions
diff --git a/include/linux/ata.h b/include/linux/ata.h
index dfa2298bf488..38a6948ce0c2 100644
--- a/include/linux/ata.h
+++ b/include/linux/ata.h
@@ -982,17 +982,17 @@ static inline void ata_id_to_hd_driveid(u16 *id)
982} 982}
983 983
984/* 984/*
985 * Write up to 'max' LBA Range Entries to the buffer that will cover the 985 * Write LBA Range Entries to the buffer that will cover the extent from
986 * extent from sector to sector + count. This is used for TRIM and for 986 * sector to sector + count. This is used for TRIM and for ADD LBA(S)
987 * ADD LBA(S) TO NV CACHE PINNED SET. 987 * TO NV CACHE PINNED SET.
988 */ 988 */
989static inline unsigned ata_set_lba_range_entries(void *_buffer, unsigned max, 989static inline unsigned ata_set_lba_range_entries(void *_buffer,
990 u64 sector, unsigned long count) 990 unsigned buf_size, u64 sector, unsigned long count)
991{ 991{
992 __le64 *buffer = _buffer; 992 __le64 *buffer = _buffer;
993 unsigned i = 0; 993 unsigned i = 0, used_bytes;
994 994
995 while (i < max) { 995 while (i < buf_size / 8 ) { /* 6-byte LBA + 2-byte range per entry */
996 u64 entry = sector | 996 u64 entry = sector |
997 ((u64)(count > 0xffff ? 0xffff : count) << 48); 997 ((u64)(count > 0xffff ? 0xffff : count) << 48);
998 buffer[i++] = __cpu_to_le64(entry); 998 buffer[i++] = __cpu_to_le64(entry);
@@ -1002,9 +1002,9 @@ static inline unsigned ata_set_lba_range_entries(void *_buffer, unsigned max,
1002 sector += 0xffff; 1002 sector += 0xffff;
1003 } 1003 }
1004 1004
1005 max = ALIGN(i * 8, 512); 1005 used_bytes = ALIGN(i * 8, 512);
1006 memset(buffer + i, 0, max - i * 8); 1006 memset(buffer + i, 0, used_bytes - i * 8);
1007 return max; 1007 return used_bytes;
1008} 1008}
1009 1009
1010static inline int is_multi_taskfile(struct ata_taskfile *tf) 1010static inline int is_multi_taskfile(struct ata_taskfile *tf)