diff mbox

[U-Boot,03/18] dm: core: Call uclass post_bind() after the driver's bind() method

Message ID 1452011474-15207-4-git-send-email-sjg@chromium.org
State Accepted
Commit 20af3c0a0034b885cd269cb7abdc2d933d82a723
Delegated to: Simon Glass
Headers show

Commit Message

Simon Glass Jan. 5, 2016, 4:30 p.m. UTC
At present the uclass's post_bind() method is called before the driver's
bind() method. This means that the uclass cannot use any of the information
set up by the driver. Move it later in the sequence to permit this.

This is an ordering change which is always fairly major in nature. The main
impact is that devices which have children will not see them appear in their
bind() method. From what I can see, existing drivers do not look at their
children in the bind() method, so this should be safe.

Conceptually this change seems to result in a 'more correct' ordering, since
the uclass (which is broader than the device) gets the last word.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 drivers/core/device.c | 7 +++++++
 drivers/core/uclass.c | 5 -----
 2 files changed, 7 insertions(+), 5 deletions(-)

Comments

Tom Rini Jan. 13, 2016, 9:55 p.m. UTC | #1
On Tue, Jan 05, 2016 at 09:30:59AM -0700, Simon Glass wrote:

> At present the uclass's post_bind() method is called before the driver's
> bind() method. This means that the uclass cannot use any of the information
> set up by the driver. Move it later in the sequence to permit this.
> 
> This is an ordering change which is always fairly major in nature. The main
> impact is that devices which have children will not see them appear in their
> bind() method. From what I can see, existing drivers do not look at their
> children in the bind() method, so this should be safe.
> 
> Conceptually this change seems to result in a 'more correct' ordering, since
> the uclass (which is broader than the device) gets the last word.
> 
> Signed-off-by: Simon Glass <sjg@chromium.org>

Reviewed-by: Tom Rini <trini@konsulko.com>
Simon Glass Jan. 16, 2016, 1:26 a.m. UTC | #2
On 13 January 2016 at 14:55, Tom Rini <trini@konsulko.com> wrote:
> On Tue, Jan 05, 2016 at 09:30:59AM -0700, Simon Glass wrote:
>
>> At present the uclass's post_bind() method is called before the driver's
>> bind() method. This means that the uclass cannot use any of the information
>> set up by the driver. Move it later in the sequence to permit this.
>>
>> This is an ordering change which is always fairly major in nature. The main
>> impact is that devices which have children will not see them appear in their
>> bind() method. From what I can see, existing drivers do not look at their
>> children in the bind() method, so this should be safe.
>>
>> Conceptually this change seems to result in a 'more correct' ordering, since
>> the uclass (which is broader than the device) gets the last word.
>>
>> Signed-off-by: Simon Glass <sjg@chromium.org>
>
> Reviewed-by: Tom Rini <trini@konsulko.com>
>
> --
> Tom

Applied to u-boot-dm
diff mbox

Patch

diff --git a/drivers/core/device.c b/drivers/core/device.c
index 7a02a93..a9fcac9 100644
--- a/drivers/core/device.c
+++ b/drivers/core/device.c
@@ -135,6 +135,11 @@  int device_bind(struct udevice *parent, const struct driver *drv,
 		if (ret)
 			goto fail_child_post_bind;
 	}
+	if (uc->uc_drv->post_bind) {
+		ret = uc->uc_drv->post_bind(dev);
+		if (ret)
+			goto fail_uclass_post_bind;
+	}
 
 	if (parent)
 		dm_dbg("Bound device %s to %s\n", dev->name, parent->name);
@@ -145,6 +150,8 @@  int device_bind(struct udevice *parent, const struct driver *drv,
 
 	return 0;
 
+fail_uclass_post_bind:
+	/* There is no child unbind() method, so no clean-up required */
 fail_child_post_bind:
 	if (CONFIG_IS_ENABLED(DM_DEVICE_REMOVE)) {
 		if (drv->unbind && drv->unbind(dev)) {
diff --git a/drivers/core/uclass.c b/drivers/core/uclass.c
index 1af0947..7f38dae 100644
--- a/drivers/core/uclass.c
+++ b/drivers/core/uclass.c
@@ -426,11 +426,6 @@  int uclass_bind_device(struct udevice *dev)
 				goto err;
 		}
 	}
-	if (uc->uc_drv->post_bind) {
-		ret = uc->uc_drv->post_bind(dev);
-		if (ret)
-			goto err;
-	}
 
 	return 0;
 err: