Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

nvmem: imx: scu: correct the fuse word index

i.MX8 fuse word row index represented as one 4-bytes word.
Exp:
- MAC0 address layout in fuse:
offset 708: MAC[3] MAC[2] MAC[1] MAC[0]
offset 709: XX xx MAC[5] MAC[4]

The original code takes row index * 4 as the offset, this
not exactly match i.MX8 fuse map documentation.

So update code the reflect the truth.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
Reviewed-by: Fugang Duan <fugang.duan@nxp.com>
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Link: https://lore.kernel.org/r/20200109104017.6249-3-srinivas.kandagatla@linaro.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Peng Fan and committed by
Greg Kroah-Hartman
8c4d35af 40bb95db

+5 -5
+5 -5
drivers/nvmem/imx-ocotp-scu.c
··· 138 138 void *p; 139 139 int i, ret; 140 140 141 - index = offset >> 2; 142 - num_bytes = round_up((offset % 4) + bytes, 4); 141 + index = offset; 142 + num_bytes = round_up(bytes, 4); 143 143 count = num_bytes >> 2; 144 144 145 145 if (count > (priv->data->nregs - index)) ··· 168 168 buf++; 169 169 } 170 170 171 - memcpy(val, (u8 *)p + offset % 4, bytes); 171 + memcpy(val, (u8 *)p, bytes); 172 172 173 173 mutex_unlock(&scu_ocotp_mutex); 174 174 ··· 188 188 int ret; 189 189 190 190 /* allow only writing one complete OTP word at a time */ 191 - if ((bytes != 4) || (offset % 4)) 191 + if (bytes != 4) 192 192 return -EINVAL; 193 193 194 - index = offset >> 2; 194 + index = offset; 195 195 196 196 if (in_hole(context, index)) 197 197 return -EINVAL;