812-v6.2-0002-nvmem-stm32-add-warning-when-upper-OTPs-are-updated.patch 1.3 KB

12345678910111213141516171819202122232425262728293031323334
  1. From d61784e6410f3df2028e6eb91b06ffed37a660e0 Mon Sep 17 00:00:00 2001
  2. From: Patrick Delaunay <[email protected]>
  3. Date: Fri, 18 Nov 2022 06:39:21 +0000
  4. Subject: [PATCH] nvmem: stm32: add warning when upper OTPs are updated
  5. As the upper OTPs are ECC protected, they support only one 32 bits word
  6. programming.
  7. For a second modification of this word, these ECC become invalid and
  8. this OTP will be no more accessible, the shadowed value is invalid.
  9. This patch adds a warning to indicate an upper OTP update, because this
  10. operation is dangerous as OTP is not locked by the driver after the first
  11. update to avoid a second update.
  12. Signed-off-by: Patrick Delaunay <[email protected]>
  13. Signed-off-by: Srinivas Kandagatla <[email protected]>
  14. Link: https://lore.kernel.org/r/[email protected]
  15. Signed-off-by: Greg Kroah-Hartman <[email protected]>
  16. ---
  17. drivers/nvmem/stm32-romem.c | 3 +++
  18. 1 file changed, 3 insertions(+)
  19. --- a/drivers/nvmem/stm32-romem.c
  20. +++ b/drivers/nvmem/stm32-romem.c
  21. @@ -132,6 +132,9 @@ static int stm32_bsec_write(void *contex
  22. }
  23. }
  24. + if (offset + bytes >= priv->lower * 4)
  25. + dev_warn(dev, "Update of upper OTPs with ECC protection (word programming, only once)\n");
  26. +
  27. return 0;
  28. }