[Skiboot] [RFC PATCH 2/4] hdata/vpd: Parse additional VINI records

Ananth N Mavinakayanahalli ananth at linux.vnet.ibm.com
Tue Feb 28 19:09:51 AEDT 2017


On Tue, Feb 28, 2017 at 06:49:46PM +1100, Oliver O'Halloran wrote:
> On Tue, Feb 28, 2017 at 4:14 PM, Ananth N Mavinakayanahalli
> <ananth at linux.vnet.ibm.com> wrote:
> > While there, use the helper to add individual records.
> >
> > Signed-off-by: Ananth N Mavinakayanahalli <ananth at linux.vnet.ibm.com>
> > ---
> >  hdata/vpd.c |   95 ++++++++++++++++++++++++++++++-----------------------------
> >  1 file changed, 49 insertions(+), 46 deletions(-)
> >
> > diff --git a/hdata/vpd.c b/hdata/vpd.c
> > index 4c787c6..79f2893 100644
> > --- a/hdata/vpd.c
> > +++ b/hdata/vpd.c
> > @@ -225,54 +225,69 @@ static const struct card_info *card_info_lookup(char *ccin)
> >         return NULL;
> >  }
> >
> > +static void vpd_add_property_string(struct dt_node *n, const char *name,
> > +                                   const void *vpd, unsigned int sz)
> > +{
> > +       char *str = zalloc(sz + 1);
> > +       if (!str)
> > +               return;
> > +       memcpy(str, vpd, sz);
> > +       dt_add_property_string(n, name, str);
> > +       free(str);
> > +}
> > +
> This looks the same as dt_add_property_nstr(). Can we remove this
> helper entirely and use that instead?

yup.. good point.

...

> >         /* Customer Card Identification Number (CCIN) */
> > -       kw = vpd_find(fruvpd, fruvpd_sz, "VINI", "CC", &kwsz);
> > +       kw = vpd_find(fruvpd, fruvpd_sz, "VINI", "CC", &sz);
> >         if (kw) {
> > -               str = zalloc(kwsz + 1);
> > -               if (!str)
> > -                       goto no_memory;
> > -               memcpy(str, kw, kwsz);
> > +               str = zalloc(sz + 1);
> > +               if (!str) {
> > +                       prerror("VPD: memory allocation failure in VINI parsing\n");
> > +                       return;
> > +               }
> > +               memcpy(str, kw, sz);
> >                 dt_add_property_string(node, "ccin", str);
> 
> We can probably use the helper here too if we looked up what we just
> added to the DT, or if card_info_lookup() was tweaked to use
> strncmp().

agreed..

Ananth



More information about the Skiboot mailing list