lkml.org 
[lkml]   [2016]   [Mar]   [2]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCHv7 3/7] eeprom: at24: extend driver to plug into the NVMEM framework
From
Date
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.

> +}
> +
> +static int at24_regmap_write(void *context, const void *data, size_t count)
> +{
> + struct at24_data *at24 = context;
> + const char *buf;
> + u32 offset;
> + size_t len;
> + int err;
> +
> + memcpy(&offset, data, sizeof(offset));
> + buf = (const char *)data + sizeof(offset);
> + len = count - sizeof(offset);
> +
> + err = at24_write(at24, buf, offset, len);
> + if (err)
> + return err;
> + return 0;

return at24_write(at24, buf, offset, len);

Minus another 5 LoC.

--
With best wishes,
Vladimir

\
 
 \ /
  Last update: 2016-03-02 23:21    [W:0.118 / U:1.464 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site