nvmem: stm32: add warning when upper OTPs are updated
authorPatrick Delaunay <patrick.delaunay@foss.st.com>
Fri, 18 Nov 2022 06:39:21 +0000 (06:39 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 23 Nov 2022 18:44:52 +0000 (19:44 +0100)
As the upper OTPs are ECC protected, they support only one 32 bits word
programming.
For a second modification of this word, these ECC become invalid and
this OTP will be no more accessible, the shadowed value is invalid.

This patch adds a warning to indicate an upper OTP update, because this
operation is dangerous as OTP is not locked by the driver after the first
update to avoid a second update.

Signed-off-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Link: https://lore.kernel.org/r/20221118063932.6418-3-srinivas.kandagatla@linaro.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/nvmem/stm32-romem.c

index d93baee01d7b64b3725487b60fe1ed4f33efdc0e..bb8aa72ba2f94c116580823e3197475d7749cb8d 100644 (file)
@@ -132,6 +132,9 @@ static int stm32_bsec_write(void *context, unsigned int offset, void *buf,
                }
        }
 
+       if (offset + bytes >= priv->lower * 4)
+               dev_warn(dev, "Update of upper OTPs with ECC protection (word programming, only once)\n");
+
        return 0;
 }