lkml.org 
[lkml]   [2017]   [Dec]   [28]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH 1/2] nvmem: add driver for JZ4780 efuse
From
Date
Hi Mathieu, PrasannaKumar,

On 27.12.2017 13:27, Mathieu Malaterre wrote:
> From: PrasannaKumar Muralidharan <prasannatsmkumar@gmail.com>
>
> This patch brings support for the JZ4780 efuse. Currently it only expose
> a read only access to the entire 8K bits efuse memory.
>
> Tested-by: Mathieu Malaterre <malat@debian.org>
> Signed-off-by: PrasannaKumar Muralidharan <prasannatsmkumar@gmail.com>
> ---

> +
> +/* main entry point */
> +static int jz4780_efuse_read(void *context, unsigned int offset,
> + void *val, size_t bytes)
> +{
> + static const int nsegments = sizeof(segments) / sizeof(*segments);
> + struct jz4780_efuse *efuse = context;
> + char buf[32];
> + char *cur = val;
> + int i;
> + /* PM recommends read/write each segment separately */
> + for (i = 0; i < nsegments; ++i) {
> + unsigned int *segment = segments[i];
> + unsigned int lpos = segment[0];
> + unsigned int buflen = segment[1] / 8;
> + unsigned int ncount = buflen / 32;
> + unsigned int remain = buflen % 32;
> + int j;

This doesn't look right, as offset & bytes are completely ignored. This
means it will return data from an offset other than requested and may
also overrun the provided output buffer?

> + /* EFUSE can read or write maximum 256bit in each time */
> + for (j = 0; j < ncount ; ++j) {
> + jz4780_efuse_read_32bytes(efuse, buf, lpos);
> + memcpy(cur, buf, sizeof(buf));
> + cur += sizeof(buf);
> + lpos += sizeof(buf);
> + }
> + if (remain) {
> + jz4780_efuse_read_32bytes(efuse, buf, lpos);
> + memcpy(cur, buf, remain);
> + cur += remain;
> + }
> + }
> +
> + return 0;
> +}


Marcin


\
 
 \ /
  Last update: 2017-12-28 08:15    [W:0.066 / U:0.348 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site