Re: [PATCH 5/6] spi: bcm2835: add polling mode for transfers below 30us

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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


[Index of Archives]     [Linux Kernel]     [Linux ARM (vger)]     [Linux ARM MSM]     [Linux Omap]     [Linux Arm]     [Linux Tegra]     [Fedora ARM]     [Linux for Samsung SOC]     [eCos]     [Linux Fastboot]     [Gcc Help]     [Git]     [DCCP]     [IETF Announce]     [Security]     [Linux MIPS]     [Yosemite Campsites]

  Powered by Linux