diff options
author | Richard Genoud <richard.genoud@gmail.com> | 2012-08-20 12:00:11 -0400 |
---|---|---|
committer | Artem Bityutskiy <artem.bityutskiy@linux.intel.com> | 2012-09-04 02:39:01 -0400 |
commit | 256334c3191af9d9e520082db9beb75ff801d86c (patch) | |
tree | 55e209de188658b9b23022ee1d0493f62424c738 /drivers/mtd | |
parent | 5993f9b7380d77fd23f5402dcfb701aedb327ffe (diff) |
UBI: prepare for max_beb_per1024 module parameter addition
This patch prepare the way for the addition of max_beb_per1024 module
parameter. There's no functional change.
Signed-off-by: Richard Genoud <richard.genoud@gmail.com>
Reviewed-by: Shmulik Ladkani <shmulik.ladkani@gmail.com>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Diffstat (limited to 'drivers/mtd')
-rw-r--r-- | drivers/mtd/ubi/build.c | 14 | ||||
-rw-r--r-- | drivers/mtd/ubi/cdev.c | 3 | ||||
-rw-r--r-- | drivers/mtd/ubi/ubi.h | 3 |
3 files changed, 12 insertions, 8 deletions
diff --git a/drivers/mtd/ubi/build.c b/drivers/mtd/ubi/build.c index 5877531f2268..8a4eb7c3e0f4 100644 --- a/drivers/mtd/ubi/build.c +++ b/drivers/mtd/ubi/build.c | |||
@@ -599,6 +599,7 @@ static int get_bad_peb_limit(const struct ubi_device *ubi, int max_beb_per1024) | |||
599 | /** | 599 | /** |
600 | * io_init - initialize I/O sub-system for a given UBI device. | 600 | * io_init - initialize I/O sub-system for a given UBI device. |
601 | * @ubi: UBI device description object | 601 | * @ubi: UBI device description object |
602 | * @max_beb_per1024: maximum expected number of bad PEB per 1024 PEBs | ||
602 | * | 603 | * |
603 | * If @ubi->vid_hdr_offset or @ubi->leb_start is zero, default offsets are | 604 | * If @ubi->vid_hdr_offset or @ubi->leb_start is zero, default offsets are |
604 | * assumed: | 605 | * assumed: |
@@ -611,10 +612,8 @@ static int get_bad_peb_limit(const struct ubi_device *ubi, int max_beb_per1024) | |||
611 | * This function returns zero in case of success and a negative error code in | 612 | * This function returns zero in case of success and a negative error code in |
612 | * case of failure. | 613 | * case of failure. |
613 | */ | 614 | */ |
614 | static int io_init(struct ubi_device *ubi) | 615 | static int io_init(struct ubi_device *ubi, int max_beb_per1024) |
615 | { | 616 | { |
616 | const int max_beb_per1024 = CONFIG_MTD_UBI_BEB_LIMIT; | ||
617 | |||
618 | if (ubi->mtd->numeraseregions != 0) { | 617 | if (ubi->mtd->numeraseregions != 0) { |
619 | /* | 618 | /* |
620 | * Some flashes have several erase regions. Different regions | 619 | * Some flashes have several erase regions. Different regions |
@@ -836,6 +835,7 @@ static int autoresize(struct ubi_device *ubi, int vol_id) | |||
836 | * @mtd: MTD device description object | 835 | * @mtd: MTD device description object |
837 | * @ubi_num: number to assign to the new UBI device | 836 | * @ubi_num: number to assign to the new UBI device |
838 | * @vid_hdr_offset: VID header offset | 837 | * @vid_hdr_offset: VID header offset |
838 | * @max_beb_per1024: maximum number of expected bad blocks per 1024 PEBs | ||
839 | * | 839 | * |
840 | * This function attaches MTD device @mtd_dev to UBI and assign @ubi_num number | 840 | * This function attaches MTD device @mtd_dev to UBI and assign @ubi_num number |
841 | * to the newly created UBI device, unless @ubi_num is %UBI_DEV_NUM_AUTO, in | 841 | * to the newly created UBI device, unless @ubi_num is %UBI_DEV_NUM_AUTO, in |
@@ -846,7 +846,8 @@ static int autoresize(struct ubi_device *ubi, int vol_id) | |||
846 | * Note, the invocations of this function has to be serialized by the | 846 | * Note, the invocations of this function has to be serialized by the |
847 | * @ubi_devices_mutex. | 847 | * @ubi_devices_mutex. |
848 | */ | 848 | */ |
849 | int ubi_attach_mtd_dev(struct mtd_info *mtd, int ubi_num, int vid_hdr_offset) | 849 | int ubi_attach_mtd_dev(struct mtd_info *mtd, int ubi_num, |
850 | int vid_hdr_offset, int max_beb_per1024) | ||
850 | { | 851 | { |
851 | struct ubi_device *ubi; | 852 | struct ubi_device *ubi; |
852 | int i, err, ref = 0; | 853 | int i, err, ref = 0; |
@@ -919,7 +920,7 @@ int ubi_attach_mtd_dev(struct mtd_info *mtd, int ubi_num, int vid_hdr_offset) | |||
919 | dbg_msg("sizeof(struct ubi_ainf_peb) %zu", sizeof(struct ubi_ainf_peb)); | 920 | dbg_msg("sizeof(struct ubi_ainf_peb) %zu", sizeof(struct ubi_ainf_peb)); |
920 | dbg_msg("sizeof(struct ubi_wl_entry) %zu", sizeof(struct ubi_wl_entry)); | 921 | dbg_msg("sizeof(struct ubi_wl_entry) %zu", sizeof(struct ubi_wl_entry)); |
921 | 922 | ||
922 | err = io_init(ubi); | 923 | err = io_init(ubi, max_beb_per1024); |
923 | if (err) | 924 | if (err) |
924 | goto out_free; | 925 | goto out_free; |
925 | 926 | ||
@@ -1208,7 +1209,8 @@ static int __init ubi_init(void) | |||
1208 | 1209 | ||
1209 | mutex_lock(&ubi_devices_mutex); | 1210 | mutex_lock(&ubi_devices_mutex); |
1210 | err = ubi_attach_mtd_dev(mtd, UBI_DEV_NUM_AUTO, | 1211 | err = ubi_attach_mtd_dev(mtd, UBI_DEV_NUM_AUTO, |
1211 | p->vid_hdr_offs); | 1212 | p->vid_hdr_offs, |
1213 | CONFIG_MTD_UBI_BEB_LIMIT); | ||
1212 | mutex_unlock(&ubi_devices_mutex); | 1214 | mutex_unlock(&ubi_devices_mutex); |
1213 | if (err < 0) { | 1215 | if (err < 0) { |
1214 | ubi_err("cannot attach mtd%d", mtd->index); | 1216 | ubi_err("cannot attach mtd%d", mtd->index); |
diff --git a/drivers/mtd/ubi/cdev.c b/drivers/mtd/ubi/cdev.c index fb5567878181..619f9144f990 100644 --- a/drivers/mtd/ubi/cdev.c +++ b/drivers/mtd/ubi/cdev.c | |||
@@ -1010,7 +1010,8 @@ static long ctrl_cdev_ioctl(struct file *file, unsigned int cmd, | |||
1010 | * 'ubi_attach_mtd_dev()'. | 1010 | * 'ubi_attach_mtd_dev()'. |
1011 | */ | 1011 | */ |
1012 | mutex_lock(&ubi_devices_mutex); | 1012 | mutex_lock(&ubi_devices_mutex); |
1013 | err = ubi_attach_mtd_dev(mtd, req.ubi_num, req.vid_hdr_offset); | 1013 | err = ubi_attach_mtd_dev(mtd, req.ubi_num, req.vid_hdr_offset, |
1014 | CONFIG_MTD_UBI_BEB_LIMIT); | ||
1014 | mutex_unlock(&ubi_devices_mutex); | 1015 | mutex_unlock(&ubi_devices_mutex); |
1015 | if (err < 0) | 1016 | if (err < 0) |
1016 | put_mtd_device(mtd); | 1017 | put_mtd_device(mtd); |
diff --git a/drivers/mtd/ubi/ubi.h b/drivers/mtd/ubi/ubi.h index c94612e67c47..2a2475b9ec54 100644 --- a/drivers/mtd/ubi/ubi.h +++ b/drivers/mtd/ubi/ubi.h | |||
@@ -693,7 +693,8 @@ int ubi_io_write_vid_hdr(struct ubi_device *ubi, int pnum, | |||
693 | struct ubi_vid_hdr *vid_hdr); | 693 | struct ubi_vid_hdr *vid_hdr); |
694 | 694 | ||
695 | /* build.c */ | 695 | /* build.c */ |
696 | int ubi_attach_mtd_dev(struct mtd_info *mtd, int ubi_num, int vid_hdr_offset); | 696 | int ubi_attach_mtd_dev(struct mtd_info *mtd, int ubi_num, |
697 | int vid_hdr_offset, int max_beb_per1024); | ||
697 | int ubi_detach_mtd_dev(int ubi_num, int anyway); | 698 | int ubi_detach_mtd_dev(int ubi_num, int anyway); |
698 | struct ubi_device *ubi_get_device(int ubi_num); | 699 | struct ubi_device *ubi_get_device(int ubi_num); |
699 | void ubi_put_device(struct ubi_device *ubi); | 700 | void ubi_put_device(struct ubi_device *ubi); |