[U-Boot] [PATCH 3/6] cbfs: Move static variables into a struct

Simon Glass sjg at chromium.org
Thu Aug 15 01:50:43 UTC 2019


Hi Bin,

On Wed, 14 Aug 2019 at 02:40, Bin Meng <bmeng.cn at gmail.com> wrote:
>
> Hi Simon,
>
> On Wed, Aug 14, 2019 at 11:09 AM Simon Glass <sjg at chromium.org> wrote:
> >
> > At present there are a number of static variables in BSS. This cannot work
> > with SPL, at least until BSS is available in board_init_r().
> >
> > Move the variables into a struct, so it is possible to malloc() it and use
> > it before BSS is available.
> >
> > Signed-off-by: Simon Glass <sjg at chromium.org>
> > ---
> >
> >  fs/cbfs/cbfs.c | 96 +++++++++++++++++++++++++++++++++-----------------
> >  1 file changed, 63 insertions(+), 33 deletions(-)
> >
> > diff --git a/fs/cbfs/cbfs.c b/fs/cbfs/cbfs.c
> > index 2a9edcc9a0..f4298d7320 100644
> > --- a/fs/cbfs/cbfs.c
> > +++ b/fs/cbfs/cbfs.c
> > @@ -11,9 +11,14 @@
> >  enum cbfs_result file_cbfs_result;
> >  static const u32 good_magic = 0x4f524243;
> >  static const u8 good_file_magic[] = "LARCHIVE";
> > -static int initialized;
> > -static struct cbfs_header cbfs_header;
> > -static struct cbfs_cachenode *file_cache;
> > +
> > +struct cbfs_priv {
> > +       int initialized;
> > +       struct cbfs_header header;
> > +       struct cbfs_cachenode *file_cache;
> > +};
>
> Could we move this struct define to cbfs.h?

We could, but I would prefer to keep it opaque. I don't think outside
code needs to look at it.

[...]

Regards,
Simon


More information about the U-Boot mailing list