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/mtdconcat.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/mtdconcat.c')
-rw-r--r-- | drivers/mtd/mtdconcat.c | 33 |
1 files changed, 19 insertions, 14 deletions
diff --git a/drivers/mtd/mtdconcat.c b/drivers/mtd/mtdconcat.c index 789842d0e6f2..ff8c14bcac68 100644 --- a/drivers/mtd/mtdconcat.c +++ b/drivers/mtd/mtdconcat.c | |||
@@ -197,7 +197,7 @@ concat_writev(struct mtd_info *mtd, const struct kvec *vecs, | |||
197 | continue; | 197 | continue; |
198 | } | 198 | } |
199 | 199 | ||
200 | size = min(total_len, (size_t)(subdev->size - to)); | 200 | size = min_t(uint64_t, total_len, subdev->size - to); |
201 | wsize = size; /* store for future use */ | 201 | wsize = size; /* store for future use */ |
202 | 202 | ||
203 | entry_high = entry_low; | 203 | entry_high = entry_low; |
@@ -385,7 +385,7 @@ static int concat_erase(struct mtd_info *mtd, struct erase_info *instr) | |||
385 | struct mtd_concat *concat = CONCAT(mtd); | 385 | struct mtd_concat *concat = CONCAT(mtd); |
386 | struct mtd_info *subdev; | 386 | struct mtd_info *subdev; |
387 | int i, err; | 387 | int i, err; |
388 | u_int32_t length, offset = 0; | 388 | uint64_t length, offset = 0; |
389 | struct erase_info *erase; | 389 | struct erase_info *erase; |
390 | 390 | ||
391 | if (!(mtd->flags & MTD_WRITEABLE)) | 391 | if (!(mtd->flags & MTD_WRITEABLE)) |
@@ -518,7 +518,7 @@ static int concat_erase(struct mtd_info *mtd, struct erase_info *instr) | |||
518 | return 0; | 518 | return 0; |
519 | } | 519 | } |
520 | 520 | ||
521 | static int concat_lock(struct mtd_info *mtd, loff_t ofs, size_t len) | 521 | static int concat_lock(struct mtd_info *mtd, loff_t ofs, uint64_t len) |
522 | { | 522 | { |
523 | struct mtd_concat *concat = CONCAT(mtd); | 523 | struct mtd_concat *concat = CONCAT(mtd); |
524 | int i, err = -EINVAL; | 524 | int i, err = -EINVAL; |
@@ -528,7 +528,7 @@ static int concat_lock(struct mtd_info *mtd, loff_t ofs, size_t len) | |||
528 | 528 | ||
529 | for (i = 0; i < concat->num_subdev; i++) { | 529 | for (i = 0; i < concat->num_subdev; i++) { |
530 | struct mtd_info *subdev = concat->subdev[i]; | 530 | struct mtd_info *subdev = concat->subdev[i]; |
531 | size_t size; | 531 | uint64_t size; |
532 | 532 | ||
533 | if (ofs >= subdev->size) { | 533 | if (ofs >= subdev->size) { |
534 | size = 0; | 534 | size = 0; |
@@ -556,7 +556,7 @@ static int concat_lock(struct mtd_info *mtd, loff_t ofs, size_t len) | |||
556 | return err; | 556 | return err; |
557 | } | 557 | } |
558 | 558 | ||
559 | static int concat_unlock(struct mtd_info *mtd, loff_t ofs, size_t len) | 559 | static int concat_unlock(struct mtd_info *mtd, loff_t ofs, uint64_t len) |
560 | { | 560 | { |
561 | struct mtd_concat *concat = CONCAT(mtd); | 561 | struct mtd_concat *concat = CONCAT(mtd); |
562 | int i, err = 0; | 562 | int i, err = 0; |
@@ -566,7 +566,7 @@ static int concat_unlock(struct mtd_info *mtd, loff_t ofs, size_t len) | |||
566 | 566 | ||
567 | for (i = 0; i < concat->num_subdev; i++) { | 567 | for (i = 0; i < concat->num_subdev; i++) { |
568 | struct mtd_info *subdev = concat->subdev[i]; | 568 | struct mtd_info *subdev = concat->subdev[i]; |
569 | size_t size; | 569 | uint64_t size; |
570 | 570 | ||
571 | if (ofs >= subdev->size) { | 571 | if (ofs >= subdev->size) { |
572 | size = 0; | 572 | size = 0; |
@@ -842,12 +842,14 @@ struct mtd_info *mtd_concat_create(struct mtd_info *subdev[], /* subdevices to c | |||
842 | concat->mtd.erasesize = curr_erasesize; | 842 | concat->mtd.erasesize = curr_erasesize; |
843 | concat->mtd.numeraseregions = 0; | 843 | concat->mtd.numeraseregions = 0; |
844 | } else { | 844 | } else { |
845 | uint64_t tmp64; | ||
846 | |||
845 | /* | 847 | /* |
846 | * erase block size varies across the subdevices: allocate | 848 | * erase block size varies across the subdevices: allocate |
847 | * space to store the data describing the variable erase regions | 849 | * space to store the data describing the variable erase regions |
848 | */ | 850 | */ |
849 | struct mtd_erase_region_info *erase_region_p; | 851 | struct mtd_erase_region_info *erase_region_p; |
850 | u_int32_t begin, position; | 852 | uint64_t begin, position; |
851 | 853 | ||
852 | concat->mtd.erasesize = max_erasesize; | 854 | concat->mtd.erasesize = max_erasesize; |
853 | concat->mtd.numeraseregions = num_erase_region; | 855 | concat->mtd.numeraseregions = num_erase_region; |
@@ -879,8 +881,9 @@ struct mtd_info *mtd_concat_create(struct mtd_info *subdev[], /* subdevices to c | |||
879 | erase_region_p->offset = begin; | 881 | erase_region_p->offset = begin; |
880 | erase_region_p->erasesize = | 882 | erase_region_p->erasesize = |
881 | curr_erasesize; | 883 | curr_erasesize; |
882 | erase_region_p->numblocks = | 884 | tmp64 = position - begin; |
883 | (position - begin) / curr_erasesize; | 885 | do_div(tmp64, curr_erasesize); |
886 | erase_region_p->numblocks = tmp64; | ||
884 | begin = position; | 887 | begin = position; |
885 | 888 | ||
886 | curr_erasesize = subdev[i]->erasesize; | 889 | curr_erasesize = subdev[i]->erasesize; |
@@ -897,9 +900,9 @@ struct mtd_info *mtd_concat_create(struct mtd_info *subdev[], /* subdevices to c | |||
897 | erase_region_p->offset = begin; | 900 | erase_region_p->offset = begin; |
898 | erase_region_p->erasesize = | 901 | erase_region_p->erasesize = |
899 | curr_erasesize; | 902 | curr_erasesize; |
900 | erase_region_p->numblocks = | 903 | tmp64 = position - begin; |
901 | (position - | 904 | do_div(tmp64, curr_erasesize); |
902 | begin) / curr_erasesize; | 905 | erase_region_p->numblocks = tmp64; |
903 | begin = position; | 906 | begin = position; |
904 | 907 | ||
905 | curr_erasesize = | 908 | curr_erasesize = |
@@ -909,14 +912,16 @@ struct mtd_info *mtd_concat_create(struct mtd_info *subdev[], /* subdevices to c | |||
909 | } | 912 | } |
910 | position += | 913 | position += |
911 | subdev[i]->eraseregions[j]. | 914 | subdev[i]->eraseregions[j]. |
912 | numblocks * curr_erasesize; | 915 | numblocks * (uint64_t)curr_erasesize; |
913 | } | 916 | } |
914 | } | 917 | } |
915 | } | 918 | } |
916 | /* Now write the final entry */ | 919 | /* Now write the final entry */ |
917 | erase_region_p->offset = begin; | 920 | erase_region_p->offset = begin; |
918 | erase_region_p->erasesize = curr_erasesize; | 921 | erase_region_p->erasesize = curr_erasesize; |
919 | erase_region_p->numblocks = (position - begin) / curr_erasesize; | 922 | tmp64 = position - begin; |
923 | do_div(tmp64, curr_erasesize); | ||
924 | erase_region_p->numblocks = tmp64; | ||
920 | } | 925 | } |
921 | 926 | ||
922 | return &concat->mtd; | 927 | return &concat->mtd; |