All of lore.kernel.org
 help / color / mirror / Atom feed
From: Daniel Golle <daniel@makrotopia.org>
To: Hauke Mehrtens <hauke@hauke-m.de>
Cc: richard@nod.at, dwmw2@infradead.org, mark.rutland@arm.com,
	devicetree@vger.kernel.org, dedekind1@gmail.com,
	robh+dt@kernel.org, linux-mtd@lists.infradead.org,
	computersforpeace@gmail.com
Subject: Re: [PATCH 2/2] ubi: open volumes define in device tree
Date: Sun, 19 Jun 2016 01:36:54 +0200	[thread overview]
Message-ID: <20160618233654.GC29476@makrotopia.org> (raw)
In-Reply-To: <1466277476-14853-2-git-send-email-hauke@hauke-m.de>

On Sat, Jun 18, 2016 at 09:17:56PM +0200, Hauke Mehrtens wrote:
> This makes it possible to define a volume to open in device tree. This
> is helpful when a root file system is on a ubi layer. Without this
> patch it is only possible to device with with kernel command line
> parameters.
> 
> Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>

The example in the documentation doesn't belong to that patch, see
below. Apart from this single [PATCH 2/2]:
Acked-by: Daniel Golle <daniel@makrotopia.org>

> ---
>  Documentation/devicetree/bindings/mtd/ubi.txt | 22 +++++++++++++++++
>  drivers/mtd/ubi/build.c                       | 34 +++++++++++++++++++++++++++
>  2 files changed, 56 insertions(+)
> 
> diff --git a/Documentation/devicetree/bindings/mtd/ubi.txt b/Documentation/devicetree/bindings/mtd/ubi.txt
> index 5fcd47e..f87a7d8 100644
> --- a/Documentation/devicetree/bindings/mtd/ubi.txt
> +++ b/Documentation/devicetree/bindings/mtd/ubi.txt
> @@ -13,6 +13,16 @@ Describe of a UBI layer in device tree.
>   			which have to be assigned to the newly created UBI
>   			device (assigned automatically by default)
>  
> +Partitions on a UBI layer can be defined:
> +
> + - compatible: 		"ubi,volume"
> + - name:		name of the ubi volume to open
> + - ubi-mode:		mode of the ubi volume to open value:
> + 			UBI_READONLY:	1
> + 			UBI_READWRITE:	2
> + 			UBI_EXCLUSIVE:	3
> + 			UBI_METAONLY:	4
> +
>  Example:
>  
>  partitions {
> @@ -29,5 +39,17 @@ partitions {
>  		label = "system_sw";
>  		reg = <0x1c0000 0xc800000>;
>  		compatible = "ubi,device";
> +
> +		rootfsA@0 {
> +			compatible = "ubi,volume";
> +			name = "rootfsA";
> +			ubi-mode = <1>;
> +		};
> +
> +		data_vol@0 {
> +			compatible = "ubi,volume";
> +			name = "data_vol";
> +			ubi-mode = <2>;
> +		};

This is an example for the 'ubi,volume' while the patch introduces
support for 'ubi,device'.


>  	};
>  };
> diff --git a/drivers/mtd/ubi/build.c b/drivers/mtd/ubi/build.c
> index 16baeb5..1c22533 100644
> --- a/drivers/mtd/ubi/build.c
> +++ b/drivers/mtd/ubi/build.c
> @@ -1,6 +1,7 @@
>  /*
>   * Copyright (c) International Business Machines Corp., 2006
>   * Copyright (c) Nokia Corporation, 2007
> + * Copyright (c) 2016 Hauke Mehrtens <hauke@hauke-m.de>
>   *
>   * This program is free software; you can redistribute it and/or modify
>   * it under the terms of the GNU General Public License as published by
> @@ -33,6 +34,7 @@
>  #include <linux/module.h>
>  #include <linux/moduleparam.h>
>  #include <linux/stringify.h>
> +#include <linux/of.h>
>  #include <linux/namei.h>
>  #include <linux/stat.h>
>  #include <linux/miscdevice.h>
> @@ -43,6 +45,7 @@
>  #include <linux/slab.h>
>  #include <linux/major.h>
>  #include "ubi.h"
> +#include "../mtdcore.h"
>  
>  /* Maximum length of the 'mtd=' parameter */
>  #define MTD_PARAM_LEN_MAX 64
> @@ -1205,6 +1208,7 @@ static struct mtd_info * __init open_mtd_device(const char *mtd_dev)
>  static int __init ubi_init(void)
>  {
>  	int err, i, k;
> +	struct mtd_info *mtd_it;
>  
>  	/* Ensure that EC and VID headers have correct size */
>  	BUILD_BUG_ON(sizeof(struct ubi_ec_hdr) != 64);
> @@ -1285,6 +1289,36 @@ static int __init ubi_init(void)
>  		}
>  	}
>  
> +	mtd_for_each_device(mtd_it) {
> +		struct mtd_info *mtd;
> +		u32 ubi_num = 0;
> +		u32 vid_hdr_offs = 0;
> +		u32 max_beb_per1024 = CONFIG_MTD_UBI_BEB_LIMIT;
> +
> +		mtd = get_mtd_device(mtd_it, -1);
> +
> +		if (!of_device_is_compatible(mtd->dev.of_node, "ubi,device")) {
> +			put_mtd_device(mtd);
> +			continue;
> +		}
> +
> +		of_property_read_u32(mtd->dev.of_node, "vid_hdr_offs",
> +				     &vid_hdr_offs);
> +		of_property_read_u32(mtd->dev.of_node, "max_beb_per1024",
> +				     &max_beb_per1024);
> +		of_property_read_u32(mtd->dev.of_node, "ubi_num", &ubi_num);
> +
> +		mutex_lock(&ubi_devices_mutex);
> +		err = ubi_attach_mtd_dev(mtd, ubi_num, vid_hdr_offs,
> +					 max_beb_per1024);
> +		mutex_unlock(&ubi_devices_mutex);
> +		if (err < 0) {
> +			pr_err("UBI error: cannot attach mtd%d",
> +			       mtd->index);
> +		}
> +		put_mtd_device(mtd);
> +	}
> +
>  	err = ubiblock_init();
>  	if (err) {
>  		pr_err("UBI error: block: cannot initialize, error %d", err);
> -- 
> 2.8.1
> 
> 
> ______________________________________________________
> Linux MTD discussion mailing list
> http://lists.infradead.org/mailman/listinfo/linux-mtd/

WARNING: multiple messages have this Message-ID (diff)
From: Daniel Golle <daniel-g5gK2j5usbvCyp4qypjU+w@public.gmane.org>
To: Hauke Mehrtens <hauke-5/S+JYg5SzeELgA04lAiVw@public.gmane.org>
Cc: richard-/L3Ra7n9ekc@public.gmane.org,
	dwmw2-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org,
	mark.rutland-5wv7dgnIgG8@public.gmane.org,
	devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	dedekind1-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org,
	robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org,
	linux-mtd-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org,
	computersforpeace-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
Subject: Re: [PATCH 2/2] ubi: open volumes define in device tree
Date: Sun, 19 Jun 2016 01:36:54 +0200	[thread overview]
Message-ID: <20160618233654.GC29476@makrotopia.org> (raw)
In-Reply-To: <1466277476-14853-2-git-send-email-hauke-5/S+JYg5SzeELgA04lAiVw@public.gmane.org>

On Sat, Jun 18, 2016 at 09:17:56PM +0200, Hauke Mehrtens wrote:
> This makes it possible to define a volume to open in device tree. This
> is helpful when a root file system is on a ubi layer. Without this
> patch it is only possible to device with with kernel command line
> parameters.
> 
> Signed-off-by: Hauke Mehrtens <hauke-5/S+JYg5SzeELgA04lAiVw@public.gmane.org>

The example in the documentation doesn't belong to that patch, see
below. Apart from this single [PATCH 2/2]:
Acked-by: Daniel Golle <daniel-g5gK2j5usbvCyp4qypjU+w@public.gmane.org>

> ---
>  Documentation/devicetree/bindings/mtd/ubi.txt | 22 +++++++++++++++++
>  drivers/mtd/ubi/build.c                       | 34 +++++++++++++++++++++++++++
>  2 files changed, 56 insertions(+)
> 
> diff --git a/Documentation/devicetree/bindings/mtd/ubi.txt b/Documentation/devicetree/bindings/mtd/ubi.txt
> index 5fcd47e..f87a7d8 100644
> --- a/Documentation/devicetree/bindings/mtd/ubi.txt
> +++ b/Documentation/devicetree/bindings/mtd/ubi.txt
> @@ -13,6 +13,16 @@ Describe of a UBI layer in device tree.
>   			which have to be assigned to the newly created UBI
>   			device (assigned automatically by default)
>  
> +Partitions on a UBI layer can be defined:
> +
> + - compatible: 		"ubi,volume"
> + - name:		name of the ubi volume to open
> + - ubi-mode:		mode of the ubi volume to open value:
> + 			UBI_READONLY:	1
> + 			UBI_READWRITE:	2
> + 			UBI_EXCLUSIVE:	3
> + 			UBI_METAONLY:	4
> +
>  Example:
>  
>  partitions {
> @@ -29,5 +39,17 @@ partitions {
>  		label = "system_sw";
>  		reg = <0x1c0000 0xc800000>;
>  		compatible = "ubi,device";
> +
> +		rootfsA@0 {
> +			compatible = "ubi,volume";
> +			name = "rootfsA";
> +			ubi-mode = <1>;
> +		};
> +
> +		data_vol@0 {
> +			compatible = "ubi,volume";
> +			name = "data_vol";
> +			ubi-mode = <2>;
> +		};

This is an example for the 'ubi,volume' while the patch introduces
support for 'ubi,device'.


>  	};
>  };
> diff --git a/drivers/mtd/ubi/build.c b/drivers/mtd/ubi/build.c
> index 16baeb5..1c22533 100644
> --- a/drivers/mtd/ubi/build.c
> +++ b/drivers/mtd/ubi/build.c
> @@ -1,6 +1,7 @@
>  /*
>   * Copyright (c) International Business Machines Corp., 2006
>   * Copyright (c) Nokia Corporation, 2007
> + * Copyright (c) 2016 Hauke Mehrtens <hauke-5/S+JYg5SzeELgA04lAiVw@public.gmane.org>
>   *
>   * This program is free software; you can redistribute it and/or modify
>   * it under the terms of the GNU General Public License as published by
> @@ -33,6 +34,7 @@
>  #include <linux/module.h>
>  #include <linux/moduleparam.h>
>  #include <linux/stringify.h>
> +#include <linux/of.h>
>  #include <linux/namei.h>
>  #include <linux/stat.h>
>  #include <linux/miscdevice.h>
> @@ -43,6 +45,7 @@
>  #include <linux/slab.h>
>  #include <linux/major.h>
>  #include "ubi.h"
> +#include "../mtdcore.h"
>  
>  /* Maximum length of the 'mtd=' parameter */
>  #define MTD_PARAM_LEN_MAX 64
> @@ -1205,6 +1208,7 @@ static struct mtd_info * __init open_mtd_device(const char *mtd_dev)
>  static int __init ubi_init(void)
>  {
>  	int err, i, k;
> +	struct mtd_info *mtd_it;
>  
>  	/* Ensure that EC and VID headers have correct size */
>  	BUILD_BUG_ON(sizeof(struct ubi_ec_hdr) != 64);
> @@ -1285,6 +1289,36 @@ static int __init ubi_init(void)
>  		}
>  	}
>  
> +	mtd_for_each_device(mtd_it) {
> +		struct mtd_info *mtd;
> +		u32 ubi_num = 0;
> +		u32 vid_hdr_offs = 0;
> +		u32 max_beb_per1024 = CONFIG_MTD_UBI_BEB_LIMIT;
> +
> +		mtd = get_mtd_device(mtd_it, -1);
> +
> +		if (!of_device_is_compatible(mtd->dev.of_node, "ubi,device")) {
> +			put_mtd_device(mtd);
> +			continue;
> +		}
> +
> +		of_property_read_u32(mtd->dev.of_node, "vid_hdr_offs",
> +				     &vid_hdr_offs);
> +		of_property_read_u32(mtd->dev.of_node, "max_beb_per1024",
> +				     &max_beb_per1024);
> +		of_property_read_u32(mtd->dev.of_node, "ubi_num", &ubi_num);
> +
> +		mutex_lock(&ubi_devices_mutex);
> +		err = ubi_attach_mtd_dev(mtd, ubi_num, vid_hdr_offs,
> +					 max_beb_per1024);
> +		mutex_unlock(&ubi_devices_mutex);
> +		if (err < 0) {
> +			pr_err("UBI error: cannot attach mtd%d",
> +			       mtd->index);
> +		}
> +		put_mtd_device(mtd);
> +	}
> +
>  	err = ubiblock_init();
>  	if (err) {
>  		pr_err("UBI error: block: cannot initialize, error %d", err);
> -- 
> 2.8.1
> 
> 
> ______________________________________________________
> Linux MTD discussion mailing list
> http://lists.infradead.org/mailman/listinfo/linux-mtd/
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

  reply	other threads:[~2016-06-18 23:37 UTC|newest]

Thread overview: 88+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-18 19:17 [PATCH 1/2] ubi: mount partitions specified in device tree Hauke Mehrtens
2016-06-18 19:17 ` Hauke Mehrtens
2016-06-18 19:17 ` [PATCH 2/2] ubi: open volumes define " Hauke Mehrtens
2016-06-18 19:17   ` Hauke Mehrtens
2016-06-18 23:36   ` Daniel Golle [this message]
2016-06-18 23:36     ` Daniel Golle
2016-06-19 21:21     ` Hauke Mehrtens
2016-06-19 21:21       ` Hauke Mehrtens
2016-06-24 18:45   ` Ezequiel Garcia
2016-06-24 18:45     ` Ezequiel Garcia
2016-06-25 20:24     ` Hauke Mehrtens
2016-06-25 20:24       ` Hauke Mehrtens
2016-06-18 19:30 ` [PATCH 1/2] ubi: mount partitions specified " Richard Weinberger
2016-06-18 19:30   ` Richard Weinberger
2016-06-18 19:35   ` Hauke Mehrtens
2016-06-18 19:35     ` Hauke Mehrtens
2016-06-18 19:46     ` Richard Weinberger
2016-06-18 19:46       ` Richard Weinberger
2016-06-18 22:54       ` Hauke Mehrtens
2016-06-18 22:54         ` Hauke Mehrtens
2016-06-19  8:41         ` Richard Weinberger
2016-06-19  8:41           ` Richard Weinberger
2016-06-18 23:20     ` Daniel Golle
2016-06-18 23:20       ` Daniel Golle
2016-06-19  8:53       ` Richard Weinberger
2016-06-19  8:53         ` Richard Weinberger
2016-06-19  9:16         ` Richard Weinberger
2016-06-19  9:16           ` Richard Weinberger
2016-06-19 11:25         ` Daniel Golle
2016-06-19 11:25           ` Daniel Golle
2016-06-19 12:02           ` Richard Weinberger
2016-06-19 12:02             ` Richard Weinberger
2016-06-19 13:05             ` Daniel Golle
2016-06-19 13:05               ` Daniel Golle
2016-06-19 13:19               ` Richard Weinberger
2016-06-19 13:19                 ` Richard Weinberger
2016-06-19 14:09                 ` Daniel Golle
2016-06-19 14:09                   ` Daniel Golle
2016-06-19 14:35                   ` Richard Weinberger
2016-06-19 14:35                     ` Richard Weinberger
2016-06-19 15:24                     ` Daniel Golle
2016-06-19 15:24                       ` Daniel Golle
2016-06-19 15:31                       ` Richard Weinberger
2016-06-19 15:31                         ` Richard Weinberger
2016-06-19 16:13                         ` Daniel Golle
2016-06-19 16:13                           ` Daniel Golle
2016-06-19 16:53                           ` Boris Brezillon
2016-06-19 16:53                             ` Boris Brezillon
2016-06-19 19:42                             ` Daniel Golle
2016-06-19 19:42                               ` Daniel Golle
2016-06-19 20:14                               ` Boris Brezillon
2016-06-19 20:14                                 ` Boris Brezillon
2016-06-19 21:48                                 ` Daniel Golle
2016-06-19 21:48                                   ` Daniel Golle
2016-06-19 22:21                                   ` Hauke Mehrtens
2016-06-19 22:21                                     ` Hauke Mehrtens
2016-06-20  8:09                                     ` Arnd Bergmann
2016-06-20  8:09                                       ` Arnd Bergmann
2016-06-20  8:26                                       ` Richard Weinberger
2016-06-20  8:26                                         ` Richard Weinberger
2016-06-20 15:08                                         ` Arnd Bergmann
2016-06-20 15:08                                           ` Arnd Bergmann
2016-06-20 17:24                                           ` Brian Norris
2016-06-20 17:24                                             ` Brian Norris
2016-06-20 19:57                                           ` Richard Weinberger
2016-06-20 19:57                                             ` Richard Weinberger
2016-06-20 21:18                                             ` Hauke Mehrtens
2016-06-20 21:18                                               ` Hauke Mehrtens
2016-06-20 17:05                                       ` Brian Norris
2016-06-20 17:05                                         ` Brian Norris
2016-06-19 15:43                       ` Boris Brezillon
2016-06-19 15:43                         ` Boris Brezillon
2016-06-19 16:23                         ` Daniel Golle
2016-06-19 16:23                           ` Daniel Golle
2016-06-20 17:03                   ` Brian Norris
2016-06-20 17:03                     ` Brian Norris
2016-06-24 18:28     ` Ezequiel Garcia
2016-06-24 18:28       ` Ezequiel Garcia
2016-06-25 20:20       ` Hauke Mehrtens
2016-06-25 20:20         ` Hauke Mehrtens
2016-06-25 20:33         ` Richard Weinberger
2016-06-25 20:33           ` Richard Weinberger
2016-06-18 23:56 ` Daniel Golle
2016-06-18 23:56   ` Daniel Golle
2016-06-19 21:36   ` Hauke Mehrtens
2016-06-19 21:36     ` Hauke Mehrtens
2016-06-19 21:52     ` Daniel Golle
2016-06-19 21:52       ` Daniel Golle

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=20160618233654.GC29476@makrotopia.org \
    --to=daniel@makrotopia.org \
    --cc=computersforpeace@gmail.com \
    --cc=dedekind1@gmail.com \
    --cc=devicetree@vger.kernel.org \
    --cc=dwmw2@infradead.org \
    --cc=hauke@hauke-m.de \
    --cc=linux-mtd@lists.infradead.org \
    --cc=mark.rutland@arm.com \
    --cc=richard@nod.at \
    --cc=robh+dt@kernel.org \
    /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.