From: Mark Brown <broonie-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
To: Martin Sperl <kernel-TqfNSX0MhmxHKSADF0wUEw@public.gmane.org>
Cc: Stephen Warren <swarren-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>,
lee-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org,
linux-spi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-rpi-kernel
<linux-rpi-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org>
Subject: Re: [PATCH 5/6] spi: bcm2835: add polling mode for transfers below 30us
Date: Sun, 29 Mar 2015 21:27:27 -0700 [thread overview]
Message-ID: <20150330042727.GC1568@sirena.org.uk> (raw)
In-Reply-To: <808DC596-35BB-4A08-8CF4-DFAB6294636E-TqfNSX0MhmxHKSADF0wUEw@public.gmane.org>
[-- Attachment #1: Type: text/plain, Size: 910 bytes --]
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 #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]
next prev parent reply other threads:[~2015-03-30 4:27 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-29 14:03 [PATCH 5/6] spi: bcm2835: add polling mode for transfers below 30us Martin Sperl
[not found] ` <808DC596-35BB-4A08-8CF4-DFAB6294636E-TqfNSX0MhmxHKSADF0wUEw@public.gmane.org>
2015-03-30 4:27 ` Mark Brown [this message]
2015-03-31 3:28 ` Stephen Warren
[not found] ` <551A1466.2020706-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>
2015-03-31 6:00 ` Martin Sperl
[not found] ` <E15DA84C-4EF9-432A-ADA9-81789EAE379F-TqfNSX0MhmxHKSADF0wUEw@public.gmane.org>
2015-04-01 15:14 ` Stephen Warren
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20150330042727.GC1568@sirena.org.uk \
--to=broonie-dgejt+ai2ygdnm+yrofe0a@public.gmane.org \
--cc=kernel-TqfNSX0MhmxHKSADF0wUEw@public.gmane.org \
--cc=lee-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
--cc=linux-rpi-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \
--cc=linux-spi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=swarren-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).