]> git.karo-electronics.de Git - karo-tx-linux.git/commit
i2c: Add the ability to match device to compatible string without an of_node
authorLee Jones <lee.jones@linaro.org>
Mon, 7 Nov 2016 12:47:37 +0000 (12:47 +0000)
committerWolfram Sang <wsa@the-dreams.de>
Thu, 17 Nov 2016 15:07:26 +0000 (16:07 +0100)
commitcabcf4f6be658b2d4bea26dee89d08fdf67d6811
treeb67ee5e3f6f1d69df477231a283ca1c560476b69
parent811073b11b83c4da78413ecdb24c5adf3e5631ae
i2c: Add the ability to match device to compatible string without an of_node

A great deal of I2C devices are currently matched via DT node name, and
as such the compatible naming convention of '<vendor>,<device>' has gone
somewhat awry - some nodes don't supply one, some supply an arbitrary
string and others the correct device name with an arbitrary vendor prefix.

In an effort to correct this problem we have to supply a mechanism to
match a device by compatible string AND by simple device name.  This
function strips off the '<vendor>,' part of a supplied compatible string
and attempts to match without it.

It is also used for sysfs, where a user can choose to instantiate a
device on an i2c bus using the sysfs interface by providing a string and
address to match and communicate with the device on the bus. Presently
this string is only matched against the old i2c device id style strings,
even in the presence of full device tree compatible strings with vendor
prefixes.

Providing a vendor-prefixed string to the sysfs interface will not match
against the device tree of_match_device() calls as there is no device
tree node to parse from the sysfs interface.

This function can match both vendor prefixed and stripped compatible
strings on the sysfs interface.

Acked-by: Grant Likely <grant.likely@linaro.org>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
Reviewed-by: Javier Martinez Canillas <javier@osg.samsung.com>
Tested-by: Javier Martinez Canillas <javier@osg.samsung.com>
Signed-off-by: Kieran Bingham <kieran@bingham.xyz>
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
drivers/i2c/i2c-core.c