All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ryan Mallon <ryan-7Wk5F4Od5/oYd5yxfr4S2w@public.gmane.org>
To: Thomas Chou <thomas-SDxUXYEhEBiCuPEqFHbRBg@public.gmane.org>
Cc: nios2-dev-1eJk0qcHJCcaeqlQEoCUNoJY59XmG8rH@public.gmane.org,
	David Brownell
	<dbrownell-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>,
	devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
Subject: Re: [PATCH v9] spi: New driver for Altera SPI
Date: Tue, 15 Feb 2011 22:12:54 +1300	[thread overview]
Message-ID: <4D5A4396.9080003@bluewatersys.com> (raw)
In-Reply-To: <4D5A2591.5090901-SDxUXYEhEBiCuPEqFHbRBg@public.gmane.org>

On 15/02/11 20:04, Thomas Chou wrote:
> Dear Ryan,
> 
> On 02/14/2011 10:20 AM, Ryan Mallon wrote:
>> On 02/14/2011 03:10 PM, Thomas Chou wrote:
>>> This patch adds a new SPI driver to support the Altera SOPC Builder
>>> SPI component. It uses the bitbanging library.
>>>
>>> Signed-off-by: Thomas Chou<thomas-SDxUXYEhEBiCuPEqFHbRBg@public.gmane.org>
>>> ---
>>
>>> +struct altera_spi {
>>> +    /* bitbang has to be first */
>>> +    struct spi_bitbang bitbang;
>>
>> Is this still true? I had a quick look and can't see anything which
>> relies on spi_bitbang being the first entry. Things like this should be
>> using container_of so that position in the struct is irrelevant.
>>
>> ~Ryan
>>
> 
> Yes, sadly true. This is due to the implementation of the bitbanging
> library, spi_bitbang.c, which assumes the struct spi_bitbang is the
> first of drvdata. Though it could be changed in the future (beyond this
> little driver), every bitbanging library user has to follow this for now.

Hmm, I see how it works now. Shouldn't the conversion be done like this:

  struct spi_bitbang *bitbang = spi_master_get_devdata(master);
  struct altera_spi *altera = container_of(bitbang,
				 struct altera_spi, bitbang);

Which doesn't require the bitbang field to be the first in the struct
and makes it more clear what is actually going on. The above could be
wrapped into a to_altera_spi macro.

~Ryan

WARNING: multiple messages have this Message-ID (diff)
From: Ryan Mallon <ryan@bluewatersys.com>
To: Thomas Chou <thomas@wytron.com.tw>
Cc: David Brownell <dbrownell@users.sourceforge.net>,
	Grant Likely <grant.likely@secretlab.ca>,
	linux-kernel@vger.kernel.org, nios2-dev@sopc.et.ntust.edu.tw,
	devicetree-discuss@lists.ozlabs.org,
	spi-devel-general@lists.sourceforge.net
Subject: Re: [PATCH v9] spi: New driver for Altera SPI
Date: Tue, 15 Feb 2011 22:12:54 +1300	[thread overview]
Message-ID: <4D5A4396.9080003@bluewatersys.com> (raw)
In-Reply-To: <4D5A2591.5090901@wytron.com.tw>

On 15/02/11 20:04, Thomas Chou wrote:
> Dear Ryan,
> 
> On 02/14/2011 10:20 AM, Ryan Mallon wrote:
>> On 02/14/2011 03:10 PM, Thomas Chou wrote:
>>> This patch adds a new SPI driver to support the Altera SOPC Builder
>>> SPI component. It uses the bitbanging library.
>>>
>>> Signed-off-by: Thomas Chou<thomas@wytron.com.tw>
>>> ---
>>
>>> +struct altera_spi {
>>> +    /* bitbang has to be first */
>>> +    struct spi_bitbang bitbang;
>>
>> Is this still true? I had a quick look and can't see anything which
>> relies on spi_bitbang being the first entry. Things like this should be
>> using container_of so that position in the struct is irrelevant.
>>
>> ~Ryan
>>
> 
> Yes, sadly true. This is due to the implementation of the bitbanging
> library, spi_bitbang.c, which assumes the struct spi_bitbang is the
> first of drvdata. Though it could be changed in the future (beyond this
> little driver), every bitbanging library user has to follow this for now.

Hmm, I see how it works now. Shouldn't the conversion be done like this:

  struct spi_bitbang *bitbang = spi_master_get_devdata(master);
  struct altera_spi *altera = container_of(bitbang,
				 struct altera_spi, bitbang);

Which doesn't require the bitbang field to be the first in the struct
and makes it more clear what is actually going on. The above could be
wrapped into a to_altera_spi macro.

~Ryan



  parent reply	other threads:[~2011-02-15  9:12 UTC|newest]

Thread overview: 45+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-10-08  6:03 [PATCH] spi: New driver for Altera SPI Thomas Chou
     [not found] ` <1254981838-20584-1-git-send-email-thomas-SDxUXYEhEBiCuPEqFHbRBg@public.gmane.org>
2011-01-17  5:46   ` [PATCH v2] " Thomas Chou
2011-01-17  5:46     ` Thomas Chou
     [not found]     ` <1295243200-28230-1-git-send-email-thomas-SDxUXYEhEBiCuPEqFHbRBg@public.gmane.org>
2011-01-17  5:59       ` Stephen Rothwell
2011-01-17  5:59         ` Stephen Rothwell
     [not found]         ` <20110117165958.f89e8220.sfr-3FnU+UHB4dNDw9hX6IcOSA@public.gmane.org>
2011-01-17  6:22           ` Thomas Chou
2011-01-17  6:22             ` Thomas Chou
     [not found]             ` <4D33E00E.5050802-SDxUXYEhEBiCuPEqFHbRBg@public.gmane.org>
2011-01-17  6:45               ` Grant Likely
2011-01-17  6:45                 ` Grant Likely
     [not found]                 ` <AANLkTi=D4Rcxbei2oo+EHc6X1O-2Oo+VWHAasK_JLj5W-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2011-01-17  7:04                   ` [PATCH v3] " Thomas Chou
2011-01-17  7:04                     ` Thomas Chou
     [not found]                     ` <1295247869-4968-1-git-send-email-thomas-SDxUXYEhEBiCuPEqFHbRBg@public.gmane.org>
2011-01-17  7:27                       ` Sinan Akman
2011-01-17  7:27                         ` Sinan Akman
     [not found]                         ` <4D33EF7C.7030005-w0xpxkV3uqlBDgjK7y7TUQ@public.gmane.org>
2011-01-18  1:33                           ` Thomas Chou
2011-01-18  1:33                             ` Thomas Chou
2011-01-19  1:36                           ` Thomas Chou
2011-01-19  1:36                             ` Thomas Chou
2011-01-17  6:56       ` [PATCH v2] " Grant Likely
2011-01-17  6:56         ` Grant Likely
     [not found]         ` <AANLkTimCvYai7mvrrHP9=EXB4L+yw3W2ad-7DU_iEzLy-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2011-01-17  7:13           ` [PATCH v4] " Thomas Chou
2011-01-17  7:13             ` Thomas Chou
     [not found]             ` <1295248436-5049-1-git-send-email-thomas-SDxUXYEhEBiCuPEqFHbRBg@public.gmane.org>
2011-01-17  7:42               ` Grant Likely
2011-01-17  7:42                 ` Grant Likely
     [not found]                 ` <AANLkTinXduw54sKNa8r9sLm_Q8YjvpqAseYPhRshbNpE-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2011-01-24  6:38                   ` [PATCH v5] " Thomas Chou
2011-01-24  6:38                     ` Thomas Chou
2011-02-03 10:02                     ` [PATCH v6] " Thomas Chou
     [not found]                       ` <1296727326-2581-1-git-send-email-thomas-SDxUXYEhEBiCuPEqFHbRBg@public.gmane.org>
2011-02-03 17:34                         ` Grant Likely
2011-02-03 17:34                           ` Grant Likely
2011-02-05 13:08                           ` Thomas Chou
2011-02-05 14:02                           ` [PATCH v7] " Thomas Chou
2011-02-06 20:23                             ` Peter Korsgaard
     [not found]                               ` <87aai8zzd1.fsf-uXGAPMMVk8amE9MCos8gUmSdvHPH+/yF@public.gmane.org>
2011-02-08  2:43                                 ` Thomas Chou
2011-02-08  2:43                                   ` Thomas Chou
2011-02-08  5:21                               ` [PATCH v8] " Thomas Chou
     [not found]                                 ` <1297142509-20158-1-git-send-email-thomas-SDxUXYEhEBiCuPEqFHbRBg@public.gmane.org>
2011-02-14  2:10                                   ` [PATCH v9] " Thomas Chou
2011-02-14  2:10                                     ` Thomas Chou
2011-02-14  2:20                                     ` Ryan Mallon
     [not found]                                       ` <4D58917E.9050408-7Wk5F4Od5/oYd5yxfr4S2w@public.gmane.org>
2011-02-15  7:04                                         ` Thomas Chou
2011-02-15  7:04                                           ` Thomas Chou
     [not found]                                           ` <4D5A2591.5090901-SDxUXYEhEBiCuPEqFHbRBg@public.gmane.org>
2011-02-15  9:12                                             ` Ryan Mallon [this message]
2011-02-15  9:12                                               ` Ryan Mallon
2011-02-15 19:42                                           ` Grant Likely
2011-02-15 21:58                                             ` Ryan Mallon
     [not found]                                     ` <1297649443-11491-1-git-send-email-thomas-SDxUXYEhEBiCuPEqFHbRBg@public.gmane.org>
2011-02-16  2:47                                       ` Grant Likely
2011-02-16  2:47                                         ` 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=4D5A4396.9080003@bluewatersys.com \
    --to=ryan-7wk5f4od5/oyd5yxfr4s2w@public.gmane.org \
    --cc=dbrownell-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org \
    --cc=devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org \
    --cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=nios2-dev-1eJk0qcHJCcaeqlQEoCUNoJY59XmG8rH@public.gmane.org \
    --cc=spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org \
    --cc=thomas-SDxUXYEhEBiCuPEqFHbRBg@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.