diff mbox

UBI: block: Configurable device major number

Message ID 1421268043-7476-1-git-send-email-dehrenberg@chromium.org
State Rejected
Headers show

Commit Message

Dan Ehrenberg Jan. 14, 2015, 8:40 p.m. UTC
By default UBI block devices use a dynamic major number. This
config option can replace that with a static major number. Set
to the new major number, or 0 for dynamic. This is useful if
you want to use an ubiblock as the root filesystem in an
indirect way, e.g., though DM and need to refer to it before
userspace is up.

Signed-off-by: Dan Ehrenberg <dehrenberg@chromium.org>
---
 drivers/mtd/ubi/Kconfig | 13 +++++++++++++
 drivers/mtd/ubi/block.c |  7 ++++++-
 2 files changed, 19 insertions(+), 1 deletion(-)

Comments

Dan Ehrenberg Jan. 15, 2015, 6:52 p.m. UTC | #1
Hi,

Please ignore this patch. I've found a better way to achieve the same
thing--modify dm to accept paths like /dev/ubiblock3_0 (parsed the
same as root=) as arguments for the target, rather than only paths in
the filesystem and major:minor pairs.

Thanks,
Dan

On Wed, Jan 14, 2015 at 12:40 PM, Dan Ehrenberg <dehrenberg@chromium.org> wrote:
> By default UBI block devices use a dynamic major number. This
> config option can replace that with a static major number. Set
> to the new major number, or 0 for dynamic. This is useful if
> you want to use an ubiblock as the root filesystem in an
> indirect way, e.g., though DM and need to refer to it before
> userspace is up.
>
> Signed-off-by: Dan Ehrenberg <dehrenberg@chromium.org>
> ---
>  drivers/mtd/ubi/Kconfig | 13 +++++++++++++
>  drivers/mtd/ubi/block.c |  7 ++++++-
>  2 files changed, 19 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/mtd/ubi/Kconfig b/drivers/mtd/ubi/Kconfig
> index f0855ce..5ac8d63 100644
> --- a/drivers/mtd/ubi/Kconfig
> +++ b/drivers/mtd/ubi/Kconfig
> @@ -103,4 +103,17 @@ config MTD_UBI_BLOCK
>
>            If in doubt, say "N".
>
> +config MTD_UBI_BLOCK_MAJOR
> +       int "Major device number for UBI block devices"
> +       default 0
> +       range 0 256
> +       depends on MTD_UBI_BLOCK
> +       help
> +          By default UBI block devices use a dynamic major number. This
> +          config option can replace that with a static major number. Set
> +          to the new major number, or 0 for dynamic. This is useful if
> +          you want to use an ubiblock as the root filesystem in an
> +          indirect way, e.g., though DM and need to refer to it before
> +          userspace is up.
> +
>  endif # MTD_UBI
> diff --git a/drivers/mtd/ubi/block.c b/drivers/mtd/ubi/block.c
> index 6b6bce2..6c8333d 100644
> --- a/drivers/mtd/ubi/block.c
> +++ b/drivers/mtd/ubi/block.c
> @@ -635,9 +635,14 @@ int __init ubiblock_init(void)
>  {
>         int ret;
>
> -       ubiblock_major = register_blkdev(0, "ubiblock");
> +       ubiblock_major = register_blkdev(CONFIG_MTD_UBI_BLOCK_MAJOR,
> +                                        "ubiblock");
>         if (ubiblock_major < 0)
>                 return ubiblock_major;
> +       if (CONFIG_MTD_UBI_BLOCK_MAJOR) {
> +               BUG_ON(ubiblock_major);
> +               ubiblock_major = CONFIG_MTD_UBI_BLOCK_MAJOR;
> +       }
>
>         /* Attach block devices from 'block=' module param */
>         ret = ubiblock_create_from_param();
> --
> 2.2.0.rc0.207.ga3a616c
>
diff mbox

Patch

diff --git a/drivers/mtd/ubi/Kconfig b/drivers/mtd/ubi/Kconfig
index f0855ce..5ac8d63 100644
--- a/drivers/mtd/ubi/Kconfig
+++ b/drivers/mtd/ubi/Kconfig
@@ -103,4 +103,17 @@  config MTD_UBI_BLOCK
 
 	   If in doubt, say "N".
 
+config MTD_UBI_BLOCK_MAJOR
+	int "Major device number for UBI block devices"
+	default 0
+	range 0 256
+	depends on MTD_UBI_BLOCK
+	help
+	   By default UBI block devices use a dynamic major number. This
+	   config option can replace that with a static major number. Set
+	   to the new major number, or 0 for dynamic. This is useful if
+	   you want to use an ubiblock as the root filesystem in an
+	   indirect way, e.g., though DM and need to refer to it before
+	   userspace is up.
+
 endif # MTD_UBI
diff --git a/drivers/mtd/ubi/block.c b/drivers/mtd/ubi/block.c
index 6b6bce2..6c8333d 100644
--- a/drivers/mtd/ubi/block.c
+++ b/drivers/mtd/ubi/block.c
@@ -635,9 +635,14 @@  int __init ubiblock_init(void)
 {
 	int ret;
 
-	ubiblock_major = register_blkdev(0, "ubiblock");
+	ubiblock_major = register_blkdev(CONFIG_MTD_UBI_BLOCK_MAJOR,
+					 "ubiblock");
 	if (ubiblock_major < 0)
 		return ubiblock_major;
+	if (CONFIG_MTD_UBI_BLOCK_MAJOR) {
+		BUG_ON(ubiblock_major);
+		ubiblock_major = CONFIG_MTD_UBI_BLOCK_MAJOR;
+	}
 
 	/* Attach block devices from 'block=' module param */
 	ret = ubiblock_create_from_param();