linux-i2c.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Device match data and DT compatible string fallback
@ 2021-06-28 15:29 Laurent Pinchart
  2021-06-28 15:55 ` Wolfram Sang
  0 siblings, 1 reply; 3+ messages in thread
From: Laurent Pinchart @ 2021-06-28 15:29 UTC (permalink / raw)
  To: linux-i2c; +Cc: Jose Cazarin

Hello,

I recently ran into an issue in a driver (drivers/iio/dac/ti-dac5571.c
to be precise, but the problem is more generic) that led to a crash at
probe time. The driver supports matching to both OF devices and platform
devices by specifying of_device_id and i2c_device_id tables. It supports
multiple devices, and stores device-specific data in the i2c_device_id
table that it retrieves at probe time through the i2c_device_id pointer
passed to the probe function.

The device I'm working with is an DAC081C081, which is compatible with
the DAC5571. It's an OF device that has the compatible property set to

	compatible = "ti,dac081c081", "ti,dac5571";

The driver doesn't support the ti,dac081c081 compatible string, so the
device is matched to the driver using the compatible fallback
"ti,dac5571". This leads to the i2c_device_id passed to the proble
function being NULL, as the i2c_device_if table doesn't contain a
"dac5571" entry, and this results in a crash.

I could fix this in the driver by calling of_device_get_match_data() in
the probe function with dev->of_node is not NULL, but I feel this is
really an issue that should be handled by the framework. Has anyone ever
given it a thought ?

-- 
Regards,

Laurent Pinchart

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-06-28 16:22 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-06-28 15:29 Device match data and DT compatible string fallback Laurent Pinchart
2021-06-28 15:55 ` Wolfram Sang
2021-06-28 16:21   ` Laurent Pinchart

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).