]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
dm: core: Mark device as active before calling uclass probe() methods
authorSimon Glass <sjg@chromium.org>
Wed, 25 Mar 2015 18:21:56 +0000 (12:21 -0600)
committerSimon Glass <sjg@chromium.org>
Sat, 18 Apr 2015 17:11:19 +0000 (11:11 -0600)
The uclass pre-probe functions may end up calling back into the device in
some circumstances. This can fail if recursion takes place. Adjust the
ordering so that we mark the device as active early, then retract this
later if needed.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Marek Vasut <marex@denx.de>
drivers/core/device.c
test/dm/test-uclass.c

index 4fba11857c9e91a28591d8dfd5f5f1747d10590e..b7ed21c0037fc6c4547ab175ba4785c979796a39 100644 (file)
@@ -243,6 +243,8 @@ int device_probe_child(struct udevice *dev, void *parent_priv)
        }
        dev->seq = seq;
 
+       dev->flags |= DM_FLAG_ACTIVATED;
+
        ret = uclass_pre_probe_device(dev);
        if (ret)
                goto fail;
@@ -269,10 +271,8 @@ int device_probe_child(struct udevice *dev, void *parent_priv)
        }
 
        ret = uclass_post_probe_device(dev);
-       if (ret) {
-               dev->flags &= ~DM_FLAG_ACTIVATED;
+       if (ret)
                goto fail_uclass;
-       }
 
        return 0;
 fail_uclass:
@@ -281,6 +281,8 @@ fail_uclass:
                        __func__, dev->name);
        }
 fail:
+       dev->flags &= ~DM_FLAG_ACTIVATED;
+
        dev->seq = -1;
        device_free(dev);
 
index be91657347b0df53514ee1ce29718127864f6100..7cb37f70c785c9df2e7f238f67532eeb43d4ec5c 100644 (file)
@@ -31,6 +31,7 @@ int test_ping(struct udevice *dev, int pingval, int *pingret)
 static int test_post_bind(struct udevice *dev)
 {
        dm_testdrv_op_count[DM_TEST_OP_POST_BIND]++;
+       ut_assert(!device_active(dev));
 
        return 0;
 }
@@ -48,7 +49,7 @@ static int test_pre_probe(struct udevice *dev)
 
        dm_testdrv_op_count[DM_TEST_OP_PRE_PROBE]++;
        ut_assert(priv);
-       ut_assert(!device_active(dev));
+       ut_assert(device_active(dev));
 
        return 0;
 }