devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Rob Herring <robherring2-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: Stephen Warren <swarren-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
Cc: Mark Brown
	<broonie-yzvPICuk2AATkU/dhu1WVueM+bqZidxxQQ4Iyu8u01E@public.gmane.org>,
	Liam Girdwood <lrg-l0cyMroinI0@public.gmane.org>,
	John Bonesio <bones-s3s/WqlpOiPyB63q8FvJNQ@public.gmane.org>,
	"alsa-devel-K7yf7f+aM1XWsZ/bQMPhNw@public.gmane.org"
	<alsa-devel-K7yf7f+aM1XWsZ/bQMPhNw@public.gmane.org>,
	"linux-tegra-u79uwXL29TY76Z2rM5mHXA@public.gmane.org"
	<linux-tegra-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
	"devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org"
	<devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org>
Subject: Re: [PATCH v2 5/5] ASoC: WM8903: Add device tree binding
Date: Tue, 06 Dec 2011 14:17:43 -0600	[thread overview]
Message-ID: <4EDE7867.2060306@gmail.com> (raw)
In-Reply-To: <74CDBE0F657A3D45AFBB94109FB122FF1750B774C0-C7FfzLzN0UxDw2glCA4ptUEOCMrvLtNR@public.gmane.org>

On 12/06/2011 02:09 PM, Stephen Warren wrote:
> Rob Herring wrote at Tuesday, December 06, 2011 12:07 PM:
>> On 12/06/2011 12:22 PM, Stephen Warren wrote:
>>> Stephen Warren wrote at Friday, December 02, 2011 3:09 PM:
>>>> Document the device tree binding for the WM8903 codec, and modify the
>>>> driver to extract platform data from the device tree, if present.
>>>
>>> Mark,
>>>
>>> I just realized that when I was re-organizing all the WM8903 patches, I
>>> dropped the part that added the of_match table to the driver:
>>>
>>> +static const struct of_device_id wm8903_of_match[] __devinitconst = {
>>> +	{ .compatible = "wlf,wm8903", },
>>> +	{},
>>> +};
>>> +MODULE_DEVICE_TABLE(of, wm8903_of_match);
>>>
>>> Now, everything still works without this. Looking at the Linux OF code,
>>> it works by retrieving the compatible property, taking everything after
>>> the comma if present, and then creating an i2c_board_info with that
>>> type, which in this case is "wm8903" and matches wm8903.c's i2c_device_id
>>> table. See drivers/of/of_i2c.c:of_i2c_register_devices() and the call to
>>> base.c:of_modalias_node().
>>>
>>> So, the question is: Should I go back and add the of_match table, or
>>> is I2C intended to work without it perpetually? I notice that you added
>>> an of_match table for all the other WM codecs.
>>
>> It definitely tries to match first with the OF match table, so it should
>> probably be added back.
> 
> OK, I have no issues putting it back.
> 
> But, I certainly can't find any code in drivers/i2c or drivers/of/of_i2c.c
> that matches the compatible property against the of_match_table. Can
> you point it out please. As best I can tell, I2C bus/controller drivers call
> of_i2c_register_devices() which calls of_modalias_node() which only
> operates in the manner I described. I don't think any generic instantiation
> code can be operating instead, since there's nothing in
> of_i2c_register_devices() that skips devices that have already been
> instantiated via other means. Nothing in drivers/i2c seems to touch of_node
> or the compatible property.
> 
Because it is not i2c specific code. But look at i2c_device_match which
calls of_driver_match_device:

static int i2c_device_match(struct device *dev, struct device_driver *drv)
{
        struct i2c_client       *client = i2c_verify_client(dev);
        struct i2c_driver       *driver;

        if (!client)
                return 0;

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

        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;

        return 0;
}

Rob

  parent reply	other threads:[~2011-12-06 20:17 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-12-02 22:08 [PATCH v2 0/5] ASoC: WM8903: DT bindings & related Stephen Warren
     [not found] ` <1322863721-29793-1-git-send-email-swarren-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2011-12-02 22:08   ` [PATCH v2 1/5] ASoC: WM8903: Fix platform data gpio_cfg confusion Stephen Warren
     [not found]     ` <1322863721-29793-2-git-send-email-swarren-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2011-12-06 10:29       ` Mark Brown
2011-12-07 23:49       ` Olof Johansson
     [not found]         ` <20111207234927.GA12676-O5ziIzlqnXUVNXGz7ipsyg@public.gmane.org>
2011-12-08  0:41           ` Mark Brown
2011-12-02 22:08   ` [PATCH v2 2/5] ASoC: WM8903: Create default platform data structure Stephen Warren
     [not found]     ` <1322863721-29793-3-git-send-email-swarren-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2011-12-03 11:19       ` Mark Brown
2011-12-02 22:08   ` [PATCH v2 3/5] ASoC: WM8903: Remove conditionals checking pdata != NULL Stephen Warren
2011-12-02 22:08   ` [PATCH v2 4/5] ASoC: WM8903: Get default irq_active_low from IRQ controller Stephen Warren
     [not found]     ` <1322863721-29793-5-git-send-email-swarren-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2011-12-03 11:17       ` Mark Brown
     [not found]         ` <20111203111713.GC6043-yzvPICuk2AATkU/dhu1WVueM+bqZidxxQQ4Iyu8u01E@public.gmane.org>
2011-12-05 16:52           ` Stephen Warren
2011-12-02 22:08   ` [PATCH v2 5/5] ASoC: WM8903: Add device tree binding Stephen Warren
     [not found]     ` <1322863721-29793-6-git-send-email-swarren-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2011-12-06 18:22       ` Stephen Warren
     [not found]         ` <74CDBE0F657A3D45AFBB94109FB122FF1750B773EE-C7FfzLzN0UxDw2glCA4ptUEOCMrvLtNR@public.gmane.org>
2011-12-06 19:06           ` Rob Herring
     [not found]             ` <4EDE67D2.2020507-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2011-12-06 20:09               ` Stephen Warren
     [not found]                 ` <74CDBE0F657A3D45AFBB94109FB122FF1750B774C0-C7FfzLzN0UxDw2glCA4ptUEOCMrvLtNR@public.gmane.org>
2011-12-06 20:17                   ` Rob Herring [this message]
2011-12-07 12:33           ` Mark Brown

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=4EDE7867.2060306@gmail.com \
    --to=robherring2-re5jqeeqqe8avxtiumwx3w@public.gmane.org \
    --cc=alsa-devel-K7yf7f+aM1XWsZ/bQMPhNw@public.gmane.org \
    --cc=bones-s3s/WqlpOiPyB63q8FvJNQ@public.gmane.org \
    --cc=broonie-yzvPICuk2AATkU/dhu1WVueM+bqZidxxQQ4Iyu8u01E@public.gmane.org \
    --cc=devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org \
    --cc=linux-tegra-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=lrg-l0cyMroinI0@public.gmane.org \
    --cc=swarren-DDmLM1+adcrQT0dZR+AlfA@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).