X-Git-Url: https://asedeno.scripts.mit.edu/gitweb/?a=blobdiff_plain;f=drivers%2Fslimbus%2Fcore.c;h=55eda5863a6b90e2f37ce5fe5dcecf277043e679;hb=0b21f21ae0d746b385a827aceb84cb26c551eb94;hp=95b00d28ad6e21ac35e562556167f4d16fce96df;hpb=92d58fd13af269552b65853d2c3a63970c4090bf;p=linux.git diff --git a/drivers/slimbus/core.c b/drivers/slimbus/core.c index 95b00d28ad6e..55eda5863a6b 100644 --- a/drivers/slimbus/core.c +++ b/drivers/slimbus/core.c @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include "slimbus.h" @@ -32,6 +33,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); } @@ -39,8 +44,23 @@ static int slim_device_probe(struct device *dev) { struct slim_device *sbdev = to_slim_device(dev); struct slim_driver *sbdrv = to_slim_driver(dev->driver); + int ret; - return sbdrv->probe(sbdev); + ret = sbdrv->probe(sbdev); + if (ret) + return ret; + + /* try getting the logical address after probe */ + ret = slim_get_logical_addr(sbdev); + if (!ret) { + if (sbdrv->device_status) + sbdrv->device_status(sbdev, sbdev->status); + } else { + dev_err(&sbdev->dev, "Failed to get logical address\n"); + ret = -EPROBE_DEFER; + } + + return ret; } static int slim_device_remove(struct device *dev) @@ -57,11 +77,24 @@ static int slim_device_remove(struct device *dev) return 0; } +static int slim_device_uevent(struct device *dev, struct kobj_uevent_env *env) +{ + struct slim_device *sbdev = to_slim_device(dev); + int ret; + + ret = of_device_uevent_modalias(dev, env); + if (ret != -ENODEV) + return ret; + + return add_uevent_var(env, "MODALIAS=slim:%s", dev_name(&sbdev->dev)); +} + struct bus_type slimbus_bus = { .name = "slimbus", .match = slim_device_match, .probe = slim_device_probe, .remove = slim_device_remove, + .uevent = slim_device_uevent, }; EXPORT_SYMBOL_GPL(slimbus_bus); @@ -77,7 +110,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;