Re: [PATCH] powerpc: add of_find_next_property and of_get_aliased_index

2008-06-26 Thread Benjamin Herrenschmidt

 +struct property *of_find_next_property(const struct device_node *np,
 + struct property *prev)
 +{
 + struct property *next;
 +
 + if (!np)
 + return NULL;
 +
 + read_lock(devtree_lock);
 + next = prev ? prev-next : np-properties;
 + read_unlock(devtree_lock);
 +
 + return next;
 +}

Unfortunately, this isn't race free vs. removal or addition of
properties. This is fine with the intended usage (ie. retreiving
aliases) but at least that should be explained in a comment.

Cheers,
Ben.


___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


Re: [PATCH] powerpc: add of_find_next_property and of_get_aliased_index

2008-06-26 Thread Timur Tabi
Segher Boessenkool wrote:

 Well, yes, your suggested code doesn't allow punctuation either; but
 that wasn't my point, it doesn't allow numbers in names.  Why don't
 you just parse a number from the end?

Oh, you mean start at the end and go backwards?  Hmmm, I guess I could do that.

 The only thing a platform should ever use aliases for is if it needs
 to (for whatever purpose) find a specific device, that it cannot
 identify otherwise (via reg, ...).  And then that platform code
 should look up the device by the alias, not look up the alias by the
 device -- there is no 1-1 mapping from device to alias!

Hmmm, I hadn't through about that.  I guess this patch isn't such a great idea
after all.  I rescind it.

-- 
Timur Tabi
Linux kernel developer at Freescale
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


Re: [PATCH] powerpc: add of_find_next_property and of_get_aliased_index

2008-06-26 Thread Stefan Roese
On Thursday 26 June 2008, Timur Tabi wrote:
  The only thing a platform should ever use aliases for is if it needs
  to (for whatever purpose) find a specific device, that it cannot
  identify otherwise (via reg, ...).  And then that platform code
  should look up the device by the alias, not look up the alias by the
  device -- there is no 1-1 mapping from device to alias!

 Hmmm, I hadn't through about that.  I guess this patch isn't such a great
 idea after all.  I rescind it.

Too bad. So now we're back to where we started with the discussion 
about cell-index vs. index vs. no index on I2C device nodes. :-(

Best regards,
Stefan
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


Re: [PATCH] powerpc: add of_find_next_property and of_get_aliased_index

2008-06-26 Thread Timur Tabi
Stefan Roese wrote:
 On Thursday 26 June 2008, Timur Tabi wrote:
 The only thing a platform should ever use aliases for is if it needs
 to (for whatever purpose) find a specific device, that it cannot
 identify otherwise (via reg, ...).  And then that platform code
 should look up the device by the alias, not look up the alias by the
 device -- there is no 1-1 mapping from device to alias!
 Hmmm, I hadn't through about that.  I guess this patch isn't such a great
 idea after all.  I rescind it.
 
 Too bad. So now we're back to where we started with the discussion 
 about cell-index vs. index vs. no index on I2C device nodes. :-(

Well, there's a lot of disagreement on this subject.  Not only do we not agree
on a method of enumerating devices, a lot of people have a problem with the
concept of enumerating them in the first place!

This whole thing started with a problem I had in ASoC V2: identifying an I2C
device by name and number.  Scott W. pointed out that all I need in my fabric
driver is a pointer to the i2c_adapter structure that the I2C driver was using.
 If we create a link from the I2C device node to its matching i2c_adapter
structure, then I won't care what the adapter/bus number is.  Unfortunately, it
appears the current I2C code in fsl_soc.c can't handle that, but of_i2c.c can.

-- 
Timur Tabi
Linux kernel developer at Freescale
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


Re: [PATCH] powerpc: add of_find_next_property and of_get_aliased_index

2008-06-25 Thread Timur Tabi
Segher Boessenkool wrote:

 It returns 2 for both i2c-1 and i2c-2.

Well, I'm assuming that the alias property names will follow the current
convention of nn where  is a name and nn is a number.  No dashes or
other punctuation.

 Also, alias names do not have any significance in general, they are
 just handy shortcut names for humans to use; it would be better not
 to overload this.  What do you want to use this for?

As an alternative to cell-index or device-id for enumerating devices.  The
consensus from the 'cell-index vs. index vs. no index in I2C device nodes'
thread is that aliases are to be used to enumerate devices.

-- 
Timur Tabi
Linux kernel developer at Freescale
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


Re: [PATCH] powerpc: add of_find_next_property and of_get_aliased_index

2008-06-25 Thread Segher Boessenkool

It returns 2 for both i2c-1 and i2c-2.


Well, I'm assuming that the alias property names will follow the 
current
convention of nn where  is a name and nn is a number.  No 
dashes or

other punctuation.


Well, yes, your suggested code doesn't allow punctuation either; but
that wasn't my point, it doesn't allow numbers in names.  Why don't
you just parse a number from the end?


Also, alias names do not have any significance in general, they are
just handy shortcut names for humans to use; it would be better not
to overload this.  What do you want to use this for?


As an alternative to cell-index or device-id for enumerating devices.  
The
consensus from the 'cell-index vs. index vs. no index in I2C 
device nodes'

thread is that aliases are to be used to enumerate devices.


Erm, no.  That wasn't the consensus as I remember it; besides, it's
not a good plan.

Pretty much all busses can be enumerated without anything like this.
There was consensus on this.

Overloading cell-index is a bad plan.  There was consensus on this,
as well.

The only thing a platform should ever use aliases for is if it needs
to (for whatever purpose) find a specific device, that it cannot
identify otherwise (via reg, ...).  And then that platform code
should look up the device by the alias, not look up the alias by the
device -- there is no 1-1 mapping from device to alias!


Segher

___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


Re: [PATCH] powerpc: add of_find_next_property and of_get_aliased_index

2008-06-25 Thread Josh Boyer
On Wed, 2008-06-25 at 15:05 -0500, Timur Tabi wrote:
 +/**
 + * Return the first or next property within a node.
 + * @np: the node
 + * @prev: if NULL, return 1st prop, otherwise return the prop after 'prev'
 + *
 + * This function is used to get a list of properties within a node.  It's
 + * also useful for when you don't know the name of the propety you want to
 + * find.

How is this useful when you don't know the name of the property you want
to find?  I don't understand that at all.

I'm not really sure what good having a list of the properties within a
node is either, outside of using it for debugging.

josh

___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev