[U-Boot] [PATCH v4 05/33] dm: do not return pointer if NULL is given to devp of device_bind()

Simon Glass
2015-08-24T15:12:23Z

From: Masahiro Yamada <yamada.masahiro@socionext.com>

This is useful when we want to bind a device, but do not need the
device pointer.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
---

Changes in v4: None
Changes in v3: None
Changes in v2: None

drivers/core/device.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/core/device.c b/drivers/core/device.c
index f40c977..4f060ee 100644
--- a/drivers/core/device.c
+++ b/drivers/core/device.c
@@ -33,7 +33,8 @@ int device_bind(struct udevice *parent, const struct driver *drv,
struct uclass *uc;
int size, ret = 0;

- *devp = NULL;
+ if (devp)
+ *devp = NULL;
if (!name)
return -EINVAL;

@@ -134,7 +135,8 @@ int device_bind(struct udevice *parent, const struct driver *drv,

if (parent)
dm_dbg("Bound device %s to %s\n", dev->name, parent->name);
- *devp = dev;
+ if (devp)
+ *devp = dev;

dev->flags |= DM_FLAG_BOUND;

--
2.5.0.457.gab17608