diff mbox

[v3,0/6] UBI: add max_beb_per1024 parameter / ioctl

Message ID 1345716615.2848.229.camel@sauron.fi.intel.com
State New, archived
Headers show

Commit Message

Artem Bityutskiy Aug. 23, 2012, 10:10 a.m. UTC
On Mon, 2012-08-20 at 18:00 +0200, Richard Genoud wrote:
> This patch serie introduce, step by step the kernel module parameter
> max_beb_per1024, then the ioctl and finally drop the kernel config option
> CONFIG_MTD_UBI_BEB_LIMIT.
> 
> It's based on top of linux-ubi/master (4ebb4b5)

I've also pushed this patch:

From 5fe236c703063f9bc87b66c593408a0d48bbe0e7 Mon Sep 17 00:00:00 2001
From: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Date: Thu, 23 Aug 2012 13:01:11 +0300
Subject: [PATCH] UBI: disallow max_beb_per1024 on NOR flash

If the flash does not admit of bad blocks (e.g., NOR) - disallow using
'max_beb_per1024'.

Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
---
 drivers/mtd/ubi/build.c |   12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

Comments

Shmulik Ladkani Aug. 23, 2012, 10:36 a.m. UTC | #1
On Thu, 23 Aug 2012 13:10:15 +0300 Artem Bityutskiy <dedekind1@gmail.com> wrote:
> diff --git a/drivers/mtd/ubi/build.c b/drivers/mtd/ubi/build.c
> index aa60b30..865e4fa 100644
> --- a/drivers/mtd/ubi/build.c
> +++ b/drivers/mtd/ubi/build.c
> @@ -860,9 +860,6 @@ int ubi_attach_mtd_dev(struct mtd_info *mtd, int ubi_num,
>  	if (max_beb_per1024 < 0 || max_beb_per1024 > MAX_MTD_UBI_BEB_LIMIT)
>  		return -EINVAL;
>  
> -	if (!max_beb_per1024)
> -		max_beb_per1024 = CONFIG_MTD_UBI_BEB_LIMIT;
> -
>  	/*
>  	 * Check if we already have the same MTD device attached.
>  	 *
> @@ -935,6 +932,15 @@ int ubi_attach_mtd_dev(struct mtd_info *mtd, int ubi_num,
>  	if (err)
>  		goto out_free;
>  
> +	if (!max_beb_per1024) {
> +		if (!ubi->bad_allowed) {
> +			ubi_err("mtd%d does not admit of bad blocks, "
> +				"max_beb_per1024 cannot be used", mtd->index);
> +			goto out_free;
> +		}
> +		max_beb_per1024 = CONFIG_MTD_UBI_BEB_LIMIT;
> +	}
> +

Artem, this is now located *after* the call to
	io_init(ubi, max_beb_per1024)
So falling to the default (in case max_beb_per1024 is zero) won't work.

Also, why displaying the error if max_beb_per1024 was NOT povided?
Shouldn't it be displayed only when max_beb_per1024 is other than zero?
What am I missing?

Regards,
Shmulik
Richard Genoud Aug. 23, 2012, 11:01 a.m. UTC | #2
2012/8/23 Shmulik Ladkani <shmulik.ladkani@gmail.com>:
> Artem, this is now located *after* the call to
>         io_init(ubi, max_beb_per1024)
> So falling to the default (in case max_beb_per1024 is zero) won't work.
>
> Also, why displaying the error if max_beb_per1024 was NOT povided?
> Shouldn't it be displayed only when max_beb_per1024 is other than zero?
> What am I missing?
+1
mounting NOR flash without the max_beb_per1024 will fail, that's
really not what we want.

Regards,
Richard.
diff mbox

Patch

diff --git a/drivers/mtd/ubi/build.c b/drivers/mtd/ubi/build.c
index aa60b30..865e4fa 100644
--- a/drivers/mtd/ubi/build.c
+++ b/drivers/mtd/ubi/build.c
@@ -860,9 +860,6 @@  int ubi_attach_mtd_dev(struct mtd_info *mtd, int ubi_num,
 	if (max_beb_per1024 < 0 || max_beb_per1024 > MAX_MTD_UBI_BEB_LIMIT)
 		return -EINVAL;
 
-	if (!max_beb_per1024)
-		max_beb_per1024 = CONFIG_MTD_UBI_BEB_LIMIT;
-
 	/*
 	 * Check if we already have the same MTD device attached.
 	 *
@@ -935,6 +932,15 @@  int ubi_attach_mtd_dev(struct mtd_info *mtd, int ubi_num,
 	if (err)
 		goto out_free;
 
+	if (!max_beb_per1024) {
+		if (!ubi->bad_allowed) {
+			ubi_err("mtd%d does not admit of bad blocks, "
+				"max_beb_per1024 cannot be used", mtd->index);
+			goto out_free;
+		}
+		max_beb_per1024 = CONFIG_MTD_UBI_BEB_LIMIT;
+	}
+
 	err = -ENOMEM;
 	ubi->peb_buf = vmalloc(ubi->peb_size);
 	if (!ubi->peb_buf)