[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <aec7e5c30911252247i344f5bf3pb0240b9c23878bf5@mail.gmail.com>
Date: Thu, 26 Nov 2009 15:47:17 +0900
From: Magnus Damm <magnus.damm@...il.com>
To: Grant Likely <grant.likely@...retlab.ca>
Cc: spi-devel-general@...ts.sourceforge.net,
dbrownell@...rs.sourceforge.net, linux-kernel@...r.kernel.org,
akpm@...ux-foundation.org
Subject: Re: [PATCH] spi: Allow using spi_bitbang_setup() with custom
txrx_bufs()
Hi Grant,
On Thu, Nov 26, 2009 at 7:15 AM, Grant Likely <grant.likely@...retlab.ca> wrote:
> On Wed, Nov 25, 2009 at 1:26 AM, Magnus Damm <magnus.damm@...il.com> wrote:
>> 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.
>> @@ -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.
Yeah, it's far from clean. I want to make use of spi_bitbang_setup()
in my MSIOF driver, but I want to avoid dummy txtx_word[] callbacks
that will be unused since i'm using a driver specific
bitbang->txrx_bufs function.
I guess the attached patch is slightly cleaner? I like the idea of
letting bitbang drivers use shared code for
spi_bitbang_setup()/spi_bitbang_cleanup() with their private
setup_transfer() function which in turn calls
spi_bitbang_setup_transfer(). My impression is that there's quite a
bit of duplicated setup()/cleanup() code.
/ magnus
Download attachment "linux-2.6.33-pre-spi-word-mode-setup-20091126.patch" of type "application/octet-stream" (3503 bytes)
Powered by blists - more mailing lists