[PATCH v2 2/6] console: Implement flush() function

Simon Glass sjg at chromium.org
Fri Aug 12 17:11:10 CEST 2022


Hi Pali,

On Fri, 12 Aug 2022 at 03:01, Pali Rohár <pali at kernel.org> wrote:
>
> On Thursday 11 August 2022 18:08:46 Simon Glass wrote:
> > Hi Pali,
> >
> > On Thu, 11 Aug 2022 at 08:50, Pali Rohár <pali at kernel.org> wrote:
> > >
> > > On Thursday 11 August 2022 08:47:50 Simon Glass wrote:
> > > > > diff --git a/include/stdio_dev.h b/include/stdio_dev.h
> > > > > index 270fa2729fb2..06278366ae88 100644
> > > > > --- a/include/stdio_dev.h
> > > > > +++ b/include/stdio_dev.h
> > > > > @@ -37,6 +37,10 @@ struct stdio_dev {
> > > > >         void (*putc)(struct stdio_dev *dev, const char c);
> > > > >         /* To put a string (accelerator) */
> > > > >         void (*puts)(struct stdio_dev *dev, const char *s);
> > > > > +#ifdef CONFIG_CONSOLE_FLUSH_SUPPORT
> > > >
> > > > I'd argue it isn't worth the #ifdef and we might as well have this
> > > > member here always. Then you can drop some #ifdefs from your code.
> > >
> > > But then it will increase binary code size.
> >
> > Using the member will increase code size. But I think the only place
> > you need an #ifdef for that is when you include it in the driver
> > struct. You can use __maybe_unused in the other place.
> >
> > Having the member will only increase memory usage, not code size.
>
> But static memory structures are part of the u-boot.bin binary and also
> their usage increase code size (required copy, etc...), so at the end it
> increase code size.

>From what I understand stdio_dev is allocated at runtime in BSS:

struct stdio_dev *stdio_devices[] = { NULL, NULL, NULL };

(the NULL stuff should not be there, but does nothing, I believe)

So long as no code accesses your new member, then it should only
affect the BSS size.

If you are very worried about it, you could use the technique in
asm-generic/global_data.h to avoid #ifdefs in the C code:

#ifdef CONFIG_GENERATE_ACPI_TABLE
#define gd_acpi_start() gd->acpi_start
#define gd_set_acpi_start(addr) gd->acpi_start = addr
#else
#define gd_acpi_start() 0UL
#define gd_set_acpi_start(addr)
#endif

Regards,
Simon


More information about the U-Boot mailing list