diff options
author | Adrian Hunter <ext-adrian.hunter@nokia.com> | 2008-12-10 08:37:21 -0500 |
---|---|---|
committer | David Woodhouse <David.Woodhouse@intel.com> | 2008-12-10 08:37:21 -0500 |
commit | 69423d99fc182a81f3c5db3eb5c140acc6fc64be (patch) | |
tree | 5f1818e6fb69388f0da276152646bf0597e318c0 /drivers/mtd/mtdpart.c | |
parent | 8a4c2495b142fe612b291a810d9e695f269c26db (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/mtdpart.c')
-rw-r--r-- | drivers/mtd/mtdpart.c | 34 |
1 files changed, 17 insertions, 17 deletions
diff --git a/drivers/mtd/mtdpart.c b/drivers/mtd/mtdpart.c index 3728913fa5fa..144e6b613a77 100644 --- a/drivers/mtd/mtdpart.c +++ b/drivers/mtd/mtdpart.c | |||
@@ -26,7 +26,7 @@ static LIST_HEAD(mtd_partitions); | |||
26 | struct mtd_part { | 26 | struct mtd_part { |
27 | struct mtd_info mtd; | 27 | struct mtd_info mtd; |
28 | struct mtd_info *master; | 28 | struct mtd_info *master; |
29 | u_int32_t offset; | 29 | uint64_t offset; |
30 | int index; | 30 | int index; |
31 | struct list_head list; | 31 | struct list_head list; |
32 | int registered; | 32 | int registered; |
@@ -235,7 +235,7 @@ void mtd_erase_callback(struct erase_info *instr) | |||
235 | } | 235 | } |
236 | EXPORT_SYMBOL_GPL(mtd_erase_callback); | 236 | EXPORT_SYMBOL_GPL(mtd_erase_callback); |
237 | 237 | ||
238 | static int part_lock(struct mtd_info *mtd, loff_t ofs, size_t len) | 238 | static int part_lock(struct mtd_info *mtd, loff_t ofs, uint64_t len) |
239 | { | 239 | { |
240 | struct mtd_part *part = PART(mtd); | 240 | struct mtd_part *part = PART(mtd); |
241 | if ((len + ofs) > mtd->size) | 241 | if ((len + ofs) > mtd->size) |
@@ -243,7 +243,7 @@ static int part_lock(struct mtd_info *mtd, loff_t ofs, size_t len) | |||
243 | return part->master->lock(part->master, ofs + part->offset, len); | 243 | return part->master->lock(part->master, ofs + part->offset, len); |
244 | } | 244 | } |
245 | 245 | ||
246 | static int part_unlock(struct mtd_info *mtd, loff_t ofs, size_t len) | 246 | static int part_unlock(struct mtd_info *mtd, loff_t ofs, uint64_t len) |
247 | { | 247 | { |
248 | struct mtd_part *part = PART(mtd); | 248 | struct mtd_part *part = PART(mtd); |
249 | if ((len + ofs) > mtd->size) | 249 | if ((len + ofs) > mtd->size) |
@@ -317,7 +317,7 @@ EXPORT_SYMBOL(del_mtd_partitions); | |||
317 | 317 | ||
318 | static struct mtd_part *add_one_partition(struct mtd_info *master, | 318 | static struct mtd_part *add_one_partition(struct mtd_info *master, |
319 | const struct mtd_partition *part, int partno, | 319 | const struct mtd_partition *part, int partno, |
320 | u_int32_t cur_offset) | 320 | uint64_t cur_offset) |
321 | { | 321 | { |
322 | struct mtd_part *slave; | 322 | struct mtd_part *slave; |
323 | 323 | ||
@@ -395,19 +395,19 @@ static struct mtd_part *add_one_partition(struct mtd_info *master, | |||
395 | slave->offset = cur_offset; | 395 | slave->offset = cur_offset; |
396 | if (slave->offset == MTDPART_OFS_NXTBLK) { | 396 | if (slave->offset == MTDPART_OFS_NXTBLK) { |
397 | slave->offset = cur_offset; | 397 | slave->offset = cur_offset; |
398 | if ((cur_offset % master->erasesize) != 0) { | 398 | if (mtd_mod_by_eb(cur_offset, master) != 0) { |
399 | /* Round up to next erasesize */ | 399 | /* Round up to next erasesize */ |
400 | slave->offset = ((cur_offset / master->erasesize) + 1) * master->erasesize; | 400 | slave->offset = (mtd_div_by_eb(cur_offset, master) + 1) * master->erasesize; |
401 | printk(KERN_NOTICE "Moving partition %d: " | 401 | printk(KERN_NOTICE "Moving partition %d: " |
402 | "0x%08x -> 0x%08x\n", partno, | 402 | "0x%012llx -> 0x%012llx\n", partno, |
403 | cur_offset, slave->offset); | 403 | (unsigned long long)cur_offset, (unsigned long long)slave->offset); |
404 | } | 404 | } |
405 | } | 405 | } |
406 | if (slave->mtd.size == MTDPART_SIZ_FULL) | 406 | if (slave->mtd.size == MTDPART_SIZ_FULL) |
407 | slave->mtd.size = master->size - slave->offset; | 407 | slave->mtd.size = master->size - slave->offset; |
408 | 408 | ||
409 | printk(KERN_NOTICE "0x%08x-0x%08x : \"%s\"\n", slave->offset, | 409 | printk(KERN_NOTICE "0x%012llx-0x%012llx : \"%s\"\n", (unsigned long long)slave->offset, |
410 | slave->offset + slave->mtd.size, slave->mtd.name); | 410 | (unsigned long long)(slave->offset + slave->mtd.size), slave->mtd.name); |
411 | 411 | ||
412 | /* let's do some sanity checks */ | 412 | /* let's do some sanity checks */ |
413 | if (slave->offset >= master->size) { | 413 | if (slave->offset >= master->size) { |
@@ -420,13 +420,13 @@ static struct mtd_part *add_one_partition(struct mtd_info *master, | |||
420 | } | 420 | } |
421 | if (slave->offset + slave->mtd.size > master->size) { | 421 | if (slave->offset + slave->mtd.size > master->size) { |
422 | slave->mtd.size = master->size - slave->offset; | 422 | slave->mtd.size = master->size - slave->offset; |
423 | printk(KERN_WARNING"mtd: partition \"%s\" extends beyond the end of device \"%s\" -- size truncated to %#x\n", | 423 | printk(KERN_WARNING"mtd: partition \"%s\" extends beyond the end of device \"%s\" -- size truncated to %#llx\n", |
424 | part->name, master->name, slave->mtd.size); | 424 | part->name, master->name, (unsigned long long)slave->mtd.size); |
425 | } | 425 | } |
426 | if (master->numeraseregions > 1) { | 426 | if (master->numeraseregions > 1) { |
427 | /* Deal with variable erase size stuff */ | 427 | /* Deal with variable erase size stuff */ |
428 | int i, max = master->numeraseregions; | 428 | int i, max = master->numeraseregions; |
429 | u32 end = slave->offset + slave->mtd.size; | 429 | u64 end = slave->offset + slave->mtd.size; |
430 | struct mtd_erase_region_info *regions = master->eraseregions; | 430 | struct mtd_erase_region_info *regions = master->eraseregions; |
431 | 431 | ||
432 | /* Find the first erase regions which is part of this | 432 | /* Find the first erase regions which is part of this |
@@ -449,7 +449,7 @@ static struct mtd_part *add_one_partition(struct mtd_info *master, | |||
449 | } | 449 | } |
450 | 450 | ||
451 | if ((slave->mtd.flags & MTD_WRITEABLE) && | 451 | if ((slave->mtd.flags & MTD_WRITEABLE) && |
452 | (slave->offset % slave->mtd.erasesize)) { | 452 | mtd_mod_by_eb(slave->offset, &slave->mtd)) { |
453 | /* Doesn't start on a boundary of major erase size */ | 453 | /* Doesn't start on a boundary of major erase size */ |
454 | /* FIXME: Let it be writable if it is on a boundary of | 454 | /* FIXME: Let it be writable if it is on a boundary of |
455 | * _minor_ erase size though */ | 455 | * _minor_ erase size though */ |
@@ -458,7 +458,7 @@ static struct mtd_part *add_one_partition(struct mtd_info *master, | |||
458 | part->name); | 458 | part->name); |
459 | } | 459 | } |
460 | if ((slave->mtd.flags & MTD_WRITEABLE) && | 460 | if ((slave->mtd.flags & MTD_WRITEABLE) && |
461 | (slave->mtd.size % slave->mtd.erasesize)) { | 461 | mtd_mod_by_eb(slave->mtd.size, &slave->mtd)) { |
462 | slave->mtd.flags &= ~MTD_WRITEABLE; | 462 | slave->mtd.flags &= ~MTD_WRITEABLE; |
463 | printk(KERN_WARNING"mtd: partition \"%s\" doesn't end on an erase block -- force read-only\n", | 463 | printk(KERN_WARNING"mtd: partition \"%s\" doesn't end on an erase block -- force read-only\n", |
464 | part->name); | 464 | part->name); |
@@ -466,7 +466,7 @@ static struct mtd_part *add_one_partition(struct mtd_info *master, | |||
466 | 466 | ||
467 | slave->mtd.ecclayout = master->ecclayout; | 467 | slave->mtd.ecclayout = master->ecclayout; |
468 | if (master->block_isbad) { | 468 | if (master->block_isbad) { |
469 | uint32_t offs = 0; | 469 | uint64_t offs = 0; |
470 | 470 | ||
471 | while (offs < slave->mtd.size) { | 471 | while (offs < slave->mtd.size) { |
472 | if (master->block_isbad(master, | 472 | if (master->block_isbad(master, |
@@ -501,7 +501,7 @@ int add_mtd_partitions(struct mtd_info *master, | |||
501 | int nbparts) | 501 | int nbparts) |
502 | { | 502 | { |
503 | struct mtd_part *slave; | 503 | struct mtd_part *slave; |
504 | u_int32_t cur_offset = 0; | 504 | uint64_t cur_offset = 0; |
505 | int i; | 505 | int i; |
506 | 506 | ||
507 | printk(KERN_NOTICE "Creating %d MTD partitions on \"%s\":\n", nbparts, master->name); | 507 | printk(KERN_NOTICE "Creating %d MTD partitions on \"%s\":\n", nbparts, master->name); |