Re: [PATCH V2 6/7] iio: adc: sc27xx: add support for PMIC ump9620

From: Jonathan Cameron
Date: Sat Apr 02 2022 - 13:01:57 EST



> Hi Jonathan:
> It used origin_calib_data in memcpy,and the length of data
> may less than sizeof(u32). we expect the other bits keeps 0;
> So we initialise 0 in here.
Ah. I'd missed that. Thanks for the explanation.

> >
> > > + size_t len = 0;
> > > +
> > > + if (!data)
> > > + return -EINVAL;
> > > +
> > > + cell = nvmem_cell_get(data->dev, cell_name);
> > > + if (IS_ERR(cell))
> > > + return PTR_ERR(cell);
> > > +
> > > + buf = nvmem_cell_read(cell, &len);
> > > + if (IS_ERR(buf)) {
> > > + nvmem_cell_put(cell);
> > > + return PTR_ERR(buf);
> > > + }
> > > +
> > > + memcpy(&origin_calib_data, buf, min(len, sizeof(u32)));
> > > +
> > > + kfree(buf);
> > > + nvmem_cell_put(cell);
> > > + return origin_calib_data;
> > > +}

Jonathan