* [PATCH] mtd: Add partition device node to mtd partition devices
@ 2017-02-09 10:50 Uwe Kleine-König
2017-02-09 15:34 ` Boris Brezillon
2017-02-10 3:19 ` Brian Norris
0 siblings, 2 replies; 7+ messages in thread
From: Uwe Kleine-König @ 2017-02-09 10:50 UTC (permalink / raw)
To: David Woodhouse, Brian Norris, Boris Brezillon, Marek Vasut,
Richard Weinberger, Cyrille Pitchen
Cc: linux-mtd, kernel, Sascha Hauer
From: Sascha Hauer <s.hauer@pengutronix.de>
The user visible change here is that mtd partitions get an of_node link
in sysfs.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
drivers/mtd/mtdpart.c | 1 +
drivers/mtd/ofpart.c | 1 +
include/linux/mtd/partitions.h | 1 +
3 files changed, 3 insertions(+)
diff --git a/drivers/mtd/mtdpart.c b/drivers/mtd/mtdpart.c
index fccdd49bb964..d0b919ab85c0 100644
--- a/drivers/mtd/mtdpart.c
+++ b/drivers/mtd/mtdpart.c
@@ -424,6 +424,7 @@ static struct mtd_part *allocate_partition(struct mtd_info *master,
slave->mtd.dev.parent = IS_ENABLED(CONFIG_MTD_PARTITIONED_MASTER) ?
&master->dev :
master->dev.parent;
+ slave->mtd.dev.of_node = part->of_node;
slave->mtd._read = part_read;
slave->mtd._write = part_write;
diff --git a/drivers/mtd/ofpart.c b/drivers/mtd/ofpart.c
index ede407d6e106..464470122493 100644
--- a/drivers/mtd/ofpart.c
+++ b/drivers/mtd/ofpart.c
@@ -108,6 +108,7 @@ static int parse_ofpart_partitions(struct mtd_info *master,
parts[i].offset = of_read_number(reg, a_cells);
parts[i].size = of_read_number(reg + a_cells, s_cells);
+ parts[i].of_node = pp;
partname = of_get_property(pp, "label", &len);
if (!partname)
diff --git a/include/linux/mtd/partitions.h b/include/linux/mtd/partitions.h
index 70736e1e6c8f..06df1e06b6e0 100644
--- a/include/linux/mtd/partitions.h
+++ b/include/linux/mtd/partitions.h
@@ -41,6 +41,7 @@ struct mtd_partition {
uint64_t size; /* partition size */
uint64_t offset; /* offset within the master MTD space */
uint32_t mask_flags; /* master MTD flags to mask out for this partition */
+ struct device_node *of_node;
};
#define MTDPART_OFS_RETAIN (-3)
--
2.11.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH] mtd: Add partition device node to mtd partition devices
2017-02-09 10:50 [PATCH] mtd: Add partition device node to mtd partition devices Uwe Kleine-König
@ 2017-02-09 15:34 ` Boris Brezillon
2017-02-09 19:39 ` Uwe Kleine-König
2017-02-10 3:19 ` Brian Norris
1 sibling, 1 reply; 7+ messages in thread
From: Boris Brezillon @ 2017-02-09 15:34 UTC (permalink / raw)
To: Uwe Kleine-König, Brian Norris
Cc: David Woodhouse, Marek Vasut, Richard Weinberger, Cyrille Pitchen,
linux-mtd, kernel, Sascha Hauer, Moritz Fischer
+Moritz
On Thu, 9 Feb 2017 11:50:24 +0100
Uwe Kleine-König <u.kleine-koenig@pengutronix.de> wrote:
> From: Sascha Hauer <s.hauer@pengutronix.de>
>
> The user visible change here is that mtd partitions get an of_node link
> in sysfs.
The same patch has already been posted last year [1].
Brian, can we take one of these?
[1]https://patchwork.ozlabs.org/patch/625978/
>
> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
> ---
> drivers/mtd/mtdpart.c | 1 +
> drivers/mtd/ofpart.c | 1 +
> include/linux/mtd/partitions.h | 1 +
> 3 files changed, 3 insertions(+)
>
> diff --git a/drivers/mtd/mtdpart.c b/drivers/mtd/mtdpart.c
> index fccdd49bb964..d0b919ab85c0 100644
> --- a/drivers/mtd/mtdpart.c
> +++ b/drivers/mtd/mtdpart.c
> @@ -424,6 +424,7 @@ static struct mtd_part *allocate_partition(struct mtd_info *master,
> slave->mtd.dev.parent = IS_ENABLED(CONFIG_MTD_PARTITIONED_MASTER) ?
> &master->dev :
> master->dev.parent;
> + slave->mtd.dev.of_node = part->of_node;
>
> slave->mtd._read = part_read;
> slave->mtd._write = part_write;
> diff --git a/drivers/mtd/ofpart.c b/drivers/mtd/ofpart.c
> index ede407d6e106..464470122493 100644
> --- a/drivers/mtd/ofpart.c
> +++ b/drivers/mtd/ofpart.c
> @@ -108,6 +108,7 @@ static int parse_ofpart_partitions(struct mtd_info *master,
>
> parts[i].offset = of_read_number(reg, a_cells);
> parts[i].size = of_read_number(reg + a_cells, s_cells);
> + parts[i].of_node = pp;
>
> partname = of_get_property(pp, "label", &len);
> if (!partname)
> diff --git a/include/linux/mtd/partitions.h b/include/linux/mtd/partitions.h
> index 70736e1e6c8f..06df1e06b6e0 100644
> --- a/include/linux/mtd/partitions.h
> +++ b/include/linux/mtd/partitions.h
> @@ -41,6 +41,7 @@ struct mtd_partition {
> uint64_t size; /* partition size */
> uint64_t offset; /* offset within the master MTD space */
> uint32_t mask_flags; /* master MTD flags to mask out for this partition */
> + struct device_node *of_node;
> };
>
> #define MTDPART_OFS_RETAIN (-3)
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] mtd: Add partition device node to mtd partition devices
2017-02-09 15:34 ` Boris Brezillon
@ 2017-02-09 19:39 ` Uwe Kleine-König
2017-02-09 19:59 ` Boris Brezillon
0 siblings, 1 reply; 7+ messages in thread
From: Uwe Kleine-König @ 2017-02-09 19:39 UTC (permalink / raw)
To: Boris Brezillon
Cc: Brian Norris, David Woodhouse, Marek Vasut, Richard Weinberger,
Cyrille Pitchen, linux-mtd, kernel, Sascha Hauer, Moritz Fischer
On Thu, Feb 09, 2017 at 04:34:58PM +0100, Boris Brezillon wrote:
> +Moritz
>
> On Thu, 9 Feb 2017 11:50:24 +0100
> Uwe Kleine-König <u.kleine-koenig@pengutronix.de> wrote:
>
> > From: Sascha Hauer <s.hauer@pengutronix.de>
> >
> > The user visible change here is that mtd partitions get an of_node link
> > in sysfs.
>
> The same patch has already been posted last year [1].
> Brian, can we take one of these?
>
> [1]https://patchwork.ozlabs.org/patch/625978/
Moritz' patch is more lame, it even updates the documentation (ok, one
point for Moriz :-) Other than that the only difference is "node" vs.
"of_node" (half a point for Sascha) and the position of the assignment
in mtdpart.c has a different position (another half point for Sascha).
If that would be liked to be seen I can volunteer to create a patch
picking the best from both sources.
Best regards
Uwe
--
Pengutronix e.K. | Uwe Kleine-König |
Industrial Linux Solutions | http://www.pengutronix.de/ |
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] mtd: Add partition device node to mtd partition devices
2017-02-09 19:39 ` Uwe Kleine-König
@ 2017-02-09 19:59 ` Boris Brezillon
2017-02-09 20:14 ` Uwe Kleine-König
0 siblings, 1 reply; 7+ messages in thread
From: Boris Brezillon @ 2017-02-09 19:59 UTC (permalink / raw)
To: Uwe Kleine-König
Cc: Brian Norris, David Woodhouse, Marek Vasut, Richard Weinberger,
Cyrille Pitchen, linux-mtd, kernel, Sascha Hauer, Moritz Fischer
On Thu, 9 Feb 2017 20:39:40 +0100
Uwe Kleine-König <u.kleine-koenig@pengutronix.de> wrote:
> On Thu, Feb 09, 2017 at 04:34:58PM +0100, Boris Brezillon wrote:
> > +Moritz
> >
> > On Thu, 9 Feb 2017 11:50:24 +0100
> > Uwe Kleine-König <u.kleine-koenig@pengutronix.de> wrote:
> >
> > > From: Sascha Hauer <s.hauer@pengutronix.de>
> > >
> > > The user visible change here is that mtd partitions get an of_node link
> > > in sysfs.
> >
> > The same patch has already been posted last year [1].
> > Brian, can we take one of these?
> >
> > [1]https://patchwork.ozlabs.org/patch/625978/
>
> Moritz' patch is more lame, it even updates the documentation (ok, one
> point for Moriz :-) Other than that the only difference is "node" vs.
> "of_node" (half a point for Sascha) and the position of the assignment
> in mtdpart.c has a different position (another half point for Sascha).
>
> If that would be liked to be seen I can volunteer to create a patch
> picking the best from both sources.
Sure, you can also add my ack (which I already put on Moritz patch).
BTW, is the of_node link in sysfs the only motivation for this change?
I know Moritz had bigger plans (nvmem blocks on top of MTD devices), and
I also considered advanced stuff (like per-partition ECC config) which
required having a valid ->of_node on slave MTD devices.
Thanks,
Boris
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] mtd: Add partition device node to mtd partition devices
2017-02-09 19:59 ` Boris Brezillon
@ 2017-02-09 20:14 ` Uwe Kleine-König
2017-02-09 20:41 ` Boris Brezillon
0 siblings, 1 reply; 7+ messages in thread
From: Uwe Kleine-König @ 2017-02-09 20:14 UTC (permalink / raw)
To: Boris Brezillon
Cc: Brian Norris, David Woodhouse, Marek Vasut, Richard Weinberger,
Cyrille Pitchen, linux-mtd, kernel, Sascha Hauer, Moritz Fischer
Hello Boris,
On Thu, Feb 09, 2017 at 08:59:22PM +0100, Boris Brezillon wrote:
> On Thu, 9 Feb 2017 20:39:40 +0100
> Uwe Kleine-König <u.kleine-koenig@pengutronix.de> wrote:
>
> > On Thu, Feb 09, 2017 at 04:34:58PM +0100, Boris Brezillon wrote:
> > > +Moritz
> > >
> > > On Thu, 9 Feb 2017 11:50:24 +0100
> > > Uwe Kleine-König <u.kleine-koenig@pengutronix.de> wrote:
> > >
> > > > From: Sascha Hauer <s.hauer@pengutronix.de>
> > > >
> > > > The user visible change here is that mtd partitions get an of_node link
> > > > in sysfs.
> > >
> > > The same patch has already been posted last year [1].
> > > Brian, can we take one of these?
> > >
> > > [1]https://patchwork.ozlabs.org/patch/625978/
> >
> > Moritz' patch is more lame, it even updates the documentation (ok, one
> > point for Moriz :-) Other than that the only difference is "node" vs.
> > "of_node" (half a point for Sascha) and the position of the assignment
> > in mtdpart.c has a different position (another half point for Sascha).
> >
> > If that would be liked to be seen I can volunteer to create a patch
> > picking the best from both sources.
>
> Sure, you can also add my ack (which I already put on Moritz patch).
> BTW, is the of_node link in sysfs the only motivation for this change?
> I know Moritz had bigger plans (nvmem blocks on top of MTD devices), and
> I also considered advanced stuff (like per-partition ECC config) which
> required having a valid ->of_node on slave MTD devices.
The motivation for Sascha to create this patch and now me to mainline
it, is that we specify some non-volatile state space in dts (to store
for example hardware revision, serial number and mac addresses). See
http://barebox.org/doc/latest/devicetree/bindings/barebox/barebox,state.html
for some details.
For the userspace part we read the dtb, something like
state {
compatible = "barebox,state";
backend = &mtdstatepartition;
...
}
, and with the symlink introduced by the patch under discussion it gets
much simpler to find the device file (in /dev) that contains our state
data.
Best regards
Uwe
--
Pengutronix e.K. | Uwe Kleine-König |
Industrial Linux Solutions | http://www.pengutronix.de/ |
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] mtd: Add partition device node to mtd partition devices
2017-02-09 20:14 ` Uwe Kleine-König
@ 2017-02-09 20:41 ` Boris Brezillon
0 siblings, 0 replies; 7+ messages in thread
From: Boris Brezillon @ 2017-02-09 20:41 UTC (permalink / raw)
To: Uwe Kleine-König
Cc: Brian Norris, David Woodhouse, Marek Vasut, Richard Weinberger,
Cyrille Pitchen, linux-mtd, kernel, Sascha Hauer, Moritz Fischer
On Thu, 9 Feb 2017 21:14:04 +0100
Uwe Kleine-König <u.kleine-koenig@pengutronix.de> wrote:
> Hello Boris,
>
> On Thu, Feb 09, 2017 at 08:59:22PM +0100, Boris Brezillon wrote:
> > On Thu, 9 Feb 2017 20:39:40 +0100
> > Uwe Kleine-König <u.kleine-koenig@pengutronix.de> wrote:
> >
> > > On Thu, Feb 09, 2017 at 04:34:58PM +0100, Boris Brezillon wrote:
> > > > +Moritz
> > > >
> > > > On Thu, 9 Feb 2017 11:50:24 +0100
> > > > Uwe Kleine-König <u.kleine-koenig@pengutronix.de> wrote:
> > > >
> > > > > From: Sascha Hauer <s.hauer@pengutronix.de>
> > > > >
> > > > > The user visible change here is that mtd partitions get an of_node link
> > > > > in sysfs.
> > > >
> > > > The same patch has already been posted last year [1].
> > > > Brian, can we take one of these?
> > > >
> > > > [1]https://patchwork.ozlabs.org/patch/625978/
> > >
> > > Moritz' patch is more lame, it even updates the documentation (ok, one
> > > point for Moriz :-) Other than that the only difference is "node" vs.
> > > "of_node" (half a point for Sascha) and the position of the assignment
> > > in mtdpart.c has a different position (another half point for Sascha).
> > >
> > > If that would be liked to be seen I can volunteer to create a patch
> > > picking the best from both sources.
> >
> > Sure, you can also add my ack (which I already put on Moritz patch).
> > BTW, is the of_node link in sysfs the only motivation for this change?
> > I know Moritz had bigger plans (nvmem blocks on top of MTD devices), and
> > I also considered advanced stuff (like per-partition ECC config) which
> > required having a valid ->of_node on slave MTD devices.
>
> The motivation for Sascha to create this patch and now me to mainline
> it, is that we specify some non-volatile state space in dts (to store
> for example hardware revision, serial number and mac addresses). See
> http://barebox.org/doc/latest/devicetree/bindings/barebox/barebox,state.html
> for some details.
>
> For the userspace part we read the dtb, something like
>
> state {
> compatible = "barebox,state";
> backend = &mtdstatepartition;
> ...
> }
>
> , and with the symlink introduced by the patch under discussion it gets
> much simpler to find the device file (in /dev) that contains our state
> data.
Okay. Looks like an advanced nvmem [1] implementation. Anyway, having
the of_node populated for MTD partition devs sounds reasonable, no
matter the reason you need that for.
[1]http://lxr.free-electrons.com/source/Documentation/devicetree/bindings/nvmem/nvmem.txt
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] mtd: Add partition device node to mtd partition devices
2017-02-09 10:50 [PATCH] mtd: Add partition device node to mtd partition devices Uwe Kleine-König
2017-02-09 15:34 ` Boris Brezillon
@ 2017-02-10 3:19 ` Brian Norris
1 sibling, 0 replies; 7+ messages in thread
From: Brian Norris @ 2017-02-10 3:19 UTC (permalink / raw)
To: Uwe Kleine-König
Cc: David Woodhouse, Boris Brezillon, Marek Vasut, Richard Weinberger,
Cyrille Pitchen, linux-mtd, kernel, Sascha Hauer
On Thu, Feb 09, 2017 at 11:50:24AM +0100, Uwe Kleine-König wrote:
> From: Sascha Hauer <s.hauer@pengutronix.de>
>
> The user visible change here is that mtd partitions get an of_node link
> in sysfs.
>
> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Appled to l2-mtd.git
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2017-02-10 3:20 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-02-09 10:50 [PATCH] mtd: Add partition device node to mtd partition devices Uwe Kleine-König
2017-02-09 15:34 ` Boris Brezillon
2017-02-09 19:39 ` Uwe Kleine-König
2017-02-09 19:59 ` Boris Brezillon
2017-02-09 20:14 ` Uwe Kleine-König
2017-02-09 20:41 ` Boris Brezillon
2017-02-10 3:19 ` Brian Norris
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).