aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd/mtdconcat.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/mtd/mtdconcat.c')
-rw-r--r--drivers/mtd/mtdconcat.c35
1 files changed, 20 insertions, 15 deletions
diff --git a/drivers/mtd/mtdconcat.c b/drivers/mtd/mtdconcat.c
index 1a05cf37851e..3dbb1b38db66 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
521static int concat_lock(struct mtd_info *mtd, loff_t ofs, size_t len) 521static 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
559static int concat_unlock(struct mtd_info *mtd, loff_t ofs, size_t len) 559static 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;
@@ -696,7 +696,7 @@ struct mtd_info *mtd_concat_create(struct mtd_info *subdev[], /* subdevices to c
696 int i; 696 int i;
697 size_t size; 697 size_t size;
698 struct mtd_concat *concat; 698 struct mtd_concat *concat;
699 u_int32_t max_erasesize, curr_erasesize; 699 uint32_t max_erasesize, curr_erasesize;
700 int num_erase_region; 700 int num_erase_region;
701 701
702 printk(KERN_NOTICE "Concatenating MTD devices:\n"); 702 printk(KERN_NOTICE "Concatenating MTD devices:\n");
@@ -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;