diff mbox series

[15/20] dm: core: Convert #ifdef to if() in root.c

Message ID 20201003173142.3213123-16-sjg@chromium.org
State Accepted
Commit 9e948b9b99d17ea6c2204a1b6251a5c33ee83dd9
Delegated to: Simon Glass
Headers show
Series dm: Enhance of-platdata to support parent devices | expand

Commit Message

Simon Glass Oct. 3, 2020, 5:31 p.m. UTC
Convert a few conditions to use compile-time checks to reduce the number
of build paths.

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

 drivers/core/root.c | 18 +++++++-----------
 1 file changed, 7 insertions(+), 11 deletions(-)

Comments

Simon Glass Oct. 30, 2020, 3:34 a.m. UTC | #1
Convert a few conditions to use compile-time checks to reduce the number
of build paths.

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

 drivers/core/root.c | 18 +++++++-----------
 1 file changed, 7 insertions(+), 11 deletions(-)

Applied to u-boot-dm, thanks!
Michal Simek Nov. 4, 2020, 12:55 p.m. UTC | #2
Hi Simon,

so 3. 10. 2020 v 19:35 odesílatel Simon Glass <sjg@chromium.org> napsal:
>
> Convert a few conditions to use compile-time checks to reduce the number
> of build paths.
>
> Signed-off-by: Simon Glass <sjg@chromium.org>
> ---
>
>  drivers/core/root.c | 18 +++++++-----------
>  1 file changed, 7 insertions(+), 11 deletions(-)
>
> diff --git a/drivers/core/root.c b/drivers/core/root.c
> index e8df5aebe84..5f10d7a39c7 100644
> --- a/drivers/core/root.c
> +++ b/drivers/core/root.c
> @@ -50,7 +50,6 @@ void dm_fixup_for_gd_move(struct global_data *new_gd)
>         }
>  }
>
> -#if defined(CONFIG_NEEDS_MANUAL_RELOC)
>  void fix_drivers(void)
>  {
>         struct driver *drv =
> @@ -129,8 +128,6 @@ void fix_devices(void)
>         }
>  }
>
> -#endif
> -
>  int dm_init(bool of_live)
>  {
>         int ret;
> @@ -141,11 +138,11 @@ int dm_init(bool of_live)
>         }
>         INIT_LIST_HEAD(&DM_UCLASS_ROOT_NON_CONST);
>
> -#if defined(CONFIG_NEEDS_MANUAL_RELOC)
> -       fix_drivers();
> -       fix_uclass();
> -       fix_devices();
> -#endif
> +       if (IS_ENABLED(CONFIG_NEEDS_MANUAL_RELOC)) {
> +               fix_drivers();
> +               fix_uclass();
> +               fix_devices();
> +       }

This change is causing a hang on the Microblaze system.
CONFIG_NEEDS_MANUAL_RELOC is out of Kconfig that's why likely this
condition is not handled properly.

U-Boot 2021.01-rc1-00211-g63677927bf26-dirty (Nov 04 2020 - 13:46:33 +0100)

Model: Xilinx MicroBlaze
DRAM:  1 GiB
Error binding driver 'axi_emac': -12
Error binding driver 'xlnx_gpio': -12
Error binding driver 'xlnx_gpio': -12
Error binding driver 'xlnx_gpio': -12
Error binding driver 'xlnx_gpio': -12
Error binding driver 'xlnx_gpio': -12
Error binding driver 'ns16550_serial': -12
Error binding driver 'gpio_restart': -12
Some drivers failed to bind
Error binding driver 'simple_bus': -12
Some drivers failed to bind
initcall sequence bffeec9c failed at call 85016230 (err=-12)
### ERROR ### Please RESET the board ###

Thanks,
Michal
Tom Rini Nov. 4, 2020, 1:59 p.m. UTC | #3
On Wed, Nov 04, 2020 at 01:55:50PM +0100, Michal Simek wrote:
> Hi Simon,
> 
> so 3. 10. 2020 v 19:35 odesílatel Simon Glass <sjg@chromium.org> napsal:
> >
> > Convert a few conditions to use compile-time checks to reduce the number
> > of build paths.
> >
> > Signed-off-by: Simon Glass <sjg@chromium.org>
> > ---
> >
> >  drivers/core/root.c | 18 +++++++-----------
> >  1 file changed, 7 insertions(+), 11 deletions(-)
> >
> > diff --git a/drivers/core/root.c b/drivers/core/root.c
> > index e8df5aebe84..5f10d7a39c7 100644
> > --- a/drivers/core/root.c
> > +++ b/drivers/core/root.c
> > @@ -50,7 +50,6 @@ void dm_fixup_for_gd_move(struct global_data *new_gd)
> >         }
> >  }
> >
> > -#if defined(CONFIG_NEEDS_MANUAL_RELOC)
> >  void fix_drivers(void)
> >  {
> >         struct driver *drv =
> > @@ -129,8 +128,6 @@ void fix_devices(void)
> >         }
> >  }
> >
> > -#endif
> > -
> >  int dm_init(bool of_live)
> >  {
> >         int ret;
> > @@ -141,11 +138,11 @@ int dm_init(bool of_live)
> >         }
> >         INIT_LIST_HEAD(&DM_UCLASS_ROOT_NON_CONST);
> >
> > -#if defined(CONFIG_NEEDS_MANUAL_RELOC)
> > -       fix_drivers();
> > -       fix_uclass();
> > -       fix_devices();
> > -#endif
> > +       if (IS_ENABLED(CONFIG_NEEDS_MANUAL_RELOC)) {
> > +               fix_drivers();
> > +               fix_uclass();
> > +               fix_devices();
> > +       }
> 
> This change is causing a hang on the Microblaze system.
> CONFIG_NEEDS_MANUAL_RELOC is out of Kconfig that's why likely this
> condition is not handled properly.

