Re: [U-Boot] [PATCH v3 05/26] dm: core: Tidy up error handling in device_bind()

2015-01-26 Thread Simon Glass
On 25 January 2015 at 08:26, Simon Glass  wrote:
> Make the error handling more standard to make it easier to build on top of
> it. Also correct a bug in the error path where there is no parent.
>
> Signed-off-by: Simon Glass 
> Reviewed-by: Masahiro Yamada 
> ---
>
> Changes in v3: None
> Changes in v2: None
>
>  drivers/core/device.c | 18 ++
>  1 file changed, 10 insertions(+), 8 deletions(-)

Applied to -u-boot-dm
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v3 05/26] dm: core: Tidy up error handling in device_bind()

2015-01-25 Thread Simon Glass
Make the error handling more standard to make it easier to build on top of
it. Also correct a bug in the error path where there is no parent.

Signed-off-by: Simon Glass 
Reviewed-by: Masahiro Yamada 
---

Changes in v3: None
Changes in v2: None

 drivers/core/device.c | 18 ++
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/drivers/core/device.c b/drivers/core/device.c
index 963b16f..eca8eda 100644
--- a/drivers/core/device.c
+++ b/drivers/core/device.c
@@ -81,18 +81,13 @@ int device_bind(struct udevice *parent, struct driver *drv, 
const char *name,
 
ret = uclass_bind_device(dev);
if (ret)
-   goto fail_bind;
+   goto fail_uclass_bind;
 
/* if we fail to bind we remove device from successors and free it */
if (drv->bind) {
ret = drv->bind(dev);
-   if (ret) {
-   if (uclass_unbind_device(dev)) {
-   dm_warn("Failed to unbind dev '%s' on error 
path\n",
-   dev->name);
-   }
+   if (ret)
goto fail_bind;
-   }
}
if (parent)
dm_dbg("Bound device %s to %s\n", dev->name, parent->name);
@@ -101,8 +96,15 @@ int device_bind(struct udevice *parent, struct driver *drv, 
const char *name,
return 0;
 
 fail_bind:
-   list_del(&dev->sibling_node);
+   if (uclass_unbind_device(dev)) {
+   dm_warn("Failed to unbind dev '%s' on error path\n",
+   dev->name);
+   }
+fail_uclass_bind:
+   if (parent)
+   list_del(&dev->sibling_node);
free(dev);
+
return ret;
 }
 
-- 
2.2.0.rc0.207.ga3a616c

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot