diff options
Diffstat (limited to 'drivers/mtd/rfd_ftl.c')
-rw-r--r-- | drivers/mtd/rfd_ftl.c | 29 |
1 files changed, 14 insertions, 15 deletions
diff --git a/drivers/mtd/rfd_ftl.c b/drivers/mtd/rfd_ftl.c index e538c0a72abb..d2aa9c46530f 100644 --- a/drivers/mtd/rfd_ftl.c +++ b/drivers/mtd/rfd_ftl.c | |||
@@ -21,8 +21,6 @@ | |||
21 | 21 | ||
22 | #include <asm/types.h> | 22 | #include <asm/types.h> |
23 | 23 | ||
24 | #define const_cpu_to_le16 __constant_cpu_to_le16 | ||
25 | |||
26 | static int block_size = 0; | 24 | static int block_size = 0; |
27 | module_param(block_size, int, 0); | 25 | module_param(block_size, int, 0); |
28 | MODULE_PARM_DESC(block_size, "Block size to use by RFD, defaults to erase unit size"); | 26 | MODULE_PARM_DESC(block_size, "Block size to use by RFD, defaults to erase unit size"); |
@@ -156,7 +154,7 @@ static int scan_header(struct partition *part) | |||
156 | size_t retlen; | 154 | size_t retlen; |
157 | 155 | ||
158 | sectors_per_block = part->block_size / SECTOR_SIZE; | 156 | sectors_per_block = part->block_size / SECTOR_SIZE; |
159 | part->total_blocks = part->mbd.mtd->size / part->block_size; | 157 | part->total_blocks = (u32)part->mbd.mtd->size / part->block_size; |
160 | 158 | ||
161 | if (part->total_blocks < 2) | 159 | if (part->total_blocks < 2) |
162 | return -ENOENT; | 160 | return -ENOENT; |
@@ -276,16 +274,17 @@ static void erase_callback(struct erase_info *erase) | |||
276 | 274 | ||
277 | part = (struct partition*)erase->priv; | 275 | part = (struct partition*)erase->priv; |
278 | 276 | ||
279 | i = erase->addr / part->block_size; | 277 | i = (u32)erase->addr / part->block_size; |
280 | if (i >= part->total_blocks || part->blocks[i].offset != erase->addr) { | 278 | if (i >= part->total_blocks || part->blocks[i].offset != erase->addr || |
281 | printk(KERN_ERR PREFIX "erase callback for unknown offset %x " | 279 | erase->addr > UINT_MAX) { |
282 | "on '%s'\n", erase->addr, part->mbd.mtd->name); | 280 | printk(KERN_ERR PREFIX "erase callback for unknown offset %llx " |
281 | "on '%s'\n", (unsigned long long)erase->addr, part->mbd.mtd->name); | ||
283 | return; | 282 | return; |
284 | } | 283 | } |
285 | 284 | ||
286 | if (erase->state != MTD_ERASE_DONE) { | 285 | if (erase->state != MTD_ERASE_DONE) { |
287 | printk(KERN_WARNING PREFIX "erase failed at 0x%x on '%s', " | 286 | printk(KERN_WARNING PREFIX "erase failed at 0x%llx on '%s', " |
288 | "state %d\n", erase->addr, | 287 | "state %d\n", (unsigned long long)erase->addr, |
289 | part->mbd.mtd->name, erase->state); | 288 | part->mbd.mtd->name, erase->state); |
290 | 289 | ||
291 | part->blocks[i].state = BLOCK_FAILED; | 290 | part->blocks[i].state = BLOCK_FAILED; |
@@ -297,7 +296,7 @@ static void erase_callback(struct erase_info *erase) | |||
297 | return; | 296 | return; |
298 | } | 297 | } |
299 | 298 | ||
300 | magic = const_cpu_to_le16(RFD_MAGIC); | 299 | magic = cpu_to_le16(RFD_MAGIC); |
301 | 300 | ||
302 | part->blocks[i].state = BLOCK_ERASED; | 301 | part->blocks[i].state = BLOCK_ERASED; |
303 | part->blocks[i].free_sectors = part->data_sectors_per_block; | 302 | part->blocks[i].free_sectors = part->data_sectors_per_block; |
@@ -345,9 +344,9 @@ static int erase_block(struct partition *part, int block) | |||
345 | rc = part->mbd.mtd->erase(part->mbd.mtd, erase); | 344 | rc = part->mbd.mtd->erase(part->mbd.mtd, erase); |
346 | 345 | ||
347 | if (rc) { | 346 | if (rc) { |
348 | printk(KERN_ERR PREFIX "erase of region %x,%x on '%s' " | 347 | printk(KERN_ERR PREFIX "erase of region %llx,%llx on '%s' " |
349 | "failed\n", erase->addr, erase->len, | 348 | "failed\n", (unsigned long long)erase->addr, |
350 | part->mbd.mtd->name); | 349 | (unsigned long long)erase->len, part->mbd.mtd->name); |
351 | kfree(erase); | 350 | kfree(erase); |
352 | } | 351 | } |
353 | 352 | ||
@@ -587,7 +586,7 @@ static int mark_sector_deleted(struct partition *part, u_long old_addr) | |||
587 | int block, offset, rc; | 586 | int block, offset, rc; |
588 | u_long addr; | 587 | u_long addr; |
589 | size_t retlen; | 588 | size_t retlen; |
590 | u16 del = const_cpu_to_le16(SECTOR_DELETED); | 589 | u16 del = cpu_to_le16(SECTOR_DELETED); |
591 | 590 | ||
592 | block = old_addr / part->block_size; | 591 | block = old_addr / part->block_size; |
593 | offset = (old_addr % part->block_size) / SECTOR_SIZE - | 592 | offset = (old_addr % part->block_size) / SECTOR_SIZE - |
@@ -763,7 +762,7 @@ static void rfd_ftl_add_mtd(struct mtd_blktrans_ops *tr, struct mtd_info *mtd) | |||
763 | { | 762 | { |
764 | struct partition *part; | 763 | struct partition *part; |
765 | 764 | ||
766 | if (mtd->type != MTD_NORFLASH) | 765 | if (mtd->type != MTD_NORFLASH || mtd->size > UINT_MAX) |
767 | return; | 766 | return; |
768 | 767 | ||
769 | part = kzalloc(sizeof(struct partition), GFP_KERNEL); | 768 | part = kzalloc(sizeof(struct partition), GFP_KERNEL); |