From a7933483b983b48fe0ef51fb09543ff6d4ef4b05 Mon Sep 17 00:00:00 2001 From: "Martin K. Petersen" Date: Thu, 26 Nov 2009 12:00:43 -0500 Subject: [PATCH] --- yaml --- r: 172895 b: refs/heads/master c: d0634c4aea0b80447cbdc4c0db285004b860c455 h: refs/heads/master i: 172893: b2dbff13f649af5466a034802e69734be01627ca 172891: 921655a4712d9f9eb183ab1261cd81f521c0c33b 172887: 14093770e7cabf94b1814bb4a8bbc6ee0cf53379 172879: 6fd5b9897b51d80ca9bd7f020f83e52e9c44a21c 172863: 1cabe66632c30f8f1b1638391b73b03b1e83234b v: v3 --- [refs] | 2 +- trunk/drivers/ata/libata-scsi.c | 2 +- trunk/include/linux/ata.h | 20 ++++++++++---------- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/[refs] b/[refs] index 5ad1e2547112..0b4db3821271 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: e78db4dfb1355a895f7ea50133b702b55b8ed184 +refs/heads/master: d0634c4aea0b80447cbdc4c0db285004b860c455 diff --git a/trunk/drivers/ata/libata-scsi.c b/trunk/drivers/ata/libata-scsi.c index e1e186b9dfcc..62e6b9ea96af 100644 --- a/trunk/drivers/ata/libata-scsi.c +++ b/trunk/drivers/ata/libata-scsi.c @@ -2972,7 +2972,7 @@ static unsigned int ata_scsi_write_same_xlat(struct ata_queued_cmd *qc) goto invalid_fld; buf = page_address(sg_page(scsi_sglist(scmd))); - size = ata_set_lba_range_entries(buf, 512 / 8, block, n_block); + size = ata_set_lba_range_entries(buf, 512, block, n_block); tf->protocol = ATA_PROT_DMA; tf->hob_feature = 0; diff --git a/trunk/include/linux/ata.h b/trunk/include/linux/ata.h index dfa2298bf488..38a6948ce0c2 100644 --- a/trunk/include/linux/ata.h +++ b/trunk/include/linux/ata.h @@ -982,17 +982,17 @@ static inline void ata_id_to_hd_driveid(u16 *id) } /* - * Write up to 'max' LBA Range Entries to the buffer that will cover the - * extent from sector to sector + count. This is used for TRIM and for - * ADD LBA(S) TO NV CACHE PINNED SET. + * Write LBA Range Entries to the buffer that will cover the extent from + * sector to sector + count. This is used for TRIM and for ADD LBA(S) + * TO NV CACHE PINNED SET. */ -static inline unsigned ata_set_lba_range_entries(void *_buffer, unsigned max, - u64 sector, unsigned long count) +static inline unsigned ata_set_lba_range_entries(void *_buffer, + unsigned buf_size, u64 sector, unsigned long count) { __le64 *buffer = _buffer; - unsigned i = 0; + unsigned i = 0, used_bytes; - while (i < max) { + while (i < buf_size / 8 ) { /* 6-byte LBA + 2-byte range per entry */ u64 entry = sector | ((u64)(count > 0xffff ? 0xffff : count) << 48); buffer[i++] = __cpu_to_le64(entry); @@ -1002,9 +1002,9 @@ static inline unsigned ata_set_lba_range_entries(void *_buffer, unsigned max, sector += 0xffff; } - max = ALIGN(i * 8, 512); - memset(buffer + i, 0, max - i * 8); - return max; + used_bytes = ALIGN(i * 8, 512); + memset(buffer + i, 0, used_bytes - i * 8); + return used_bytes; } static inline int is_multi_taskfile(struct ata_taskfile *tf)