All of lore.kernel.org
 help / color / mirror / Atom feed
From: Richard Genoud <richard.genoud@gmail.com>
To: Artem Bityutskiy <dedekind1@gmail.com>
Cc: Richard Genoud <richard.genoud@gmail.com>,
	linux-mtd@lists.infradead.org,
	Shmulik Ladkani <shmulik.ladkani@gmail.com>
Subject: [PATCH v3 1/6] UBI: prepare for max_beb_per1024 module parameter addition
Date: Mon, 20 Aug 2012 18:00:11 +0200	[thread overview]
Message-ID: <1345478416-23900-2-git-send-email-richard.genoud@gmail.com> (raw)
In-Reply-To: <1345478416-23900-1-git-send-email-richard.genoud@gmail.com>

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>
---
 drivers/mtd/ubi/build.c |   14 ++++++++------
 drivers/mtd/ubi/cdev.c  |    3 ++-
 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 4385aaa..3c0b91f 100644
--- a/drivers/mtd/ubi/build.c
+++ b/drivers/mtd/ubi/build.c
@@ -602,6 +602,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.
  * @ubi: UBI device description object
+ * @max_beb_per1024: maximum expected number of bad PEB per 1024 PEB
  *
  * If @ubi->vid_hdr_offset or @ubi->leb_start is zero, default offsets are
  * assumed:
@@ -614,10 +615,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
  * 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) {
 		/*
 		 * Some flashes have several erase regions. Different regions
@@ -839,6 +838,7 @@ static int autoresize(struct ubi_device *ubi, int vol_id)
  * @mtd: MTD device description object
  * @ubi_num: number to assign to the new UBI device
  * @vid_hdr_offset: VID header offset
+ * @max_beb_per1024: maximum number of expected bad blocks per 1024 eraseblocks
  *
  * 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
@@ -849,7 +849,8 @@ static int autoresize(struct ubi_device *ubi, int vol_id)
  * Note, the invocations of this function has to be serialized by the
  * @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;
 	int i, err, ref = 0;
@@ -922,7 +923,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_wl_entry) %zu", sizeof(struct ubi_wl_entry));
 
-	err = io_init(ubi);
+	err = io_init(ubi, max_beb_per1024);
 	if (err)
 		goto out_free;
 
@@ -1211,7 +1212,8 @@ static int __init ubi_init(void)
 
 		mutex_lock(&ubi_devices_mutex);
 		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);
 		if (err < 0) {
 			ubi_err("cannot attach mtd%d", mtd->index);
diff --git a/drivers/mtd/ubi/cdev.c b/drivers/mtd/ubi/cdev.c
index fb55678..619f914 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,
 		 * 'ubi_attach_mtd_dev()'.
 		 */
 		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);
 		if (err < 0)
 			put_mtd_device(mtd);
diff --git a/drivers/mtd/ubi/ubi.h b/drivers/mtd/ubi/ubi.h
index c94612e..2a2475b 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,
 			 struct ubi_vid_hdr *vid_hdr);
 
 /* 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);
 struct ubi_device *ubi_get_device(int ubi_num);
 void ubi_put_device(struct ubi_device *ubi);
-- 
1.7.2.5

  reply	other threads:[~2012-08-20 16:00 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-08-20 16:00 [PATCH v3 0/6] UBI: add max_beb_per1024 parameter / ioctl Richard Genoud
2012-08-20 16:00 ` Richard Genoud [this message]
2012-08-20 19:01   ` [PATCH v3 1/6] UBI: prepare for max_beb_per1024 module parameter addition Artem Bityutskiy
2012-08-20 16:00 ` [PATCH v3 2/6] UBI: change CONFIG_MTD_UBI_BEB_LIMIT range Richard Genoud
2012-08-20 19:03   ` Artem Bityutskiy
2012-08-20 16:00 ` [PATCH v3 3/6] UBI: check max_beb_per1024 value in ubi_attach_mtd_dev Richard Genoud
2012-08-20 19:19   ` Artem Bityutskiy
2012-08-20 16:00 ` [PATCH v3 4/6] UBI: replace MTD_UBI_BEB_LIMIT with module parameter Richard Genoud
2012-08-21 13:54   ` Artem Bityutskiy
2012-08-22  8:32     ` Richard Genoud
2012-08-22  8:49       ` Artem Bityutskiy
2012-08-22 12:09         ` Richard Genoud
2012-08-22 12:16           ` Artem Bityutskiy
2012-08-20 16:00 ` [PATCH v3 5/6] UBI: add ioctl for max_beb_per1024 Richard Genoud
2012-08-21 19:34   ` Artem Bityutskiy
2012-08-20 16:00 ` [PATCH v3 6/6] UBI: drop CONFIG_MTD_UBI_BEB_LIMIT Richard Genoud
2012-08-21 19:34   ` Artem Bityutskiy
2012-08-23 10:10 ` [PATCH v3 0/6] UBI: add max_beb_per1024 parameter / ioctl Artem Bityutskiy
2012-08-23 10:36   ` Shmulik Ladkani
2012-08-23 11:01     ` Richard Genoud
2012-08-23 12:30     ` Artem Bityutskiy
2012-08-23 12:44       ` Shmulik Ladkani
2012-08-23 12:58         ` Artem Bityutskiy
2012-08-23 13:13           ` Richard Genoud
2012-08-23 14:45             ` Artem Bityutskiy
2012-08-31 14:46             ` Richard Genoud
2012-09-03  8:00               ` Artem Bityutskiy
2012-09-03 10:57                 ` Richard Genoud
2012-09-03 11:53                   ` Artem Bityutskiy
2012-09-03 13:14                     ` Richard Genoud
2012-09-03 13:31                       ` Artem Bityutskiy
2012-09-03 13:37                         ` Richard Genoud
2012-09-03 14:32               ` Artem Bityutskiy
2012-09-03 14:33               ` Artem Bityutskiy
2012-09-03 14:45                 ` Richard Genoud

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1345478416-23900-2-git-send-email-richard.genoud@gmail.com \
    --to=richard.genoud@gmail.com \
    --cc=dedekind1@gmail.com \
    --cc=linux-mtd@lists.infradead.org \
    --cc=shmulik.ladkani@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.