Thread (1 message) 1 message, 1 author, 2013-05-13

Re: [PATCH] i2c: core: make it possible to match a pure device tree driver

From: Grant Likely <hidden>
Date: 2013-05-13 10:30:57
Also in: linux-i2c

On 13 May 2013 10:26, Linus Walleij [off-list ref] wrote:
On Mon, May 13, 2013 at 9:16 AM, Sascha Hauer [off-list ref] wrote:
quoted
quoted
-     status = driver->probe(client, i2c_match_id(driver->id_table, client));
+     if (dev->driver->of_match_table)
+             /* Device tree matching */
+             status = driver->probe(client, NULL);
+     else
+             /* Fall back to matching the id_table */
+             status = driver->probe(client, i2c_match_id(driver->id_table, client));
If you correctly register a device with "vendor,product" in the devicetree
the driver can already fetch the of_device_id using of_match_device(dt_ids, &client->dev)
just like a platform driver would do aswell.
Yes, this is what I write in the commit message:

  "(...) If the driver wants to deduce secondary info
  from the struct of_device_id .data field, it has to call
  of_match_device() on its own match table in the probe function
  device tree probe path."
quoted
i2c_match_id will return a NULL pointer if called with "vendor,product",
because nothing matches in the drivers id_table, so for this case you
change nothing.

If anything, you introduce the problem that a devicetree capable driver
no longer gets a i2c_device_id if the device was instantiated with
i2c_board_info.
Hm, you're right there, what about this:

+     if (dev->of_node)
+             /* Device tree matching */
+             status = driver->probe(client, NULL);
+     else
+             /* Fall back to matching the id_table */
+             status = driver->probe(client,
i2c_match_id(driver->id_table, client));

If the device has an of_node it surely should not be using the
id_table and it'd be correct to pass NULL, right?
That will break anything described in the device tree, but the driver
currently using the heuristic and depending on the data field. You
would instead need to test for an of_match_device() hit when
suppressing the data field.



g.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help