diff mbox series

[U-Boot,009/126] dm: core: Call ofdata_to_platdata() with of-platdata

Message ID 20190925145750.200592-10-sjg@chromium.org
State Accepted
Commit ea14778d0680f8a3f262a06ceb52ea17deb6a104
Delegated to: Bin Meng
Headers show
Series x86: Add initial support for apollolake | expand

Commit Message

Simon Glass Sept. 25, 2019, 2:55 p.m. UTC
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>
---

 drivers/core/device.c    | 3 ++-
 drivers/serial/sandbox.c | 2 ++
 2 files changed, 4 insertions(+), 1 deletion(-)

Comments

Bin Meng Oct. 4, 2019, 9:44 a.m. UTC | #1
On Wed, Sep 25, 2019 at 10:58 PM Simon Glass <sjg@chromium.org> wrote:
>
> 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>
> ---
>
>  drivers/core/device.c    | 3 ++-
>  drivers/serial/sandbox.c | 2 ++
>  2 files changed, 4 insertions(+), 1 deletion(-)
>

Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Bin Meng Oct. 6, 2019, 9:15 a.m. UTC | #2
On Fri, Oct 4, 2019 at 5:44 PM Bin Meng <bmeng.cn@gmail.com> wrote:
>
> On Wed, Sep 25, 2019 at 10:58 PM Simon Glass <sjg@chromium.org> wrote:
> >
> > 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>
> > ---
> >
> >  drivers/core/device.c    | 3 ++-
> >  drivers/serial/sandbox.c | 2 ++
> >  2 files changed, 4 insertions(+), 1 deletion(-)
> >
>
> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>

applied to u-boot-x86/next, thanks!
diff mbox series

Patch

diff --git a/drivers/core/device.c b/drivers/core/device.c
index 05dadf98f95..84f0f0fbf0e 100644
--- a/drivers/core/device.c
+++ b/drivers/core/device.c
@@ -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;
diff --git a/drivers/serial/sandbox.c b/drivers/serial/sandbox.c
index 33102fc872f..2f7bc248871 100644
--- a/drivers/serial/sandbox.c
+++ b/drivers/serial/sandbox.c
@@ -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);