From: Grant Likely <grant.likely@secretlab.ca>
To: Magnus Damm <magnus.damm@gmail.com>
Cc: spi-devel-general@lists.sourceforge.net,
dbrownell@users.sourceforge.net, linux-kernel@vger.kernel.org,
akpm@linux-foundation.org
Subject: Re: [PATCH] spi: Allow using spi_bitbang_setup() with custom txrx_bufs()
Date: Wed, 25 Nov 2009 15:15:54 -0700 [thread overview]
Message-ID: <fa686aa40911251415q624f3610n92cbc20437b12bf6@mail.gmail.com> (raw)
In-Reply-To: <20091125082603.25618.57438.sendpatchset@rxone.opensource.se>
On Wed, Nov 25, 2009 at 1:26 AM, Magnus Damm <magnus.damm@gmail.com> wrote:
> From: Magnus Damm <damm@opensource.se>
>
> This patch modifies the shared spi bitbanging code
> to allow using spi_bitbang_setup() even though the
> txrx_word[] callbacks are unset. Useful for drivers
> that want to make use of spi_bitbang_setup() but
> have their own txrx_bufs() callback.
>
> While at it, drop the MSIOF driver workaround.
>
> Signed-off-by: Magnus Damm <damm@opensource.se>
> ---
>
> Depends on the MSIOF driver.
>
> drivers/spi/spi_bitbang.c | 25 ++++++++++++++-----------
> drivers/spi/spi_sh_msiof.c | 11 -----------
> 2 files changed, 14 insertions(+), 22 deletions(-)
>
> --- 0001/drivers/spi/spi_bitbang.c
> +++ work/drivers/spi/spi_bitbang.c 2009-11-25 15:30:45.000000000 +0900
> @@ -176,6 +176,14 @@ int spi_bitbang_setup_transfer(struct sp
> }
> EXPORT_SYMBOL_GPL(spi_bitbang_setup_transfer);
>
> +static int spi_bitbang_bufs(struct spi_device *spi, struct spi_transfer *t)
> +{
> + struct spi_bitbang_cs *cs = spi->controller_state;
> + unsigned nsecs = cs->nsecs;
> +
> + return cs->txrx_bufs(spi, cs->txrx_word, nsecs, t);
> +}
> +
> /**
> * spi_bitbang_setup - default setup for per-word I/O loops
> */
> @@ -183,6 +191,7 @@ int spi_bitbang_setup(struct spi_device
> {
> struct spi_bitbang_cs *cs = spi->controller_state;
> struct spi_bitbang *bitbang;
> + int mode_mask = SPI_CPOL | SPI_CPHA;
> int retval;
> unsigned long flags;
>
> @@ -196,9 +205,11 @@ int spi_bitbang_setup(struct spi_device
> }
>
> /* per-word shift register access, in hardware or bitbanging */
> - cs->txrx_word = bitbang->txrx_word[spi->mode & (SPI_CPOL|SPI_CPHA)];
> - if (!cs->txrx_word)
> - return -EINVAL;
> + if (bitbang->txrx_bufs == spi_bitbang_bufs) {
> + cs->txrx_word = bitbang->txrx_word[spi->mode & mode_mask];
> + if (!cs->txrx_word)
> + return -EINVAL;
> + }
Hmmm... this smells like an ugly hack to me. It seems to me that if
some bitbang backend drivers don't want this code, then it should be
encoded into a callback so it can be overridden. Thoughts.
g.
--
Grant Likely, B.Sc., P.Eng.
Secret Lab Technologies Ltd.
next prev parent reply other threads:[~2009-11-25 22:15 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-11-25 8:26 [PATCH] spi: Allow using spi_bitbang_setup() with custom txrx_bufs() Magnus Damm
2009-11-25 22:15 ` Grant Likely [this message]
2009-11-26 6:47 ` Magnus Damm
2009-11-26 7:21 ` Grant Likely
2009-11-26 7:50 ` Magnus Damm
2009-11-26 14:45 ` Grant Likely
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=fa686aa40911251415q624f3610n92cbc20437b12bf6@mail.gmail.com \
--to=grant.likely@secretlab.ca \
--cc=akpm@linux-foundation.org \
--cc=dbrownell@users.sourceforge.net \
--cc=linux-kernel@vger.kernel.org \
--cc=magnus.damm@gmail.com \
--cc=spi-devel-general@lists.sourceforge.net \
/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).