Re: [PATCH 1/2] nvmem: add driver for JZ4780 efuse

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




Hi Mathieu, PrasannaKumar,

On 27.12.2017 13:27, Mathieu Malaterre wrote:
From: PrasannaKumar Muralidharan <prasannatsmkumar@xxxxxxxxx>

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@xxxxxxxxxx>
Signed-off-by: PrasannaKumar Muralidharan <prasannatsmkumar@xxxxxxxxx>
---

+
+/* 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


--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Device Tree Compilter]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux PCI Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Yosemite Backpacking]


  Powered by Linux