diff options
Diffstat (limited to 'drivers/mtd/ubi')
-rw-r--r-- | drivers/mtd/ubi/build.c | 42 | ||||
-rw-r--r-- | drivers/mtd/ubi/ubi.h | 3 |
2 files changed, 16 insertions, 29 deletions
diff --git a/drivers/mtd/ubi/build.c b/drivers/mtd/ubi/build.c index 071454376643..403c10a668bd 100644 --- a/drivers/mtd/ubi/build.c +++ b/drivers/mtd/ubi/build.c | |||
@@ -50,13 +50,11 @@ | |||
50 | * struct mtd_dev_param - MTD device parameter description data structure. | 50 | * struct mtd_dev_param - MTD device parameter description data structure. |
51 | * @name: MTD device name or number string | 51 | * @name: MTD device name or number string |
52 | * @vid_hdr_offs: VID header offset | 52 | * @vid_hdr_offs: VID header offset |
53 | * @data_offs: data offset | ||
54 | */ | 53 | */ |
55 | struct mtd_dev_param | 54 | struct mtd_dev_param |
56 | { | 55 | { |
57 | char name[MTD_PARAM_LEN_MAX]; | 56 | char name[MTD_PARAM_LEN_MAX]; |
58 | int vid_hdr_offs; | 57 | int vid_hdr_offs; |
59 | int data_offs; | ||
60 | }; | 58 | }; |
61 | 59 | ||
62 | /* Numbers of elements set in the @mtd_dev_param array */ | 60 | /* Numbers of elements set in the @mtd_dev_param array */ |
@@ -512,7 +510,7 @@ static int io_init(struct ubi_device *ubi) | |||
512 | return -EINVAL; | 510 | return -EINVAL; |
513 | } | 511 | } |
514 | 512 | ||
515 | if (ubi->vid_hdr_offset < 0 || ubi->leb_start < ubi->vid_hdr_offset) | 513 | if (ubi->vid_hdr_offset < 0) |
516 | return -EINVAL; | 514 | return -EINVAL; |
517 | 515 | ||
518 | /* | 516 | /* |
@@ -562,10 +560,8 @@ static int io_init(struct ubi_device *ubi) | |||
562 | } | 560 | } |
563 | 561 | ||
564 | /* Similar for the data offset */ | 562 | /* Similar for the data offset */ |
565 | if (ubi->leb_start == 0) { | 563 | ubi->leb_start = ubi->vid_hdr_offset + ubi->vid_hdr_alsize; |
566 | ubi->leb_start = ubi->vid_hdr_offset + ubi->vid_hdr_alsize; | 564 | ubi->leb_start = ALIGN(ubi->leb_start, ubi->min_io_size); |
567 | ubi->leb_start = ALIGN(ubi->leb_start, ubi->min_io_size); | ||
568 | } | ||
569 | 565 | ||
570 | dbg_msg("vid_hdr_offset %d", ubi->vid_hdr_offset); | 566 | dbg_msg("vid_hdr_offset %d", ubi->vid_hdr_offset); |
571 | dbg_msg("vid_hdr_aloffset %d", ubi->vid_hdr_aloffset); | 567 | dbg_msg("vid_hdr_aloffset %d", ubi->vid_hdr_aloffset); |
@@ -626,7 +622,6 @@ static int io_init(struct ubi_device *ubi) | |||
626 | * ubi_attach_mtd_dev - attach an MTD device. | 622 | * ubi_attach_mtd_dev - attach an MTD device. |
627 | * @mtd_dev: MTD device description object | 623 | * @mtd_dev: MTD device description object |
628 | * @vid_hdr_offset: VID header offset | 624 | * @vid_hdr_offset: VID header offset |
629 | * @data_offset: data offset | ||
630 | * | 625 | * |
631 | * This function attaches an MTD device to UBI. It first treats @mtd_dev as the | 626 | * This function attaches an MTD device to UBI. It first treats @mtd_dev as the |
632 | * MTD device name, and tries to open it by this name. If it is unable to open, | 627 | * MTD device name, and tries to open it by this name. If it is unable to open, |
@@ -637,8 +632,7 @@ static int io_init(struct ubi_device *ubi) | |||
637 | * Note, the invocations of this function has to be serialized by the | 632 | * Note, the invocations of this function has to be serialized by the |
638 | * @ubi_devices_mutex. | 633 | * @ubi_devices_mutex. |
639 | */ | 634 | */ |
640 | int ubi_attach_mtd_dev(struct mtd_info *mtd, int vid_hdr_offset, | 635 | int ubi_attach_mtd_dev(struct mtd_info *mtd, int vid_hdr_offset) |
641 | int data_offset) | ||
642 | { | 636 | { |
643 | struct ubi_device *ubi; | 637 | struct ubi_device *ubi; |
644 | int i, err; | 638 | int i, err; |
@@ -674,10 +668,9 @@ int ubi_attach_mtd_dev(struct mtd_info *mtd, int vid_hdr_offset, | |||
674 | ubi->mtd = mtd; | 668 | ubi->mtd = mtd; |
675 | ubi->ubi_num = i; | 669 | ubi->ubi_num = i; |
676 | ubi->vid_hdr_offset = vid_hdr_offset; | 670 | ubi->vid_hdr_offset = vid_hdr_offset; |
677 | ubi->leb_start = data_offset; | ||
678 | 671 | ||
679 | dbg_msg("attaching mtd%d to ubi%d: VID header offset %d data offset %d", | 672 | dbg_msg("attaching mtd%d to ubi%d: VID header offset %d", |
680 | mtd->index, ubi->ubi_num, vid_hdr_offset, data_offset); | 673 | mtd->index, ubi->ubi_num, vid_hdr_offset); |
681 | 674 | ||
682 | err = io_init(ubi); | 675 | err = io_init(ubi); |
683 | if (err) | 676 | if (err) |
@@ -942,7 +935,7 @@ static int __init ubi_init(void) | |||
942 | } | 935 | } |
943 | 936 | ||
944 | mutex_lock(&ubi_devices_mutex); | 937 | mutex_lock(&ubi_devices_mutex); |
945 | err = ubi_attach_mtd_dev(mtd, p->vid_hdr_offs, p->data_offs); | 938 | err = ubi_attach_mtd_dev(mtd, p->vid_hdr_offs); |
946 | mutex_unlock(&ubi_devices_mutex); | 939 | mutex_unlock(&ubi_devices_mutex); |
947 | if (err < 0) { | 940 | if (err < 0) { |
948 | put_mtd_device(mtd); | 941 | put_mtd_device(mtd); |
@@ -1094,13 +1087,9 @@ static int __init ubi_mtd_param_parse(const char *val, struct kernel_param *kp) | |||
1094 | 1087 | ||
1095 | if (tokens[1]) | 1088 | if (tokens[1]) |
1096 | p->vid_hdr_offs = bytes_str_to_int(tokens[1]); | 1089 | p->vid_hdr_offs = bytes_str_to_int(tokens[1]); |
1097 | if (tokens[2]) | ||
1098 | p->data_offs = bytes_str_to_int(tokens[2]); | ||
1099 | 1090 | ||
1100 | if (p->vid_hdr_offs < 0) | 1091 | if (p->vid_hdr_offs < 0) |
1101 | return p->vid_hdr_offs; | 1092 | return p->vid_hdr_offs; |
1102 | if (p->data_offs < 0) | ||
1103 | return p->data_offs; | ||
1104 | 1093 | ||
1105 | mtd_devs += 1; | 1094 | mtd_devs += 1; |
1106 | return 0; | 1095 | return 0; |
@@ -1108,16 +1097,15 @@ static int __init ubi_mtd_param_parse(const char *val, struct kernel_param *kp) | |||
1108 | 1097 | ||
1109 | module_param_call(mtd, ubi_mtd_param_parse, NULL, NULL, 000); | 1098 | module_param_call(mtd, ubi_mtd_param_parse, NULL, NULL, 000); |
1110 | MODULE_PARM_DESC(mtd, "MTD devices to attach. Parameter format: " | 1099 | MODULE_PARM_DESC(mtd, "MTD devices to attach. Parameter format: " |
1111 | "mtd=<name|num>[,<vid_hdr_offs>,<data_offs>]. " | 1100 | "mtd=<name|num>[,<vid_hdr_offs>].\n" |
1112 | "Multiple \"mtd\" parameters may be specified.\n" | 1101 | "Multiple \"mtd\" parameters may be specified.\n" |
1113 | "MTD devices may be specified by their number or name. " | 1102 | "MTD devices may be specified by their number or name.\n" |
1114 | "Optional \"vid_hdr_offs\" and \"data_offs\" parameters " | 1103 | "Optional \"vid_hdr_offs\" parameter specifies UBI VID " |
1115 | "specify UBI VID header position and data starting " | 1104 | "header position and data starting position to be used " |
1116 | "position to be used by UBI.\n" | 1105 | "by UBI.\n" |
1117 | "Example: mtd=content,1984,2048 mtd=4 - attach MTD device" | 1106 | "Example: mtd=content,1984 mtd=4 - attach MTD device" |
1118 | "with name content using VID header offset 1984 and data " | 1107 | "with name \"content\" using VID header offset 1984, and " |
1119 | "start 2048, and MTD device number 4 using default " | 1108 | "MTD device number 4 with default VID header offset."); |
1120 | "offsets"); | ||
1121 | 1109 | ||
1122 | MODULE_VERSION(__stringify(UBI_VERSION)); | 1110 | MODULE_VERSION(__stringify(UBI_VERSION)); |
1123 | MODULE_DESCRIPTION("UBI - Unsorted Block Images"); | 1111 | MODULE_DESCRIPTION("UBI - Unsorted Block Images"); |
diff --git a/drivers/mtd/ubi/ubi.h b/drivers/mtd/ubi/ubi.h index 25ff15a7fc58..4c3607e5743e 100644 --- a/drivers/mtd/ubi/ubi.h +++ b/drivers/mtd/ubi/ubi.h | |||
@@ -483,8 +483,7 @@ int ubi_io_write_vid_hdr(struct ubi_device *ubi, int pnum, | |||
483 | struct ubi_vid_hdr *vid_hdr); | 483 | struct ubi_vid_hdr *vid_hdr); |
484 | 484 | ||
485 | /* build.c */ | 485 | /* build.c */ |
486 | int ubi_attach_mtd_dev(struct mtd_info *mtd, int vid_hdr_offset, | 486 | int ubi_attach_mtd_dev(struct mtd_info *mtd, int vid_hdr_offset); |
487 | int data_offset); | ||
488 | int ubi_detach_mtd_dev(int ubi_num, int anyway); | 487 | int ubi_detach_mtd_dev(int ubi_num, int anyway); |
489 | struct ubi_device *ubi_get_device(int ubi_num); | 488 | struct ubi_device *ubi_get_device(int ubi_num); |
490 | void ubi_put_device(struct ubi_device *ubi); | 489 | void ubi_put_device(struct ubi_device *ubi); |