The AM335x uses ti,omap4-i2c as compatible for the I2C device tree
nodes, but that compatible unlike its brethern has no driver data as
it's determined using the machine compatible in the probe function
instead.

device_get_match_data() returning NULL is thus expected and should not
lead to an immediate error.

Fixes: 20d87123a638 ("treewide: replace dev_get_drvdata with 
device_get_match_data")
Signed-off-by: Ahmad Fatoum <[email protected]>
---
I manually verified all drivers calling device_get_match_data() and I
believe this to be the only such bug.
---
 drivers/i2c/busses/i2c-omap.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/i2c/busses/i2c-omap.c b/drivers/i2c/busses/i2c-omap.c
index 29378a96d722..c45483579250 100644
--- a/drivers/i2c/busses/i2c-omap.c
+++ b/drivers/i2c/busses/i2c-omap.c
@@ -1076,14 +1076,15 @@ i2c_omap_probe(struct device *pdev)
        }
 
        i2c_data = device_get_match_data(pdev);
-       if (!i2c_data)
-               return -ENODEV;
 
        if (of_machine_is_compatible("ti,am33xx"))
                i2c_data = &am33xx_data;
        if (of_machine_is_compatible("ti,omap4"))
                i2c_data = &omap4_data;
 
+       if (!i2c_data)
+               return -EINVAL;
+
        i2c_omap->data = i2c_data;
        i2c_omap->reg_shift = (i2c_data->flags >>
                                        OMAP_I2C_FLAG_BUS_SHIFT__SHIFT) & 3;
-- 
2.47.3


Reply via email to