dm: core: Call ofdata_to_platdata() with of-platdata
authorSimon Glass <sjg@chromium.org>
Wed, 25 Sep 2019 14:55:53 +0000 (08:55 -0600)
committerBin Meng <bmeng.cn@gmail.com>
Tue, 8 Oct 2019 05:57:38 +0000 (13:57 +0800)
At present this function is never called when of-platdata is enabled since
we never have a device tree. However, this function is responsible for
copying over the of-platdata, so we must call it. Otherwise the probe()
method would have to be used.

Correct this and fix the sandbox serial driver to not read from the device
tree and try to write to what is read-only platdata on some platforms.

Fixes: 396e343b3d (dm: core: Allow binding a device from a live tree)
Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
drivers/core/device.c
drivers/serial/sandbox.c

index 05dadf98f95950f0b5c29a4ff113dcab7ce3ee74..84f0f0fbf0e87b450f33752706577b51e92c05f7 100644 (file)
@@ -404,7 +404,8 @@ int device_probe(struct udevice *dev)
                        goto fail;
        }
 
-       if (drv->ofdata_to_platdata && dev_has_of_node(dev)) {
+       if (drv->ofdata_to_platdata &&
+           (CONFIG_IS_ENABLED(OF_PLATDATA) || dev_has_of_node(dev))) {
                ret = drv->ofdata_to_platdata(dev);
                if (ret)
                        goto fail;
index 33102fc872f20fd1b1533403ed9c33022fc7df41..2f7bc248871ff8a2e8ce836a9804beb6563b5f11 100644 (file)
@@ -220,6 +220,8 @@ static int sandbox_serial_ofdata_to_platdata(struct udevice *dev)
        const char *colour;
        int i;
 
+       if (CONFIG_IS_ENABLED(OF_PLATDATA))
+               return 0;
        plat->colour = -1;
        colour = fdt_getprop(gd->fdt_blob, dev_of_offset(dev),
                             "sandbox,text-colour", NULL);