linux-i2c.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Laurent Pinchart <laurent.pinchart-ryLnwIuWjnjg/C1BVhZhaw@public.gmane.org>
To: Frank Bormann <fbormann-/E1597aS9LQAvxtiuMwx3w@public.gmane.org>
Cc: Ben Dooks <ben.dooks-4yDnlxn2s6sWdaTGBSpHTA@public.gmane.org>,
	Linux I2C List
	<linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>
Subject: Re: platform_data in i2c device drivers
Date: Fri, 21 Mar 2014 17:01:20 +0100	[thread overview]
Message-ID: <3083300.Xj9oJdUK5O@avalon> (raw)
In-Reply-To: <532C60EC.3060405-/E1597aS9LQAvxtiuMwx3w@public.gmane.org>

Hi Frank,

On Friday 21 March 2014 11:55:24 Frank Bormann wrote:
> Hi Laurent,
> 
> Thank you again for explaining. One last question if that's okay.
> 
> If I have i2c_board_info being passed in to the probe function through the
> platform_data pointer and I also have the same, similar or maybe even
> conflicting configuration information in the DTB, is there any of the two
> that is supposed to take precedence or should that be an error case?

That shouldn't happen (except in very special cases using OF_DEV_AUXDATA, but 
you really should think twice before going that way). If the I2C device is 
instantiated in board code with i2c_board_info then there will be no DT node 
corresponding to the device (client->dev.of_node will be NULL). If the device 
is instead instantiated from DT there will be no platform data (client-
>dev.platform_data will be NULL).

> On 20/03/14 01:51 PM, Laurent Pinchart wrote:
> > On Thursday 20 March 2014 13:16:35 Frank Bormann wrote:
> >> Hi Ben,
> >> 
> >>> I think client->dev should be avoided if at-all possible. Many
> >>> drivers keep their own local copy of platform data or the pointer
> >>> to it in their driver private information.
> >> 
> >> I was thinking about that. But then again, I'd either have to copy the
> >> client->dev.platform_data pointer over to the private data, if it is
> >> non-null, or I would have to use some variation of
> >> 
> >> pdata = client->dev.platform_data ? client->dev.platform_data : priv_pd;
> >> 
> >> every time I want to access the configuration. Guess, that's not so bad
> >> though.
> > 
> > Most drivers store a pointer to the platform data or a copy of the
> > platform data in a per-device driver private structure. They populate that
> > pointer or copy from the platform data pointer (in the legacy case) or
> > from the device tree content. Outside of the probe function the driver
> > thus only accesses its private pointer or copy.

-- 
Regards,

Laurent Pinchart

  parent reply	other threads:[~2014-03-21 16:01 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-03-19 22:32 platform_data in i2c device drivers Frank Bormann
     [not found] ` <532A1B12.8080400-/E1597aS9LQAvxtiuMwx3w@public.gmane.org>
2014-03-20  0:10   ` Laurent Pinchart
2014-03-20 16:12     ` Frank Bormann
     [not found]       ` <532B1367.8050906-/E1597aS9LQAvxtiuMwx3w@public.gmane.org>
2014-03-20 16:25         ` Ben Dooks
     [not found]           ` <532B1689.3080202-4yDnlxn2s6sWdaTGBSpHTA@public.gmane.org>
2014-03-20 17:16             ` Frank Bormann
     [not found]               ` <532B2273.8040004-/E1597aS9LQAvxtiuMwx3w@public.gmane.org>
2014-03-20 17:51                 ` Laurent Pinchart
2014-03-21 15:55                   ` Frank Bormann
     [not found]                     ` <532C60EC.3060405-/E1597aS9LQAvxtiuMwx3w@public.gmane.org>
2014-03-21 16:01                       ` Laurent Pinchart [this message]
     [not found]     ` <534FF708.7040409@yahoo.com>
     [not found]       ` <534FF708.7040409-/E1597aS9LQAvxtiuMwx3w@public.gmane.org>
2014-04-17 15:46         ` [PATCH] i2c-mux-pca954x: allow downstream bus numbers to be specified in the dts Laurent Pinchart
2014-04-17 18:00           ` Laxman Dewangan
     [not found]             ` <535016B5.7060006-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2014-04-22 21:46               ` Frank Bormann
     [not found]           ` <53501564.1090607@yahoo.com>
     [not found]             ` <53501564.1090607-/E1597aS9LQAvxtiuMwx3w@public.gmane.org>
2014-04-17 20:15               ` Laurent Pinchart
     [not found]                 ` <CAE6_GsvJpajY==6MJExo3T7FrVF_LNGcoozq0N5KEBho9y5NWw@mail.gmail.com>
     [not found]                   ` <CAE6_GsvJpajY==6MJExo3T7FrVF_LNGcoozq0N5KEBho9y5NWw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-04-17 20:42                     ` Laurent Pinchart

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=3083300.Xj9oJdUK5O@avalon \
    --to=laurent.pinchart-rylnwiuwjnjg/c1bvhzhaw@public.gmane.org \
    --cc=ben.dooks-4yDnlxn2s6sWdaTGBSpHTA@public.gmane.org \
    --cc=fbormann-/E1597aS9LQAvxtiuMwx3w@public.gmane.org \
    --cc=linux-i2c-u79uwXL29TY76Z2rM5mHXA@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;
as well as URLs for NNTP newsgroup(s).