[PATCH] spi/spi-altera: Allow to explicitely override bus number via dts

Grant Likely grant.likely at secretlab.ca
Thu Feb 2 04:57:51 EST 2012


On Wed, Feb 1, 2012 at 8:52 AM, Frederic LAMBERT <frdrc66 at gmail.com> wrote:
> 2012/2/1 Mark Brown <broonie at sirena.org.uk>
>
>>
>> Well, something that walks all block devices on Linux is very
>> straightforward...  It sounds like you just want logic along the lines
>> of "find a block device and offer the option of overriding by providing
>> a specific path for use with a file", is that about right?
>>
>
> Well, yes, excepted that the file *is* equivalent to a block device for my
> piece of code!

The answer here is to use the data provided by the kernel to find the
correct device.  Hard coding bus numbers (or any other globally
visible number space for that matter) has all kinds of problems and it
is by design that spi bus drivers are not allowed to choose a bus
number when they are created from DT data.

Instead, your code should either be using udev, or doing the same
thing that udev does to find a specific hardware device.  The uevent
attribute in devices that appear under /dev/bus/spi/devices should be
used to compare with the full device tree path.  I've just written a
patch that should give you the information that you need and I'll cc:
you when I post it.  I'll try to get it merged for v3.4.  This
approach will allow you to find the correct device in a reliable way
that won't be affected by bus numbering changes.

g.


More information about the devicetree-discuss mailing list