Can you do the migration or should I?  It looks like just adding to the
top-level Kconfig and select'ing for microblaze/m68k.
Michal Simek Nov. 4, 2020, 2:33 p.m. UTC | #4
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi,

On 04. 11. 20 14:59, Tom Rini wrote:
> On Wed, Nov 04, 2020 at 01:55:50PM +0100, Michal Simek wrote:
>> Hi Simon,
>>
>> so 3. 10. 2020 v 19:35 odesílatel Simon Glass <sjg@chromium.org>
>> napsal:
>>>
>>> Convert a few conditions to use compile-time checks to reduce
>>> the number of build paths.
>>>
>>> Signed-off-by: Simon Glass <sjg@chromium.org> ---
>>>
>>> drivers/core/root.c | 18 +++++++----------- 1 file changed, 7
>>> insertions(+), 11 deletions(-)
>>>
>>> diff --git a/drivers/core/root.c b/drivers/core/root.c index
>>> e8df5aebe84..5f10d7a39c7 100644 --- a/drivers/core/root.c +++
>>> b/drivers/core/root.c @@ -50,7 +50,6 @@ void
>>> dm_fixup_for_gd_move(struct global_data *new_gd) } }
>>>
>>> -#if defined(CONFIG_NEEDS_MANUAL_RELOC) void fix_drivers(void)
>>> { struct driver *drv = @@ -129,8 +128,6 @@ void
>>> fix_devices(void) } }
>>>
>>> -#endif - int dm_init(bool of_live) { int ret; @@ -141,11
>>> +138,11 @@ int dm_init(bool of_live) }
>>> INIT_LIST_HEAD(&DM_UCLASS_ROOT_NON_CONST);
>>>
>>> -#if defined(CONFIG_NEEDS_MANUAL_RELOC) -       fix_drivers();
>>> -       fix_uclass(); -       fix_devices(); -#endif +       if
>>> (IS_ENABLED(CONFIG_NEEDS_MANUAL_RELOC)) { +
>>> fix_drivers(); +               fix_uclass(); +
>>> fix_devices(); +       }
>>
>> This change is causing a hang on the Microblaze system.
>> CONFIG_NEEDS_MANUAL_RELOC is out of Kconfig that's why likely
>> this condition is not handled properly.
>
> Can you do the migration or should I?  It looks like just adding to
> the top-level Kconfig and select'ing for microblaze/m68k.
>

Send a patch your way. Please review.

Thanks,
Michal
-----BEGIN PGP SIGNATURE-----

iF0EARECAB0WIQQbPNTMvXmYlBPRwx7KSWXLKUoMIQUCX6K7xQAKCRDKSWXLKUoM
ITb5AJ9nzJXtJkmxuKTc/C7zn6Y9onNNWgCdGw68CTEMEeuA9FkCjIJvV0F77U8=
=opbA
-----END PGP SIGNATURE-----
diff mbox series

Patch

diff --git a/drivers/core/root.c b/drivers/core/root.c
index e8df5aebe84..5f10d7a39c7 100644
--- a/drivers/core/root.c
+++ b/drivers/core/root.c
@@ -50,7 +50,6 @@  void dm_fixup_for_gd_move(struct global_data *new_gd)
 	}
 }
 
-#if defined(CONFIG_NEEDS_MANUAL_RELOC)
 void fix_drivers(void)
 {
 	struct driver *drv =
@@ -129,8 +128,6 @@  void fix_devices(void)
 	}
 }
 
-#endif
-
 int dm_init(bool of_live)
 {
 	int ret;
@@ -141,11 +138,11 @@  int dm_init(bool of_live)
 	}
 	INIT_LIST_HEAD(&DM_UCLASS_ROOT_NON_CONST);
 
-#if defined(CONFIG_NEEDS_MANUAL_RELOC)
-	fix_drivers();
-	fix_uclass();
-	fix_devices();
-#endif
+	if (IS_ENABLED(CONFIG_NEEDS_MANUAL_RELOC)) {
+		fix_drivers();
+		fix_uclass();
+		fix_devices();
+	}
 
 	ret = device_bind_by_name(NULL, false, &root_info, &DM_ROOT_NON_CONST);
 	if (ret)
@@ -350,9 +347,8 @@  int dm_init_and_scan(bool pre_reloc_only)
 {
 	int ret;
 
-#if CONFIG_IS_ENABLED(OF_PLATDATA)
-	dm_populate_phandle_data();
-#endif
+	if (CONFIG_IS_ENABLED(OF_PLATDATA))
+		dm_populate_phandle_data();
 
 	ret = dm_init(CONFIG_IS_ENABLED(OF_LIVE));
 	if (ret) {