ofpart: Partitions at same address cannot have the same name
Sometimes, an special partition is included in the device tree including all the partitions. Like in: partit...@ff00 { reg = < 0x00 0x80 >; label = "Root File System"; }; partit...@ff80 { reg = < 0x80 0x1a >; label = "Bitstream"; }; ... partition...@ff00 { reg = < 0x00 0x100 >; label = "Full FLASH"; }; Because two nodes of a device tree cannot have the same name, but all the partitions must be named "partition", this special partition is invalid. This patch makes ofpart.c only check for the firt part of the name, and ignore the rest, allowing this special partition. --- The extra partition is quite useful while formating the full firmware from linux v2, removes the -1 drivers/mtd/ofpart.c |3 ++- 1 files changed, 2 insertions(+), 1 deletions(-) diff --git a/drivers/mtd/ofpart.c b/drivers/mtd/ofpart.c index 3e164f0..0af3b07 100644 --- a/drivers/mtd/ofpart.c +++ b/drivers/mtd/ofpart.c @@ -48,7 +48,7 @@ int __devinit of_mtd_parse_partitions(struct device *dev, /* check if this is a partition node */ partname = of_get_property(pp, "name", &len); - if (strcmp(partname, "partition") != 0) { + if (strncmp(partname, "partition", strlen("partition") != 0) { nr_parts--; continue; } -- 1.6.2.4 ___ Linuxppc-dev mailing list Linuxppc-dev@ozlabs.org https://ozlabs.org/mailman/listinfo/linuxppc-dev
[MTD] ofpart: Partitions at same address cannot have the same name
Sometimes, an special partition is included in the device tree including all the partitions. Like in: partit...@ff00 { reg = < 0x00 0x80 >; label = "Root File System"; }; partit...@ff80 { reg = < 0x80 0x1a >; label = "Bitstream"; }; ... partition...@ff00 { reg = < 0x00 0x100 >; label = "Full FLASH"; }; Because two nodes of a device tree cannot have the same name, but all the partitions must be named "partition", this special partition is invalid. This patch makes ofpart.c only check for the firt part of the name, and ignore the rest, allowing this special partition. --- The extra partition is quite useful while formating the full firmware from linux drivers/mtd/ofpart.c |3 ++- 1 files changed, 2 insertions(+), 1 deletions(-) diff --git a/drivers/mtd/ofpart.c b/drivers/mtd/ofpart.c index 3e164f0..0af3b07 100644 --- a/drivers/mtd/ofpart.c +++ b/drivers/mtd/ofpart.c @@ -48,7 +48,8 @@ int __devinit of_mtd_parse_partitions(struct device *dev, /* check if this is a partition node */ partname = of_get_property(pp, "name", &len); - if (strcmp(partname, "partition") != 0) { + if (strncmp(partname, "partition", strlen("partition")-1) + != 0) { nr_parts--; continue; } -- 1.6.2.4 ___ Linuxppc-dev mailing list Linuxppc-dev@ozlabs.org https://ozlabs.org/mailman/listinfo/linuxppc-dev
Re: ofpart: Partitions at same address cannot have the same name
>--- a/drivers/mtd/ofpart.c >+++ b/drivers/mtd/ofpart.c >@@ -48,7 +48,7 @@ int __devinit of_mtd_parse_partitions(struct device *dev, > > /* check if this is a partition node */ > partname = of_get_property(pp, "name", &len); >- if (strcmp(partname, "partition") != 0) { >+ if (strncmp(partname, "partition", strlen("partition") != 0) { Hi Recardo, I would suggest to do: if (strcmp(partname, "partition") <= 0) { cheers ben ___ Linuxppc-dev mailing list Linuxppc-dev@ozlabs.org https://ozlabs.org/mailman/listinfo/linuxppc-dev
Re: ofpart: Partitions at same address cannot have the same name
Benjamin Krill wrote: --- a/drivers/mtd/ofpart.c +++ b/drivers/mtd/ofpart.c @@ -48,7 +48,7 @@ int __devinit of_mtd_parse_partitions(struct device *dev, /* check if this is a partition node */ partname = of_get_property(pp, "name", &len); - if (strcmp(partname, "partition") != 0) { + if (strncmp(partname, "partition", strlen("partition") != 0) { Perhaps "compatible" should be used instead? Hi Recardo, I would suggest to do: if (strcmp(partname, "partition") <= 0) { Check whether it sorts alphabetically before "partition"? Why? -Scott ___ Linuxppc-dev mailing list Linuxppc-dev@ozlabs.org https://ozlabs.org/mailman/listinfo/linuxppc-dev
Re: ofpart: Partitions at same address cannot have the same name
Hi Scott > Perhaps "compatible" should be used instead? What do you mean? if (strcmp(partname, "partition") || strcmp(partname, "compatible") ) I can't see the advantages. > >> Hi Recardo, >> >> I would suggest to do: >> >> if (strcmp(partname, "partition") <= 0) { > > Check whether it sorts alphabetically before "partition"? Why? > > -Scott > -- Ricardo Ribalda http://www.eps.uam.es/~rribalda/ ___ Linuxppc-dev mailing list Linuxppc-dev@ozlabs.org https://ozlabs.org/mailman/listinfo/linuxppc-dev
Re: ofpart: Partitions at same address cannot have the same name
Hello Benjamin > Hi Recardo, > > I would suggest to do: > > if (strcmp(partname, "partition") <= 0) { Anything alfabetically higher than partition (like "z" will pass the test :S) Regards > > cheers > ben > > -- Ricardo Ribalda http://www.eps.uam.es/~rribalda/ ___ Linuxppc-dev mailing list Linuxppc-dev@ozlabs.org https://ozlabs.org/mailman/listinfo/linuxppc-dev
Re: ofpart: Partitions at same address cannot have the same name
Ricardo Ribalda Delgado wrote: Hi Scott Perhaps "compatible" should be used instead? What do you mean? if (strcmp(partname, "partition") || strcmp(partname, "compatible") ) I can't see the advantages. No, I mean: foo { compatible = "partition"; ... }; -Scott ___ Linuxppc-dev mailing list Linuxppc-dev@ozlabs.org https://ozlabs.org/mailman/listinfo/linuxppc-dev
Re: ofpart: Partitions at same address cannot have the same name
* Ricardo Ribalda Delgado | 2009-04-22 19:59:08 [+0200]: >> >> if (strcmp(partname, "partition") <= 0) { > >Anything alfabetically higher than partition (like "z" will pass >the test :S) You are totally right! cheers ben ___ Linuxppc-dev mailing list Linuxppc-dev@ozlabs.org https://ozlabs.org/mailman/listinfo/linuxppc-dev
Re: ofpart: Partitions at same address cannot have the same name
Hello Scott It is definitively more elegant... Let me send tomorrow a patch On Wed, Apr 22, 2009 at 20:11, Scott Wood wrote: > Ricardo Ribalda Delgado wrote: >> >> Hi Scott >> >>> Perhaps "compatible" should be used instead? >> >> What do you mean? >> >> if (strcmp(partname, "partition") || strcmp(partname, "compatible") ) >> >> I can't see the advantages. > > No, I mean: > > foo { > compatible = "partition"; > ... > }; > > -Scott > -- Ricardo Ribalda http://www.eps.uam.es/~rribalda/ ___ Linuxppc-dev mailing list Linuxppc-dev@ozlabs.org https://ozlabs.org/mailman/listinfo/linuxppc-dev
Re: [MTD] ofpart: Partitions at same address cannot have the same name
> "Ricardo" == Ricardo Ribalda Delgado writes: Hi, Ricardo> Sometimes, an special partition is included in the device Ricardo> tree including all the partitions. Like in: Ricardo> drivers/mtd/ofpart.c |3 ++- Ricardo> 1 files changed, 2 insertions(+), 1 deletions(-) Ricardo> diff --git a/drivers/mtd/ofpart.c b/drivers/mtd/ofpart.c Ricardo> index 3e164f0..0af3b07 100644 Ricardo> --- a/drivers/mtd/ofpart.c Ricardo> +++ b/drivers/mtd/ofpart.c Ricardo> @@ -48,7 +48,8 @@ int __devinit of_mtd_parse_partitions(struct device *dev, Ricardo> /* check if this is a partition node */ Ricardo> partname = of_get_property(pp, "name", &len); Ricardo> - if (strcmp(partname, "partition") != 0) { Ricardo> + if (strncmp(partname, "partition", strlen("partition")-1) Why strlen() - 1 ? -- Bye, Peter Korsgaard ___ Linuxppc-dev mailing list Linuxppc-dev@ozlabs.org https://ozlabs.org/mailman/listinfo/linuxppc-dev
Re: [MTD] ofpart: Partitions at same address cannot have the same name
Hello You are right, remove the -1. I thought that strlen gives the #of chars + 1 ('\0'). Thanks On Wed, Apr 22, 2009 at 11:24, Peter Korsgaard wrote: >> "Ricardo" == Ricardo Ribalda Delgado writes: > > Hi, > > Ricardo> Sometimes, an special partition is included in the device > Ricardo> tree including all the partitions. Like in: > > Ricardo> drivers/mtd/ofpart.c | 3 ++- > Ricardo> 1 files changed, 2 insertions(+), 1 deletions(-) > > Ricardo> diff --git a/drivers/mtd/ofpart.c b/drivers/mtd/ofpart.c > Ricardo> index 3e164f0..0af3b07 100644 > Ricardo> --- a/drivers/mtd/ofpart.c > Ricardo> +++ b/drivers/mtd/ofpart.c > Ricardo> @@ -48,7 +48,8 @@ int __devinit of_mtd_parse_partitions(struct > device *dev, > > Ricardo> /* check if this is a partition node */ > Ricardo> partname = of_get_property(pp, "name", &len); > Ricardo> - if (strcmp(partname, "partition") != 0) { > Ricardo> + if (strncmp(partname, "partition", > strlen("partition")-1) > > Why strlen() - 1 ? > > -- > Bye, Peter Korsgaard > -- Ricardo Ribalda http://www.eps.uam.es/~rribalda/ ___ Linuxppc-dev mailing list Linuxppc-dev@ozlabs.org https://ozlabs.org/mailman/listinfo/linuxppc-dev
Re: [MTD] ofpart: Partitions at same address cannot have the same name
On Wed, 2009-04-22 at 10:05 +0200, Ricardo Ribalda Delgado wrote: > Sometimes, an special partition is included in the device tree including all > the > partitions. Like in: > > partit...@ff00 { > reg = < 0x00 0x80 >; > label = "Root File System"; > }; > partit...@ff80 { > reg = < 0x80 0x1a >; > label = "Bitstream"; > }; > ... > partition...@ff00 { > reg = < 0x00 0x100 >; > label = "Full FLASH"; > }; > > Because two nodes of a device tree cannot have the same name, but all the > partitions must be named "partition", this special partition is invalid. > > This patch makes ofpart.c only check for the firt part of the name, and > ignore the rest, allowing this special partition. I fail to see the point of this "special" partition in the first place... Things would make more sense if you had a full flash device whose child nodes are the partitions. Ben. ___ Linuxppc-dev mailing list Linuxppc-dev@ozlabs.org https://ozlabs.org/mailman/listinfo/linuxppc-dev
Re: [MTD] ofpart: Partitions at same address cannot have the same name
On Thu, 2009-04-30 at 04:19 +0100, Benjamin Herrenschmidt wrote: > > I fail to see the point of this "special" partition in the first > place... > > Things would make more sense if you had a full flash device > whose child nodes are the partitions. That's the model I think I want to move to, and which I was toying with in http://git.infradead.org/users/dwmw2/mtd-sysfs.git (I haven't done it yet, but it's logically the next step after what I've already done). -- David WoodhouseOpen Source Technology Centre david.woodho...@intel.com Intel Corporation ___ Linuxppc-dev mailing list Linuxppc-dev@ozlabs.org https://ozlabs.org/mailman/listinfo/linuxppc-dev
[PATCH] [MTD] ofpart: Partitions at same address cannot have the same name v3
Sometimes, an special partition is included in the device tree including all the partitions. Like in: partit...@ff00 { reg = < 0x00 0x80 >; label = "Root File System"; }; partit...@ff80 { reg = < 0x80 0x1a >; label = "Bitstream"; }; ... f...@ff00 { compatible = "partition"; reg = < 0x00 0x100 >; label = "Full FLASH"; }; Because two nodes of a device tree cannot have the same name, but all the partitions must be named "partition", this special partition is invalid. This patch makes ofpart.c accept spetial partitions compatible with "partition" but not named partition. These spetial partitions are very useful for flashing the full firmware of a device from linux --- This v3 includes feedback from Scott Wood, Peter Korsgaard & Benjamin Kril v3: Use the compatible propierty v2: buggy implementation, strlen-1 instead of strlen v1: Just check the firt part of the name drivers/mtd/ofpart.c |4 +++- 1 files changed, 3 insertions(+), 1 deletions(-) diff --git a/drivers/mtd/ofpart.c b/drivers/mtd/ofpart.c index 3e164f0..59c1e4a 100644 --- a/drivers/mtd/ofpart.c +++ b/drivers/mtd/ofpart.c @@ -48,7 +48,9 @@ int __devinit of_mtd_parse_partitions(struct device *dev, /* check if this is a partition node */ partname = of_get_property(pp, "name", &len); - if (strcmp(partname, "partition") != 0) { + if ((strcmp(partname, "partition") != 0) && + (of_device_is_compatible(pp, "partition") != 1)) + { nr_parts--; continue; } -- 1.6.2.4 ___ Linuxppc-dev mailing list Linuxppc-dev@ozlabs.org https://ozlabs.org/mailman/listinfo/linuxppc-dev
Re: [PATCH] [MTD] ofpart: Partitions at same address cannot have the same name v3
>--- a/drivers/mtd/ofpart.c >+++ b/drivers/mtd/ofpart.c >@@ -48,7 +48,9 @@ int __devinit of_mtd_parse_partitions(struct device *dev, > > /* check if this is a partition node */ > partname = of_get_property(pp, "name", &len); >- if (strcmp(partname, "partition") != 0) { >+ if ((strcmp(partname, "partition") != 0) && >+ (of_device_is_compatible(pp, "partition") != 1)) >+ { > nr_parts--; > continue; > } If this is the way, how to go, you get my ack. Acked-by: Benjamin Krill ___ Linuxppc-dev mailing list Linuxppc-dev@ozlabs.org https://ozlabs.org/mailman/listinfo/linuxppc-dev
Re: [PATCH] [MTD] ofpart: Partitions at same address cannot have the same name v3
Sometimes, an special partition is included in the device tree including all the partitions. Like in: partit...@ff00 { reg = < 0x00 0x80 >; label = "Root File System"; }; partit...@ff80 { reg = < 0x80 0x1a >; label = "Bitstream"; }; ... f...@ff00 { compatible = "partition"; reg = < 0x00 0x100 >; label = "Full FLASH"; }; Your special "partition" isn't really a partition then, is it. Because of that, device nodes to represent your partitions doesn't work very well. You really want to use something else, a partition table on the flash itself for example. Or maybe the (platform? MTD?) code should create a Linux device for the "full" device. Because two nodes of a device tree cannot have the same name, This isn't true. but all the partitions must be named "partition", Bad binding, no cookie for you! - if (strcmp(partname, "partition") != 0) { + if ((strcmp(partname, "partition") != 0) && + (of_device_is_compatible(pp, "partition") != 1)) + { You cannot claim a name as generic as "partition" for this. Pick something else if you really must do things this way. Segher ___ Linuxppc-dev mailing list Linuxppc-dev@ozlabs.org https://ozlabs.org/mailman/listinfo/linuxppc-dev