Commit 256334c3 authored by Richard Genoud's avatar Richard Genoud Committed by Artem Bityutskiy

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: default avatarRichard Genoud <richard.genoud@gmail.com>
Reviewed-by: default avatarShmulik Ladkani <shmulik.ladkani@gmail.com>
Signed-off-by: default avatarArtem Bityutskiy <artem.bityutskiy@linux.intel.com>
parent 5993f9b7
...@@ -599,6 +599,7 @@ static int get_bad_peb_limit(const struct ubi_device *ubi, int max_beb_per1024) ...@@ -599,6 +599,7 @@ static int get_bad_peb_limit(const struct ubi_device *ubi, int max_beb_per1024)
/** /**
* io_init - initialize I/O sub-system for a given UBI device. * io_init - initialize I/O sub-system for a given UBI device.
* @ubi: UBI device description object * @ubi: UBI device description object
* @max_beb_per1024: maximum expected number of bad PEB per 1024 PEBs
* *
* If @ubi->vid_hdr_offset or @ubi->leb_start is zero, default offsets are * If @ubi->vid_hdr_offset or @ubi->leb_start is zero, default offsets are
* assumed: * assumed:
...@@ -611,10 +612,8 @@ static int get_bad_peb_limit(const struct ubi_device *ubi, int max_beb_per1024) ...@@ -611,10 +612,8 @@ static int get_bad_peb_limit(const struct ubi_device *ubi, int max_beb_per1024)
* This function returns zero in case of success and a negative error code in * This function returns zero in case of success and a negative error code in
* case of failure. * case of failure.
*/ */
static int io_init(struct ubi_device *ubi) static int io_init(struct ubi_device *ubi, int max_beb_per1024)
{ {
const int max_beb_per1024 = CONFIG_MTD_UBI_BEB_LIMIT;
if (ubi->mtd->numeraseregions != 0) { if (ubi->mtd->numeraseregions != 0) {
/* /*
* Some flashes have several erase regions. Different regions * Some flashes have several erase regions. Different regions
...@@ -836,6 +835,7 @@ static int autoresize(struct ubi_device *ubi, int vol_id) ...@@ -836,6 +835,7 @@ static int autoresize(struct ubi_device *ubi, int vol_id)
* @mtd: MTD device description object * @mtd: MTD device description object
* @ubi_num: number to assign to the new UBI device * @ubi_num: number to assign to the new UBI device
* @vid_hdr_offset: VID header offset * @vid_hdr_offset: VID header offset
* @max_beb_per1024: maximum number of expected bad blocks per 1024 PEBs
* *
* This function attaches MTD device @mtd_dev to UBI and assign @ubi_num number * This function attaches MTD device @mtd_dev to UBI and assign @ubi_num number
* to the newly created UBI device, unless @ubi_num is %UBI_DEV_NUM_AUTO, in * 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,7 +846,8 @@ static int autoresize(struct ubi_device *ubi, int vol_id)
* Note, the invocations of this function has to be serialized by the * Note, the invocations of this function has to be serialized by the
* @ubi_devices_mutex. * @ubi_devices_mutex.
*/ */
int ubi_attach_mtd_dev(struct mtd_info *mtd, int ubi_num, int vid_hdr_offset) int ubi_attach_mtd_dev(struct mtd_info *mtd, int ubi_num,
int vid_hdr_offset, int max_beb_per1024)
{ {
struct ubi_device *ubi; struct ubi_device *ubi;
int i, err, ref = 0; 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,7 +920,7 @@ int ubi_attach_mtd_dev(struct mtd_info *mtd, int ubi_num, int vid_hdr_offset)
dbg_msg("sizeof(struct ubi_ainf_peb) %zu", sizeof(struct ubi_ainf_peb)); dbg_msg("sizeof(struct ubi_ainf_peb) %zu", sizeof(struct ubi_ainf_peb));
dbg_msg("sizeof(struct ubi_wl_entry) %zu", sizeof(struct ubi_wl_entry)); dbg_msg("sizeof(struct ubi_wl_entry) %zu", sizeof(struct ubi_wl_entry));
err = io_init(ubi); err = io_init(ubi, max_beb_per1024);
if (err) if (err)
goto out_free; goto out_free;
...@@ -1208,7 +1209,8 @@ static int __init ubi_init(void) ...@@ -1208,7 +1209,8 @@ static int __init ubi_init(void)
mutex_lock(&ubi_devices_mutex); mutex_lock(&ubi_devices_mutex);
err = ubi_attach_mtd_dev(mtd, UBI_DEV_NUM_AUTO, err = ubi_attach_mtd_dev(mtd, UBI_DEV_NUM_AUTO,
p->vid_hdr_offs); p->vid_hdr_offs,
CONFIG_MTD_UBI_BEB_LIMIT);
mutex_unlock(&ubi_devices_mutex); mutex_unlock(&ubi_devices_mutex);
if (err < 0) { if (err < 0) {
ubi_err("cannot attach mtd%d", mtd->index); ubi_err("cannot attach mtd%d", mtd->index);
......
...@@ -1010,7 +1010,8 @@ static long ctrl_cdev_ioctl(struct file *file, unsigned int cmd, ...@@ -1010,7 +1010,8 @@ static long ctrl_cdev_ioctl(struct file *file, unsigned int cmd,
* 'ubi_attach_mtd_dev()'. * 'ubi_attach_mtd_dev()'.
*/ */
mutex_lock(&ubi_devices_mutex); mutex_lock(&ubi_devices_mutex);
err = ubi_attach_mtd_dev(mtd, req.ubi_num, req.vid_hdr_offset); err = ubi_attach_mtd_dev(mtd, req.ubi_num, req.vid_hdr_offset,
CONFIG_MTD_UBI_BEB_LIMIT);
mutex_unlock(&ubi_devices_mutex); mutex_unlock(&ubi_devices_mutex);
if (err < 0) if (err < 0)
put_mtd_device(mtd); put_mtd_device(mtd);
......
...@@ -693,7 +693,8 @@ int ubi_io_write_vid_hdr(struct ubi_device *ubi, int pnum, ...@@ -693,7 +693,8 @@ int ubi_io_write_vid_hdr(struct ubi_device *ubi, int pnum,
struct ubi_vid_hdr *vid_hdr); struct ubi_vid_hdr *vid_hdr);
/* build.c */ /* build.c */
int ubi_attach_mtd_dev(struct mtd_info *mtd, int ubi_num, int vid_hdr_offset); int ubi_attach_mtd_dev(struct mtd_info *mtd, int ubi_num,
int vid_hdr_offset, int max_beb_per1024);
int ubi_detach_mtd_dev(int ubi_num, int anyway); int ubi_detach_mtd_dev(int ubi_num, int anyway);
struct ubi_device *ubi_get_device(int ubi_num); struct ubi_device *ubi_get_device(int ubi_num);
void ubi_put_device(struct ubi_device *ubi); void ubi_put_device(struct ubi_device *ubi);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment