linux-spi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
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: Thu, 26 Nov 2009 07:45:51 -0700	[thread overview]
Message-ID: <fa686aa40911260645i50bf0c35g93b4146952a5f82e@mail.gmail.com> (raw)
In-Reply-To: <aec7e5c30911252350r717393e8sd476fa7e3aeb301f@mail.gmail.com>

On Thu, Nov 26, 2009 at 12:50 AM, Magnus Damm <magnus.damm@gmail.com> wrote:
> On Thu, Nov 26, 2009 at 4:21 PM, Grant Likely <grant.likely@secretlab.ca> wrote:
>> On Wed, Nov 25, 2009 at 11:47 PM, Magnus Damm <magnus.damm@gmail.com> wrote:
>>> On Thu, Nov 26, 2009 at 7:15 AM, Grant Likely <grant.likely@secretlab.ca> wrote:
>>>> On Wed, Nov 25, 2009 at 1:26 AM, Magnus Damm <magnus.damm@gmail.com> wrote:
>>>>>        /* 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.
>>
>> This is certainly less ugly.  But with the points brought up in the
>> other thread, I want to have a close look at spi-bitbang before I
>> start applying stuff.  It seems nasty.  Give me a few days.
>
> Sure, I plan on posting a V2 of the MSIOF driver. I plan to keep the
> dummy txrx_word() function for now - this to disconnect the cleanup
> from the driver integration, hope that sounds like a good plan.

Works for me.  Now I just need to find someone with the time to
refactor spi-bitbang.  :-)

g.




-- 
Grant Likely, B.Sc., P.Eng.
Secret Lab Technologies Ltd.

      reply	other threads:[~2009-11-26 14:45 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
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 [this message]

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=fa686aa40911260645i50bf0c35g93b4146952a5f82e@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).