mirror of
https://github.com/brain-hackers/u-boot-brain
synced 2024-10-02 09:30:43 +09:00
dm: Improve handling of a missing uclass
When a uclass definition is missing, no drivers in that uclass can operate. This can happen if a board has a strange collection of options (e.g. the driver is enabled but the uclass is not). Unfortunately this is very confusing at present. Starting up driver model results in a -ENOENT error, which is pretty generic. Quite a big of digging is needed to get to the root cause. To help with this, change the error to a very strange one with no other users in U-Boot. Also add a debug message. Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
parent
e3563f2ec7
commit
3346c87625
@ -39,8 +39,10 @@ int device_bind(struct udevice *parent, const struct driver *drv,
|
|||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
ret = uclass_get(drv->id, &uc);
|
ret = uclass_get(drv->id, &uc);
|
||||||
if (ret)
|
if (ret) {
|
||||||
|
debug("Missing uclass for driver %s\n", drv->name);
|
||||||
return ret;
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
dev = calloc(1, sizeof(struct udevice));
|
dev = calloc(1, sizeof(struct udevice));
|
||||||
if (!dev)
|
if (!dev)
|
||||||
|
@ -58,7 +58,12 @@ static int uclass_add(enum uclass_id id, struct uclass **ucp)
|
|||||||
if (!uc_drv) {
|
if (!uc_drv) {
|
||||||
debug("Cannot find uclass for id %d: please add the UCLASS_DRIVER() declaration for this UCLASS_... id\n",
|
debug("Cannot find uclass for id %d: please add the UCLASS_DRIVER() declaration for this UCLASS_... id\n",
|
||||||
id);
|
id);
|
||||||
return -ENOENT;
|
/*
|
||||||
|
* Use a strange error to make this case easier to find. When
|
||||||
|
* a uclass is not available it can prevent driver model from
|
||||||
|
* starting up and this failure is otherwise hard to debug.
|
||||||
|
*/
|
||||||
|
return -EPFNOSUPPORT;
|
||||||
}
|
}
|
||||||
uc = calloc(1, sizeof(*uc));
|
uc = calloc(1, sizeof(*uc));
|
||||||
if (!uc)
|
if (!uc)
|
||||||
|
Loading…
Reference in New Issue
Block a user