On Sat, Mar 01, 2014 at 12:40:39PM +0100, Martin Sperl wrote: > I am not sure if it might make some bus-drivers more complicated > /inefficient just to support this zero length. For most of them it should be relatively straightforward, especially as we factor things out into the core so that the drivers don't need to implement the delays at all and it's all handled in the core. > For example: the spi-bcm2835.c driver would do the following with a > spi_transfer.len == 0 in the transfer_on method: > * enables SPI and wait for interrupt completion > * the above which will trigger an interrupt > ** in the interrupt we find out that there is nothing to transfer, > so we signal completion to transfer_one, so it may continue. > * the main transfer_one will get woken up > ** it will do a delay_usecs > ** it will handle CS_CHANGE > ** it will disable SPI/reset HW again > So this implementation shows that there is a lot of inefficient > overhead/delay just to trigger a delay... You really ought to be deferring to task context to implement the delays anyway - delaying in interrupt context is rude (though doable for very short delays). I'd have expected that the enable/disable to be bypassable, unless the hardware needs to be reset between transfers this should only be happening when the device goes idle. > I guess other drivers will show similar code-artefacts and > some may even make the implicit assumption it has to be non-zero, > which would break functionality those odd devices. There's lots of stuff that's broken with individual drivers - anything that relies on cs_change is going to break with half the drivers out there. Some of this is legitimate hardware limitations (where the /CS control is out of the control of software) but a lot of it is just bugs due to people open coding things.
Attachment:
signature.asc
Description: Digital signature