• Lee Jones's avatar
    i2c: Add the ability to match device to compatible string without an of_node · cabcf4f6
    Lee Jones authored
    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: default avatarGrant Likely <grant.likely@linaro.org>
    Signed-off-by: default avatarLee Jones <lee.jones@linaro.org>
    Reviewed-by: default avatarJavier Martinez Canillas <javier@osg.samsung.com>
    Tested-by: default avatarJavier Martinez Canillas <javier@osg.samsung.com>
    Signed-off-by: default avatarKieran Bingham <kieran@bingham.xyz>
    Signed-off-by: default avatarWolfram Sang <wsa@the-dreams.de>
    cabcf4f6
i2c-core.c 94.2 KB