Re: [PATCHv7 3/7] eeprom: at24: extend driver to plug into the NVMEM framework

Andrew Lunn
2016-03-02T21:49:07Z

On Wed, Mar 02, 2016 at 11:46:39PM +0200, Vladimir Zapolskiy wrote:
> Hi Andrew,
>
> On 26.02.2016 21:59, Andrew Lunn wrote:
> > Add a regmap for accessing the EEPROM, and then use that with the
> > NVMEM framework. Set the NVMEM config structure to enable backward, so
> > that the 'eeprom' file in sys is provided by the framework.
> >
> > Signed-off-by: Andrew Lunn <andrew@lunn.ch>
> > Acked-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
> > Tested-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
> > ---
>
> [snip]
>
> > +static int at24_regmap_read(void *context, const void *reg, size_t reg_size,
> > + void *val, size_t val_size)
> > +{
> > + struct at24_data *at24 = context;
> > + off_t offset = *(u32 *)reg;
> > + int err;
> > +
> > + err = at24_read(at24, val, offset, val_size);
> > + if (err)
> > + return err;
> > + return 0;
>
> return at24_read(at24, val, offset, val_size);
>
> Minus 5 LoC.

And everything breaks :-(

regmap expects either an error code, or 0. Return a positive value and
it is not happy.

Andrew