Devicetree
 help / color / mirror / Atom feed
From: Grant Likely <grant.likely-s3s/WqlpOiPyB63q8FvJNQ@public.gmane.org>
To: Thomas Abraham <thomas.abraham-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
Cc: devicetree-discuss
	<devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org>
Subject: Re: Question regarding usage of pdev->id and platform_data
Date: Wed, 23 Feb 2011 11:03:16 -0700	[thread overview]
Message-ID: <20110223180316.GI14597@angua.secretlab.ca> (raw)
In-Reply-To: <AANLkTi=AoFEQ685Pup8i7EAs=hLHip0UnhMV+ZHxVAiD-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>

Hi Thomas,

On Wed, Feb 23, 2011 at 10:48:37PM +0530, Thomas Abraham wrote:
> Hi,
> 
> I am adding support for device tree based probe for the s5pv310 serial
> driver for a platform that has 4 instances of the uart port. I have
> few questions on this and appreciate any help for the following
> questions.
> 
> 1. The driver is based on the usage of pdev->id in several parts of
> the driver. But the platform_device created using the
> of_platform_bus_probe function assigns -1 to pdev->id. Is the use of
> pdev->id not advisable or is it okay if the driver assigns a pdev->id
> value during the probe.

No, the driver should *not* write a value to pdev->id at probe time.
Doing so breaks the device model.  Instead, any enumeration that the
driver cares about should be stored in the driver's private data
structure.  I would recommend modifying the driver to copy pdev->id
into its private structure.  If it is -1, then dynamically assign an
id.

> 
> 2. The driver uses pdev->dev.platform_data even after the probe is
> complete. I read in one of the posts from Grant Likely that drivers
> should not assign pdev->dev.platfrom_data.

Correct.

> Is it okay if the driver
> parse the platform data related information from the device node and
> assign it to pdev->dev.platform_data.

No.  The driver *must not* modify or assign platform_data.  That
pointer provides information to the driver, but there are memory
allocation lifecycle issues if it tries to store something there.
(Okay, I it *can* be done if the driver very carefully cleaned up
after itself; but I strongly recommend against it; that isn't what
that pointer is for)  Modifying it also causes issues with drivers
that can accept either platform_data or device tree data.

Instead, the driver should store all data it needs in its private data
structure.  That's exactly why drivers have private data structures.

g.

  parent reply	other threads:[~2011-02-23 18:03 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-02-23 17:18 Question regarding usage of pdev->id and platform_data Thomas Abraham
     [not found] ` <AANLkTi=AoFEQ685Pup8i7EAs=hLHip0UnhMV+ZHxVAiD-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2011-02-23 18:03   ` Grant Likely [this message]
     [not found]     ` <20110223180316.GI14597-MrY2KI0G/OVr83L8+7iqerDks+cytr/Z@public.gmane.org>
2011-02-24 12:13       ` Thomas Abraham
     [not found]         ` <AANLkTikKLJn60_L2r-cyiFLtQVn=WCNBTzPg6vAVwZRV-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2011-03-17 19:19           ` Grant Likely
     [not found]             ` <20110317191938.GB12824-MrY2KI0G/OVr83L8+7iqerDks+cytr/Z@public.gmane.org>
2011-03-21 14:10               ` Thomas Abraham

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=20110223180316.GI14597@angua.secretlab.ca \
    --to=grant.likely-s3s/wqlpoipyb63q8fvjnq@public.gmane.org \
    --cc=devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org \
    --cc=thomas.abraham-QSEj5FYQhm4dnm+yROfE0A@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox