Skip to contentSkip to conversation

num_chipselect and number of Slaves

DISCUSSION jassi brar 1 participant 1 message Apr 17, 2009 SPI

lore
Share & tools
lore

jassi brar

author
#0 lore raw

Hello,

Nothing serious, just a minor point to bring to your notice.

I came across a minor but confusing discrepancy in the documentation of SPI-API while writing a SPI controller driver.

include/linux/spi/spi.h defines num_chipselect as:- @num_chipselect: chipselects are used to distinguish individual SPI slaves, and are numbered from __zero-to-num_chipselects__.

Whereas drivers/spi/spi.c take them from [0, num_chipselect-1]

Perhaps thats why a couple of drivers fell for it.

drivers/spi/atmel_spi.c writes:-
"if (spi->chip_select > spi->master->num_chipselect)"
instead of
if (spi->chip_select >= spi->master->num_chipselect)

drivers/spi/spi_bfin5xx.c writes:-

    "(chip->chip_select_num <= spi->master->num_chipselect)"
instead of 
    (chip->chip_select_num < spi->master->num_chipselect)

Those concerned might like to make appropriate changes in the logic and documentation.

It's embarrassing to release a patch for such a trivial thing, or shud i? :)

Regards,
Jassi

------------------------------------------------------------------------------
Stay on top of everything new and different, both inside and around Java (TM) technology - register by April 22, and save $200 on the JavaOne (SM) conference, June 2-5, 2009, San Francisco. 300 plus technical and hands-on sessions. Register today. Use priority code J9JMT32. http://p.sf.net/sfu/p