slimbus: core: match device tree based devices correctly
authorSrinivas Kandagatla <srinivas.kandagatla@linaro.org>
Sun, 16 Sep 2018 23:45:42 +0000 (16:45 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 25 Sep 2018 18:21:02 +0000 (20:21 +0200)
device_id for device tree based devices come from dt compatible string,
such drivers need not provide non dt style device id table.

Match those device using compatible strings.

Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/slimbus/core.c

index 95b00d28ad6e21ac35e562556167f4d16fce96df..7cd635eb44ed272a2e1f422ee4d20f92d5a4506e 100644 (file)
@@ -32,6 +32,10 @@ static int slim_device_match(struct device *dev, struct device_driver *drv)
        struct slim_device *sbdev = to_slim_device(dev);
        struct slim_driver *sbdrv = to_slim_driver(drv);
 
+       /* Attempt an OF style match first */
+       if (of_driver_match_device(dev, drv))
+               return 1;
+
        return !!slim_match(sbdrv->id_table, sbdev);
 }
 
@@ -77,7 +81,7 @@ EXPORT_SYMBOL_GPL(slimbus_bus);
 int __slim_driver_register(struct slim_driver *drv, struct module *owner)
 {
        /* ID table and probe are mandatory */
-       if (!drv->id_table || !drv->probe)
+       if (!(drv->driver.of_match_table || drv->id_table) || !drv->probe)
                return -EINVAL;
 
        drv->driver.bus = &slimbus_bus;