aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArtem Bityutskiy <Artem.Bityutskiy@nokia.com>2008-12-18 07:10:05 -0500
committerDavid Woodhouse <David.Woodhouse@intel.com>2008-12-19 11:23:35 -0500
commitd85316ac459f1cdd14ea1828eebeac1f1028e167 (patch)
tree2d9cc1bc3cec5cff015160b0dfcf45bbdbf59651
parent5b7f3a500cd097d673a6283fbb748c1e4f87bac6 (diff)
[MTD] fix m25p80 64-bit divisions
MTD has recently been upgraded for 64-bit support, see commit number 69423d99fc182a81f3c5db3eb5c140acc6fc64be in the mtd-2.6.git tree (git://git.infradead.org/mtd-2.6.git) or see this URL: http://git.infradead.org/mtd-2.6.git?a=commit;h=69423d99fc182a81f3c5db3eb5c140acc6fc64be Some variables in MTD data structures which were 32-bit became 64-bit. Namely, the 'size' field in 'struct mtd_info' and the 'addr'/'len' fields in 'struct erase_info'. This means we have to use 'do_div' to divide them. This patch fixes the following linking error: ERROR: "__umoddi3" [drivers/mtd/devices/m25p80.ko] undefined! This patch changes divisions of 64-bit variable so that they use 'do_div'. This patch also change some print placeholders to get rid of gcc warnings. Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com> Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
-rw-r--r--drivers/mtd/devices/m25p80.c37
1 files changed, 19 insertions, 18 deletions
diff --git a/drivers/mtd/devices/m25p80.c b/drivers/mtd/devices/m25p80.c
index 6659b2275c0c..9be0229c3d30 100644
--- a/drivers/mtd/devices/m25p80.c
+++ b/drivers/mtd/devices/m25p80.c
@@ -20,6 +20,7 @@
20#include <linux/device.h> 20#include <linux/device.h>
21#include <linux/interrupt.h> 21#include <linux/interrupt.h>
22#include <linux/mutex.h> 22#include <linux/mutex.h>
23#include <linux/math64.h>
23 24
24#include <linux/mtd/mtd.h> 25#include <linux/mtd/mtd.h>
25#include <linux/mtd/partitions.h> 26#include <linux/mtd/partitions.h>
@@ -169,9 +170,9 @@ static int wait_till_ready(struct m25p *flash)
169 */ 170 */
170static int erase_chip(struct m25p *flash) 171static int erase_chip(struct m25p *flash)
171{ 172{
172 DEBUG(MTD_DEBUG_LEVEL3, "%s: %s %dKiB\n", 173 DEBUG(MTD_DEBUG_LEVEL3, "%s: %s %lldKiB\n",
173 flash->spi->dev.bus_id, __func__, 174 flash->spi->dev.bus_id, __func__,
174 flash->mtd.size / 1024); 175 (long long)(flash->mtd.size >> 10));
175 176
176 /* Wait until finished previous write command. */ 177 /* Wait until finished previous write command. */
177 if (wait_till_ready(flash)) 178 if (wait_till_ready(flash))
@@ -232,18 +233,18 @@ static int m25p80_erase(struct mtd_info *mtd, struct erase_info *instr)
232{ 233{
233 struct m25p *flash = mtd_to_m25p(mtd); 234 struct m25p *flash = mtd_to_m25p(mtd);
234 u32 addr,len; 235 u32 addr,len;
236 uint32_t rem;
235 237
236 DEBUG(MTD_DEBUG_LEVEL2, "%s: %s %s 0x%08x, len %d\n", 238 DEBUG(MTD_DEBUG_LEVEL2, "%s: %s %s 0x%llx, len %lld\n",
237 flash->spi->dev.bus_id, __func__, "at", 239 flash->spi->dev.bus_id, __func__, "at",
238 (u32)instr->addr, instr->len); 240 (long long)instr->addr, (long long)instr->len);
239 241
240 /* sanity checks */ 242 /* sanity checks */
241 if (instr->addr + instr->len > flash->mtd.size) 243 if (instr->addr + instr->len > flash->mtd.size)
242 return -EINVAL; 244 return -EINVAL;
243 if ((instr->addr % mtd->erasesize) != 0 245 div_u64_rem(instr->len, mtd->erasesize, &rem);
244 || (instr->len % mtd->erasesize) != 0) { 246 if (rem)
245 return -EINVAL; 247 return -EINVAL;
246 }
247 248
248 addr = instr->addr; 249 addr = instr->addr;
249 len = instr->len; 250 len = instr->len;
@@ -677,24 +678,24 @@ static int __devinit m25p_probe(struct spi_device *spi)
677 flash->mtd.erasesize = info->sector_size; 678 flash->mtd.erasesize = info->sector_size;
678 } 679 }
679 680
680 dev_info(&spi->dev, "%s (%d Kbytes)\n", info->name, 681 dev_info(&spi->dev, "%s (%lld Kbytes)\n", info->name,
681 flash->mtd.size / 1024); 682 (long long)flash->mtd.size >> 10);
682 683
683 DEBUG(MTD_DEBUG_LEVEL2, 684 DEBUG(MTD_DEBUG_LEVEL2,
684 "mtd .name = %s, .size = 0x%.8x (%uMiB) " 685 "mtd .name = %s, .size = 0x%llx (%lldMiB) "
685 ".erasesize = 0x%.8x (%uKiB) .numeraseregions = %d\n", 686 ".erasesize = 0x%.8x (%uKiB) .numeraseregions = %d\n",
686 flash->mtd.name, 687 flash->mtd.name,
687 flash->mtd.size, flash->mtd.size / (1024*1024), 688 (long long)flash->mtd.size, (long long)(flash->mtd.size >> 20),
688 flash->mtd.erasesize, flash->mtd.erasesize / 1024, 689 flash->mtd.erasesize, flash->mtd.erasesize / 1024,
689 flash->mtd.numeraseregions); 690 flash->mtd.numeraseregions);
690 691
691 if (flash->mtd.numeraseregions) 692 if (flash->mtd.numeraseregions)
692 for (i = 0; i < flash->mtd.numeraseregions; i++) 693 for (i = 0; i < flash->mtd.numeraseregions; i++)
693 DEBUG(MTD_DEBUG_LEVEL2, 694 DEBUG(MTD_DEBUG_LEVEL2,
694 "mtd.eraseregions[%d] = { .offset = 0x%.8x, " 695 "mtd.eraseregions[%d] = { .offset = 0x%llx, "
695 ".erasesize = 0x%.8x (%uKiB), " 696 ".erasesize = 0x%.8x (%uKiB), "
696 ".numblocks = %d }\n", 697 ".numblocks = %d }\n",
697 i, flash->mtd.eraseregions[i].offset, 698 i, (long long)flash->mtd.eraseregions[i].offset,
698 flash->mtd.eraseregions[i].erasesize, 699 flash->mtd.eraseregions[i].erasesize,
699 flash->mtd.eraseregions[i].erasesize / 1024, 700 flash->mtd.eraseregions[i].erasesize / 1024,
700 flash->mtd.eraseregions[i].numblocks); 701 flash->mtd.eraseregions[i].numblocks);
@@ -722,12 +723,12 @@ static int __devinit m25p_probe(struct spi_device *spi)
722 if (nr_parts > 0) { 723 if (nr_parts > 0) {
723 for (i = 0; i < nr_parts; i++) { 724 for (i = 0; i < nr_parts; i++) {
724 DEBUG(MTD_DEBUG_LEVEL2, "partitions[%d] = " 725 DEBUG(MTD_DEBUG_LEVEL2, "partitions[%d] = "
725 "{.name = %s, .offset = 0x%.8x, " 726 "{.name = %s, .offset = 0x%llx, "
726 ".size = 0x%.8x (%uKiB) }\n", 727 ".size = 0x%llx (%lldKiB) }\n",
727 i, parts[i].name, 728 i, parts[i].name,
728 parts[i].offset, 729 (long long)parts[i].offset,
729 parts[i].size, 730 (long long)parts[i].size,
730 parts[i].size / 1024); 731 (long long)(parts[i].size >> 10));
731 } 732 }
732 flash->partitioned = 1; 733 flash->partitioned = 1;
733 return add_mtd_partitions(&flash->mtd, parts, nr_parts); 734 return add_mtd_partitions(&flash->mtd, parts, nr_parts);