public inbox for linux-i2c@vger.kernel.org
 help / color / mirror / Atom feed
From: Jean Delvare <khali-PUYAD+kWke1g9hUCZPvPmw@public.gmane.org>
To: Shane Dixon <shane.dixon-AIFe0yeh4nAAvxtiuMwx3w@public.gmane.org>
Cc: linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: Moving to new driver model: probe never called
Date: Fri, 1 May 2009 19:51:46 +0200	[thread overview]
Message-ID: <20090501195146.4da8edf5@hyperion.delvare> (raw)
In-Reply-To: <1241193404.31476.6.camel@homestead>

Hi Shane,

On Fri, 01 May 2009 09:56:44 -0600, Shane Dixon wrote:
> I'm trying to port a working driver from the old device driver model to
> the new.  I have a printk in the first line of my probe function, which
> never gets printed after doing a modprobe.  Hooking up a scope shows
> that nothing is sent at all to the device.  Below is the relevant
> snippets of code:
> 
> #define DEVICE_NAME "atpm"
> 
> static struct i2c_device_id atpm_idtable[] = {
>   { DEVICE_NAME, 0 },
>   { }
> };
> MODULE_DEVICE_TABLE(i2c, atpm_idtable);
> 
> static struct i2c_driver atpm_driver =
> {
>     .driver = {
>       .name         = DEVICE_NAME,
>       .owner        = THIS_MODULE,
>     },
>     .probe          = atpm_probe,
>     .remove         = __devexit_p(atpm_remove),
>     .id_table       = atpm_idtable,
>     .detect         = atpm_detect,
>     /* .address_data   = &addr_data */

.detect is ignored without .address_data. From i2c-core.c:

static int i2c_detect(struct i2c_adapter *adapter, struct i2c_driver *driver)
{
	const struct i2c_client_address_data *address_data;
	(...)

	address_data = driver->address_data;
	if (!driver->detect || !address_data)
		return 0;

Additionally, you must define atpm_driver.class, otherwise
atpm_driver.detect will never be called.

> };
> 
> static int __init atpm_init(void)
> {
>   printk(DEVICE_NAME ": adding i2c driver\n");
>   return i2c_add_driver(&atpm_driver);
> }
> 
> static void __exit atpm_exit(void)
> {
>   i2c_del_driver(&atpm_driver);
>   printk(DEVICE_NAME ": deleting i2c driver\n");
> }
> 
> module_init(atpm_init);
> module_exit(atpm_exit);
> 
> Any help would be appreciated.

What is this "atpm" device? Can it be reliably detected? In general it
is better to instantiate I2C devices explicitly, for example through
platform data. Why don't you do that?

-- 
Jean Delvare
http://khali.linux-fr.org/wishlist.html

  reply	other threads:[~2009-05-01 17:51 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-05-01 15:56 Moving to new driver model: probe never called Shane Dixon
2009-05-01 17:51 ` Jean Delvare [this message]
     [not found]   ` <20090501195146.4da8edf5-ig7AzVSIIG7kN2dkZ6Wm7A@public.gmane.org>
2009-05-01 19:14     ` Shane Dixon
2009-05-04 16:10       ` Jean Delvare

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=20090501195146.4da8edf5@hyperion.delvare \
    --to=khali-puyad+kwke1g9huczpvpmw@public.gmane.org \
    --cc=linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=shane.dixon-AIFe0yeh4nAAvxtiuMwx3w@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