aboutsummaryrefslogtreecommitdiff
path: root/drivers/core
diff options
context:
space:
mode:
authorSimon Glass2014-07-23 06:55:08 -0600
committerSimon Glass2014-07-23 14:07:25 +0100
commit9ca296a1b0ef37e53ca62ec8a345d9970f987599 (patch)
tree4fe6e371b8d31025b2d64be96e858d29294cf30f /drivers/core
parent093f79ab88d57b800283b0a172c17167699f4243 (diff)
dm: Move uclass error checking/probing into a function
Several functions will use this same pattern, so bring it into a function. Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'drivers/core')
-rw-r--r--drivers/core/uclass.c28
1 files changed, 22 insertions, 6 deletions
diff --git a/drivers/core/uclass.c b/drivers/core/uclass.c
index 34723ec42a7..db915267d6e 100644
--- a/drivers/core/uclass.c
+++ b/drivers/core/uclass.c
@@ -158,13 +158,19 @@ int uclass_find_device(enum uclass_id id, int index, struct udevice **devp)
return -ENODEV;
}
-int uclass_get_device(enum uclass_id id, int index, struct udevice **devp)
+/**
+ * uclass_get_device_tail() - handle the end of a get_device call
+ *
+ * This handles returning an error or probing a device as needed.
+ *
+ * @dev: Device that needs to be probed
+ * @ret: Error to return. If non-zero then the device is not probed
+ * @devp: Returns the value of 'dev' if there is no error
+ * @return ret, if non-zero, else the result of the device_probe() call
+ */
+static int uclass_get_device_tail(struct udevice *dev, int ret,
+ struct udevice **devp)
{
- struct udevice *dev;
- int ret;
-
- *devp = NULL;
- ret = uclass_find_device(id, index, &dev);
if (ret)
return ret;
@@ -177,6 +183,16 @@ int uclass_get_device(enum uclass_id id, int index, struct udevice **devp)
return 0;
}
+int uclass_get_device(enum uclass_id id, int index, struct udevice **devp)
+{
+ struct udevice *dev;
+ int ret;
+
+ *devp = NULL;
+ ret = uclass_find_device(id, index, &dev);
+ return uclass_get_device_tail(dev, ret, devp);
+}
+
int uclass_first_device(enum uclass_id id, struct udevice **devp)
{
struct uclass *uc;