[PATCH v2 03/18] bootstd: Avoid sprintf() in SPL when creating bootdevs

Simon Glass sjg at chromium.org
Sat Dec 7 15:39:15 CET 2024


Hi Tom,

On Fri, 4 Oct 2024 at 16:02, Tom Rini <trini at konsulko.com> wrote:
>
> On Fri, Sep 20, 2024 at 10:12:42AM +0200, Simon Glass wrote:
>
> > The name of the bootdev device is not that important, particular in SPL.
> > Save a little code space by using a simpler name.
> >
> > Signed-off-by: Simon Glass <sjg at chromium.org>
> > ---
> >
> > (no changes since v1)
> >
> >  boot/bootdev-uclass.c | 10 ++++++++--
> >  1 file changed, 8 insertions(+), 2 deletions(-)
> >
> > diff --git a/boot/bootdev-uclass.c b/boot/bootdev-uclass.c
> > index 807f8dfb064..79d4d990edb 100644
> > --- a/boot/bootdev-uclass.c
> > +++ b/boot/bootdev-uclass.c
> > @@ -16,6 +16,7 @@
> >  #include <malloc.h>
> >  #include <part.h>
> >  #include <sort.h>
> > +#include <spl.h>
> >  #include <dm/device-internal.h>
> >  #include <dm/lists.h>
> >  #include <dm/uclass-internal.h>
> > @@ -278,8 +279,13 @@ int bootdev_setup_for_sibling_blk(struct udevice *blk, const char *drv_name)
> >       int ret, len;
> >
> >       len = bootdev_get_suffix_start(blk, ".blk");
> > -     snprintf(dev_name, sizeof(dev_name), "%.*s.%s", len, blk->name,
> > -              "bootdev");
> > +     if (spl_phase() < PHASE_BOARD_R) {
> > +             strncpy(dev_name, blk->name, sizeof(dev_name) - 5);
> > +             strcat(dev_name, ".sib");
> > +     } else {
> > +             snprintf(dev_name, sizeof(dev_name), "%.*s.%s", len, blk->name,
> > +                      "bootdev");
> > +     }
> >
> >       parent = dev_get_parent(blk);
> >       ret = device_find_child_by_name(parent, dev_name, &dev);
>
> I don't understand this change. In testing, I don't see any size
> reduction in SPL anywhere (no platforms shrink in SPL for this series)
> and just size growth in main u-boot in this function. Did the wrong
> comments get applied to this patch?

That's because nothing is using bootstd in SPL (or VPL) yet. We don't
have to have this change and I can come back to it later, if you like.

Regards,
Simon


More information about the U-Boot mailing list