]> git.baikalelectronics.ru Git - kernel.git/commit
iio: dac: dac5571: Fix chip id detection for OF devices
authorJose Cazarin <joseespiriki@gmail.com>
Thu, 24 Mar 2022 23:43:40 +0000 (01:43 +0200)
committerJonathan Cameron <Jonathan.Cameron@huawei.com>
Mon, 4 Apr 2022 08:19:01 +0000 (09:19 +0100)
commite44eb6fb078e30cff72b0f8354cbadfc7f715bef
treeedc5049d96df553b90005b855542144ae49dcc96
parent396c964be873dde834d7e7a26613d3466b4ca15e
iio: dac: dac5571: Fix chip id detection for OF devices

When matching an OF device, the match mechanism tries all components of
the compatible property. This can result with a device matched with a
compatible string that isn't the first in the compatible list. For
instance, with a compatible property set to

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

the driver will match the second compatible string, as the first one
isn't listed in the of_device_id table. The device will however be named
"dac081c081" by the I2C core.

This causes an issue when identifying the chip. The probe function
receives a i2c_device_id that comes from the module's I2C device ID
table. There is no entry in that table for "dac081c081", which results
in a NULL pointer passed to the probe function.

To fix this, add chip_id information in the data field of the OF device
ID table, and retrieve it with device_get_match_data() for OF
devices.

Signed-off-by: Jose Cazarin <joseespiriki@gmail.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Link: https://lore.kernel.org/r/20220324234340.32402-1-laurent.pinchart@ideasonboard.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
drivers/iio/dac/ti-dac5571.c