From: Jean Delvare <khali-PUYAD+kWke1g9hUCZPvPmw@public.gmane.org>
To: Ben Dooks <ben-linux-elnMNo+KYs3YtjvyW6yDsg@public.gmane.org>
Cc: i2c-GZX6beZjE8VD60Wz+7aTrA@public.gmane.org
Subject: Re: Documentation issue on attaching new style drivers
Date: Tue, 3 Jun 2008 16:35:37 +0200 [thread overview]
Message-ID: <20080603163537.22c69aff@hyperion.delvare> (raw)
In-Reply-To: <20080603103450.GA8391-elnMNo+KYs3pIgCt6eIbzw@public.gmane.org>
Hi Ben,
On Tue, 3 Jun 2008 11:34:50 +0100, Ben Dooks wrote:
> Quoting from Documentation/i2c/writing-clients, the section
> entitled "Standard Driver Model Binding ("New Style")" has
> the following paragraph:
>
> Drivers match devices when i2c_client.driver_name and the driver name are
> the same; this approach is used in several other busses that don't have
> device typing support in the hardware. The driver and module name should
> match, so hotplug/coldplug mechanisms will modprobe the driver.
>
> Having tried this whilst upgrading an old driver in my own
> tree, I found that this does not work, and that you need to
> supply your own idtable for the .id_table entry.
>
> I had a quick look in drivers/i2c/i2c-core.c and it seems
> that the only thing the .match entry i2c_device_match()
> is doing is checking the driver's id_table, as so:
>
> static int i2c_device_match(struct device *dev, struct device_driver *drv)
> {
> struct i2c_client *client = to_i2c_client(dev);
> struct i2c_driver *driver = to_i2c_driver(drv);
>
> /* make legacy i2c drivers bypass driver model probing entirely;
> * such drivers scan each i2c adapter/bus themselves.
> */
> if (!is_newstyle_driver(driver))
> return 0;
>
> /* match on an id table if there is one */
> if (driver->id_table)
> return i2c_match_id(driver->id_table, client) != NULL;
>
> return 0;
> }
>
> Is the documentation wrong, and all drivers need to have an id_table
> in them, or is the i2c-core.c wrong for only checking the id_table
> entries?
The documentation is wrong, or more precisely, it's out-of-date. It was
correct when it was written, but the i2c subsystem was updated since
then and I forgot to update this piece of documentation. Do you feel
like submitting a patch fixing it?
> My suspicion is that everyone is using the id_table as this can be
> passed to the MODULE_DEVICE_TABLE() to allow autoloading of the
> relevant modules? Note, the i2c_probe function will correctly pass
> a NULL ID if there is no id_table present.
The id_table is mandatory. The i2c_device_probe() function can be
simplified now, as it will never be called if driver->id_table is NULL.
I'll send a patch right now, thanks for pointing this out.
--
Jean Delvare
_______________________________________________
i2c mailing list
i2c-GZX6beZjE8VD60Wz+7aTrA@public.gmane.org
http://lists.lm-sensors.org/mailman/listinfo/i2c
prev parent reply other threads:[~2008-06-03 14:35 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-06-03 10:34 Documentation issue on attaching new style drivers Ben Dooks
[not found] ` <20080603103450.GA8391-elnMNo+KYs3pIgCt6eIbzw@public.gmane.org>
2008-06-03 14:35 ` Jean Delvare [this message]
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=20080603163537.22c69aff@hyperion.delvare \
--to=khali-puyad+kwke1g9huczpvpmw@public.gmane.org \
--cc=ben-linux-elnMNo+KYs3YtjvyW6yDsg@public.gmane.org \
--cc=i2c-GZX6beZjE8VD60Wz+7aTrA@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