public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Igor Grinberg <grinberg@compulab.co.il>
To: Grant Likely <grant.likely@secretlab.ca>
Cc: Christian Gmeiner <christian.gmeiner@gmail.com>,
	linux-kernel@vger.kernel.org
Subject: Re: pca953x: support working w/o platform data
Date: Mon, 04 Jul 2011 10:45:03 +0300	[thread overview]
Message-ID: <4E116F7F.5010508@compulab.co.il> (raw)
In-Reply-To: <20110704064347.GL15152@ponder.secretlab.ca>

On 07/04/11 09:43, Grant Likely wrote:

> On Fri, Jul 01, 2011 at 08:17:44PM +0300, Igor Grinberg wrote:
>> On 07/01/11 14:33, Christian Gmeiner wrote:
>>
>>> Provide defaults for pca953x, so the driver can be used w/o
>>> providing platform data.
>> Wouldn't it be better to provide a default pdata structure inside the driver
>> and use it in case no pdata supplied, so you will not have to patch the
>> driver all around checking each time if pdata is valid?
>
> I would agree.  However, you will need to adjust the structure of the
> driver somewhat to do so.  Once a device is registered, the data
> pointed to by platform_device->dev.platform_data must be treated as
> immutable by the driver, otherwise driver unbind/rebind can become
> horribly broken.

The driver already copies several field from pdata to the chip structure.
Also, chip->dyn_pdata can be used for this purpose, but instead of
allocating it dynamically, it just can be  a part of the chip structure.

> I often solve this by keeping a full copy of the pdata structure in
> the driver's private data structure, and always referencing the 'safe'
> local copy instead of dereferencing dev->platform_data every time.

If this is done and the chip structure will contain all the information
needed (either flat, or in some kind of dyn_pdata), then indeed there
will be no need to access the pdata anymore.
Also, there will be no need to allocate pdata in pca953x_get_alt_pdata()
function.
I think this would be the most clean and safe way.

-- 
Regards,
Igor.


  reply	other threads:[~2011-07-04  7:45 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-07-01 11:33 pca953x: support working w/o platform data Christian Gmeiner
2011-07-01 17:17 ` Igor Grinberg
2011-07-04  6:43   ` Grant Likely
2011-07-04  7:45     ` Igor Grinberg [this message]
2011-07-04 15:41       ` 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=4E116F7F.5010508@compulab.co.il \
    --to=grinberg@compulab.co.il \
    --cc=christian.gmeiner@gmail.com \
    --cc=grant.likely@secretlab.ca \
    --cc=linux-kernel@vger.kernel.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