From 298d4de1ed003ad91cb49e068d744db0343cacb6 Mon Sep 17 00:00:00 2001 From: Lee Jones Date: Mon, 7 Nov 2016 12:47:38 +0000 Subject: i2c: Match using traditional OF methods, then by vendor-less compatible strings This function provides a single call for all I2C devices which need to match firstly using traditional OF means i.e by of_node, then if that fails we attempt to match using the supplied I2C client name with a list of supplied compatible strings with the ',' string removed. The latter is required due to the unruly naming conventions used currently by I2C devices. Acked-by: Grant Likely Signed-off-by: Lee Jones [Kieran: Fix static inline usage on !CONFIG_OF] Tested-by: Kieran Bingham Reviewed-by: Javier Martinez Canillas Tested-by: Javier Martinez Canillas Signed-off-by: Kieran Bingham Signed-off-by: Wolfram Sang --- drivers/i2c/i2c-core.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'drivers/i2c/i2c-core.c') diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c index c588a8504c99..2151d0b353b3 100644 --- a/drivers/i2c/i2c-core.c +++ b/drivers/i2c/i2c-core.c @@ -1799,6 +1799,22 @@ i2c_of_match_device_sysfs(const struct of_device_id *matches, return NULL; } +const struct of_device_id +*i2c_of_match_device(const struct of_device_id *matches, + struct i2c_client *client) +{ + const struct of_device_id *match; + + if (!(client && matches)) + return NULL; + + match = of_match_device(matches, &client->dev); + if (match) + return match; + + return i2c_of_match_device_sysfs(matches, client); +} +EXPORT_SYMBOL_GPL(i2c_of_match_device); #else static void of_i2c_register_devices(struct i2c_adapter *adap) { } #endif /* CONFIG_OF */ -- cgit v1.2.3