diff mbox

ofpart: Partitions at same address cannot have the same name

Message ID 1240415535-10939-1-git-send-email-ricardo.ribalda@uam.es (mailing list archive)
State Rejected, archived
Headers show

Commit Message

Ricardo Ribalda April 22, 2009, 3:52 p.m. UTC
Sometimes, an special partition is included in the device tree including all the
partitions. Like in:

partition@ff000000 {
       reg = < 0x000000 0x800000 >;
       label = "Root File System";
};
partition@ff800000 {
       reg = < 0x800000 0x1a0000 >;
       label = "Bitstream";
};
...
partitionAll@ff000000 {
       reg = < 0x000000 0x1000000 >;
       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 <Peter Korsgaard>

 drivers/mtd/ofpart.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

Comments

Benjamin Krill April 22, 2009, 5:10 p.m. UTC | #1
>--- 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
Scott Wood April 22, 2009, 5:27 p.m. UTC | #2
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
Ricardo Ribalda April 22, 2009, 5:56 p.m. UTC | #3
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 April 22, 2009, 5:59 p.m. UTC | #4
Hello Benjamin

> Hi Recardo,
>
> I would suggest to do:
>
>                if (strcmp(partname, "partition") <= 0) {

Anything alfabetically higher than partition (like "zzzzz" will pass
the test :S)

Regards



>
> cheers
>  ben
>
>
Scott Wood April 22, 2009, 6:11 p.m. UTC | #5
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
Benjamin Krill April 22, 2009, 6:33 p.m. UTC | #6
* Ricardo Ribalda Delgado | 2009-04-22 19:59:08 [+0200]:
>>
>>                if (strcmp(partname, "partition") <= 0) {
>
>Anything alfabetically higher than partition (like "zzzzz" will pass
>the test :S)

You are totally right!

cheers
 ben
Ricardo Ribalda April 22, 2009, 6:58 p.m. UTC | #7
Hello Scott

It is definitively more elegant...

  Let me send tomorrow a patch

On Wed, Apr 22, 2009 at 20:11, Scott Wood <scottwood@freescale.com> 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
>
diff mbox

Patch

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;
 		}