aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd/rfd_ftl.c
diff options
context:
space:
mode:
authorAdrian Hunter <ext-adrian.hunter@nokia.com>2008-12-10 08:37:21 -0500
committerDavid Woodhouse <David.Woodhouse@intel.com>2008-12-10 08:37:21 -0500
commit69423d99fc182a81f3c5db3eb5c140acc6fc64be (patch)
tree5f1818e6fb69388f0da276152646bf0597e318c0 /drivers/mtd/rfd_ftl.c
parent8a4c2495b142fe612b291a810d9e695f269c26db (diff)
[MTD] update internal API to support 64-bit device size
MTD internal API presently uses 32-bit values to represent device size. This patch updates them to 64-bits but leaves the external API unchanged. Extending the external API is a separate issue for several reasons. First, no one needs it at the moment. Secondly, whether the implementation is done with IOCTLs, sysfs or both is still debated. Thirdly external API changes require the internal API to be accepted first. Note that although the MTD API will be able to support 64-bit device sizes, existing drivers do not and are not required to do so, although NAND base has been updated. In general, changing from 32-bit to 64-bit values cause little or no changes to the majority of the code with the following exceptions: - printk message formats - division and modulus of 64-bit values - NAND base support - 32-bit local variables used by mtdpart and mtdconcat - naughtily assuming one structure maps to another in MEMERASE ioctl Signed-off-by: Adrian Hunter <ext-adrian.hunter@nokia.com> Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com> Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
Diffstat (limited to 'drivers/mtd/rfd_ftl.c')
-rw-r--r--drivers/mtd/rfd_ftl.c23
1 files changed, 12 insertions, 11 deletions
diff --git a/drivers/mtd/rfd_ftl.c b/drivers/mtd/rfd_ftl.c
index e538c0a72abb..490b4742ce3a 100644
--- a/drivers/mtd/rfd_ftl.c
+++ b/drivers/mtd/rfd_ftl.c
@@ -156,7 +156,7 @@ static int scan_header(struct partition *part)
156 size_t retlen; 156 size_t retlen;
157 157
158 sectors_per_block = part->block_size / SECTOR_SIZE; 158 sectors_per_block = part->block_size / SECTOR_SIZE;
159 part->total_blocks = part->mbd.mtd->size / part->block_size; 159 part->total_blocks = (u32)part->mbd.mtd->size / part->block_size;
160 160
161 if (part->total_blocks < 2) 161 if (part->total_blocks < 2)
162 return -ENOENT; 162 return -ENOENT;
@@ -276,16 +276,17 @@ static void erase_callback(struct erase_info *erase)
276 276
277 part = (struct partition*)erase->priv; 277 part = (struct partition*)erase->priv;
278 278
279 i = erase->addr / part->block_size; 279 i = (u32)erase->addr / part->block_size;
280 if (i >= part->total_blocks || part->blocks[i].offset != erase->addr) { 280 if (i >= part->total_blocks || part->blocks[i].offset != erase->addr ||
281 printk(KERN_ERR PREFIX "erase callback for unknown offset %x " 281 erase->addr > UINT_MAX) {
282 "on '%s'\n", erase->addr, part->mbd.mtd->name); 282 printk(KERN_ERR PREFIX "erase callback for unknown offset %llx "
283 "on '%s'\n", (unsigned long long)erase->addr, part->mbd.mtd->name);
283 return; 284 return;
284 } 285 }
285 286
286 if (erase->state != MTD_ERASE_DONE) { 287 if (erase->state != MTD_ERASE_DONE) {
287 printk(KERN_WARNING PREFIX "erase failed at 0x%x on '%s', " 288 printk(KERN_WARNING PREFIX "erase failed at 0x%llx on '%s', "
288 "state %d\n", erase->addr, 289 "state %d\n", (unsigned long long)erase->addr,
289 part->mbd.mtd->name, erase->state); 290 part->mbd.mtd->name, erase->state);
290 291
291 part->blocks[i].state = BLOCK_FAILED; 292 part->blocks[i].state = BLOCK_FAILED;
@@ -345,9 +346,9 @@ static int erase_block(struct partition *part, int block)
345 rc = part->mbd.mtd->erase(part->mbd.mtd, erase); 346 rc = part->mbd.mtd->erase(part->mbd.mtd, erase);
346 347
347 if (rc) { 348 if (rc) {
348 printk(KERN_ERR PREFIX "erase of region %x,%x on '%s' " 349 printk(KERN_ERR PREFIX "erase of region %llx,%llx on '%s' "
349 "failed\n", erase->addr, erase->len, 350 "failed\n", (unsigned long long)erase->addr,
350 part->mbd.mtd->name); 351 (unsigned long long)erase->len, part->mbd.mtd->name);
351 kfree(erase); 352 kfree(erase);
352 } 353 }
353 354
@@ -763,7 +764,7 @@ static void rfd_ftl_add_mtd(struct mtd_blktrans_ops *tr, struct mtd_info *mtd)
763{ 764{
764 struct partition *part; 765 struct partition *part;
765 766
766 if (mtd->type != MTD_NORFLASH) 767 if (mtd->type != MTD_NORFLASH || mtd->size > UINT_MAX)
767 return; 768 return;
768 769
769 part = kzalloc(sizeof(struct partition), GFP_KERNEL); 770 part = kzalloc(sizeof(struct partition), GFP_KERNEL);