On Sun, Mar 29, 2015 at 04:03:27PM +0200, Martin Sperl wrote:

> +     /* check if we shall run in polling mode */
> +     xfer_time_us = tfr->len * 9 * 1000000 / spi_used_hz;
> +     if (xfer_time_us <= BCM2835_SPI_POLLING_LIMIT_US) {


> +             /* Transfer complete - reset SPI HW */
> +             bcm2835_spi_reset_hw(master);
> +             /* and return without waiting for completion */
> +             return 0;
> +     }

The logic here is fine but it's more common to construct these things by
having separate functions for the different modes of operation.  This
makes the code more straightforward since it's clear that there are
alternative branches being taken which isn't so obvious here as the
polling case is an else within the main transfer function.  You end up
with


        if (polling)
                driver_polling_transfer()
        else if (interrupt)
                driver_interrupt_transfer()
        else
                driver_dma_transfer()

or whatever at the point where the flows branch.

Attachment: signature.asc
Description: Digital signature

Reply via email to