linux-i2c.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Robert Dolca <robert.dolca-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: Mika Westerberg
	<mika.westerberg-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
Cc: Robert Dolca
	<robert.dolca-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>,
	linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-acpi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	"linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org"
	<linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
	Wolfram Sang <wsa-z923LK4zBo2bacvFa/9K2g@public.gmane.org>,
	"Rafael J. Wysocki" <rjw-LthD3rsA81gm4RdzfppkhA@public.gmane.org>,
	Len Brown <lenb-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>,
	Daniel Baluta
	<daniel.baluta-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
Subject: Re: [PATCH RFC] i2c: Use ID table to detect ACPI I2C devices
Date: Wed, 20 May 2015 13:49:02 +0300	[thread overview]
Message-ID: <CAFPB+YcggLY9vwtYREX_YVVJFrTYHTQYnBtvMcicvLgo5MX-+A@mail.gmail.com> (raw)
In-Reply-To: <20150520094829.GS1490-3PARRvDOhMZrdx17CPfAsdBPR1lH4CV8@public.gmane.org>

On Wed, May 20, 2015 at 12:48 PM, Mika Westerberg wrote:
> On Wed, May 20, 2015 at 12:39:22PM +0300, Robert Dolca wrote:
>> Currently, if the name used for DT (in dts) matches one of the names
>> specified in the id table you will have a match. Isn't that an
>> intended behavior?
>
> I thought one needs to put IDs to the driver .of_match_table. This is
> also what i2c_device_match() is expecting, if I read it right.

If you put the DT id in of_match_table it will match here:

i2c_device_match
        /* Attempt an OF style match */
        if (of_driver_match_device(dev, drv))
                return 1;

If you don't specify of_match_table and you put the same ID in
i2c_device_id table it wil match here:

i2c_device_match
        driver = to_i2c_driver(drv);
        /* match on an id table if there is one */
        if (driver->id_table)
                return i2c_match_id(driver->id_table, client) != NULL;

This is happening because the name from dts is used for client->name.
i2c_match_id does the matching based on the client name.

> BTW, how modules are supposed to be matched if we allow putting ACPI
> identifiers to i2c_device_id table?

My aproach was like this: if the driver specifies .acpi_match table it
will work like before.

i2c_device_match
        /* Then ACPI style match */
        if (acpi_driver_match_device(dev, drv))
                return 1;

If the driver does not specify .acpi_match table the i2c core will
atempt to match against the  i2c_match_id table (the same way it does
for DT). In the ACPI case the client->name has that :nn suffix and
what the patch does is to ignore that when i2c_match_id is called.

i2c_device_match
        driver = to_i2c_driver(drv);
        /* match on an id table if there is one */
        if (driver->id_table)
                return i2c_match_id(driver->id_table, client) != NULL;

The final goal is to simplify the driver and remove redundant code.

Robert

  parent reply	other threads:[~2015-05-20 10:49 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-19 14:03 [PATCH RFC] i2c: Use ID table to detect ACPI I2C devices Robert Dolca
2015-05-19 23:35 ` Rafael J. Wysocki
2015-05-20  7:47 ` Mika Westerberg
2015-05-20  9:39   ` Robert Dolca
2015-05-20  9:48     ` Mika Westerberg
     [not found]       ` <20150520094829.GS1490-3PARRvDOhMZrdx17CPfAsdBPR1lH4CV8@public.gmane.org>
2015-05-20 10:49         ` Robert Dolca [this message]
     [not found]           ` <CAFPB+YcggLY9vwtYREX_YVVJFrTYHTQYnBtvMcicvLgo5MX-+A-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-05-20 10:57             ` Mika Westerberg
     [not found]               ` <20150520105753.GT1490-3PARRvDOhMZrdx17CPfAsdBPR1lH4CV8@public.gmane.org>
2015-05-20 13:07                 ` Robert Dolca
     [not found]                   ` <CAFPB+Ydw4Ywo4dt5NB-Aed6gtt89h2kMucXtgJa42vwommZerw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-05-20 13:57                     ` Mika Westerberg
2015-05-20 21:32                       ` Robert Dolca

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=CAFPB+YcggLY9vwtYREX_YVVJFrTYHTQYnBtvMcicvLgo5MX-+A@mail.gmail.com \
    --to=robert.dolca-re5jqeeqqe8avxtiumwx3w@public.gmane.org \
    --cc=daniel.baluta-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org \
    --cc=lenb-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
    --cc=linux-acpi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=mika.westerberg-VuQAYsv1563Yd54FQh9/CA@public.gmane.org \
    --cc=rjw-LthD3rsA81gm4RdzfppkhA@public.gmane.org \
    --cc=robert.dolca-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org \
    --cc=wsa-z923LK4zBo2bacvFa/9K2g@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).