[PATCH] of: Create function for counting number of phandles in a property

Andreas Larsson andreas at gaisler.com
Tue Feb 12 20:18:10 EST 2013


On 2013-02-11 00:58, Grant Likely wrote:
> This patch creates of_count_phandle_with_args(), a new function for
> counting the number of phandle+argument tuples in a given property. This
> is better than the existing method of parsing each phandle individually
> until parsing fails which is a horribly slow way to do the count.
>
> It also converts of_gpio_named_count() to use the new function instead
> of using the above described horrible method.
>
> This also requires the return value of of_gpio_count() &
> of_gpio_named_count() from 'unsigned int' to 'int' so that it can return
> an error code. All the users of that function are fixed up to correctly
> handle a negative return value.

One more thing: In of_spi_register_master() in drivers/spi.c the error 
code is put in the unsigned variable nb, leading to a huge nb and 
master->num_chipselect with following problems when of_gpio_named_count 
returns an error code.

Cheers,
Andreas Larsson



More information about the devicetree-discuss mailing list