public inbox for linux-i2c@vger.kernel.org
 help / color / mirror / Atom feed
From: Ben Dooks <ben-linux-elnMNo+KYs3YtjvyW6yDsg@public.gmane.org>
To: Timur Tabi <timur-KZfg59tc24xl57MIdRCFDg@public.gmane.org>
Cc: linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: Dynamically-allocated i2c_device_id vs MODULE_DEVICE_TABLE
Date: Sat, 24 Jan 2009 16:50:40 +0000	[thread overview]
Message-ID: <20090124165040.GL8032@fluff.org.uk> (raw)
In-Reply-To: <497A3097.1030808-KZfg59tc24xl57MIdRCFDg@public.gmane.org>

On Fri, Jan 23, 2009 at 03:03:19PM -0600, Timur Tabi wrote:
> I currently have this in my code:
> 
> static const struct i2c_device_id cs4270_id[] = {
> 	{"cs4270", 0},
> 	{}
> };
> MODULE_DEVICE_TABLE(i2c, cs4270_id);
> 
> static struct i2c_driver cs4270_i2c_driver = {
> 	.driver = {
> 		.name = "cs4270",
> 		.owner = THIS_MODULE,
> 	},
> 	.id_table = cs4270_id,
> 	.probe = cs4270_i2c_probe,
> 	.remove = cs4270_i2c_remove,
> };
> 
> ret = i2c_add_driver(&cs4270_i2c_driver);
> 
> I would like to use the i2c_device_id.driver_data variable to pass private data
> to my cs4270_i2c_probe() function.  So it will look like this:
> 
> 	socdev = kmalloc(...);
> 	c24270_id.driver_data = socdev;
> 	i2c_add_driver(&cs4270_i2c_driver);

you seem to have managed to short-circuit part of the device
creation process. You do not need to pass the data via the device
driver, you should pass it when creating the device. 

If you look at i2c_board_info which can be passed into i2c_new_device
or similar functions, there is a platform_data field you can fill out
and this is passed in to your probe routine in the i2c device.

-- 
Ben (ben-elnMNo+KYs3YtjvyW6yDsg@public.gmane.org, http://www.fluff.org/)

  'a smiley only costs 4 bytes'

  parent reply	other threads:[~2009-01-24 16:50 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-01-23 21:03 Dynamically-allocated i2c_device_id vs MODULE_DEVICE_TABLE Timur Tabi
     [not found] ` <497A3097.1030808-KZfg59tc24xl57MIdRCFDg@public.gmane.org>
2009-01-23 22:26   ` Jon Smirl
2009-01-24  1:28   ` Mark Brown
     [not found]     ` <20090124012817.GA31775-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
2009-01-24  2:23       ` Timur Tabi
     [not found]         ` <497A7BA4.2080908-KZfg59tc24xl57MIdRCFDg@public.gmane.org>
2009-01-24 11:39           ` Mark Brown
2009-01-24 16:50   ` Ben Dooks [this message]
     [not found]     ` <20090124165040.GL8032-elnMNo+KYs3pIgCt6eIbzw@public.gmane.org>
2009-01-26 18:06       ` Timur Tabi
     [not found]         ` <ed82fe3e0901261006u2223ccb3n5d7b3be9a85df7c7-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2009-01-26 19:16           ` Jon Smirl

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=20090124165040.GL8032@fluff.org.uk \
    --to=ben-linux-elnmno+kys3ytjvyw6ydsg@public.gmane.org \
    --cc=linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=timur-KZfg59tc24xl57MIdRCFDg@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