Advertisement
Guest User

Untitled

a guest
Feb 5th, 2023
36
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.06 KB | None | 0 0
  1. --- a/drivers/firmware/broadcom/bcm47xx_nvram.c 2023-02-05 13:19:33.299888563 +0100
  2. +++ b/drivers/firmware/broadcom/bcm47xx_nvram.c 2023-02-05 13:22:28.556220624 +0100
  3. @@ -164,6 +164,20 @@
  4. return -ENXIO;
  5. }
  6.  
  7. +int bcm47xx_nvram_read(unsigned int offset, char *val, size_t val_len)
  8. +{
  9. + if (!nvram_len)
  10. + return -ENXIO;
  11. +
  12. + if ((offset+val_len) > nvram_len)
  13. + return -EINVAL;
  14. +
  15. + while (val_len--)
  16. + *val++ = nvram_buf[offset++];
  17. +
  18. + return 0;
  19. +}
  20. +
  21. int bcm47xx_nvram_getenv(const char *name, char *val, size_t val_len)
  22. {
  23. char *var, *value, *end, *eq;
  24. --- a/include/linux/bcm47xx_nvram.h 2023-02-05 13:03:29.604243964 +0100
  25. +++ b/include/linux/bcm47xx_nvram.h 2023-02-05 13:18:34.899663357 +0100
  26. @@ -20,6 +20,7 @@
  27. {
  28. vfree(nvram);
  29. };
  30. +int bcm47xx_nvram_read(unsigned int offset, char *val, size_t val_len);
  31. #else
  32. static inline int bcm47xx_nvram_init_from_iomem(void __iomem *nvram_start,
  33. size_t res_size)
  34. @@ -48,6 +49,11 @@
  35. static inline void bcm47xx_nvram_release_contents(char *nvram)
  36. {
  37. };
  38. +
  39. +static inline int bcm47xx_nvram_read(unsigned int offset, char *val, size_t val_len)
  40. +{
  41. + return -ENOTSUPP;
  42. +}:
  43. #endif
  44.  
  45. #endif /* __BCM47XX_NVRAM_H */
  46. --- a/drivers/nvmem/brcm_nvram.c 2023-02-05 14:58:33.089372758 +0100
  47. +++ b/drivers/nvmem/brcm_nvram.c 2023-02-05 15:03:03.862249690 +0100
  48. @@ -12,6 +12,7 @@
  49. #include <linux/of.h>
  50. #include <linux/platform_device.h>
  51. #include <linux/slab.h>
  52. +#include <linux/vmalloc.h>
  53.  
  54. #define NVRAM_MAGIC "FLSH"
  55.  
  56. @@ -30,9 +31,17 @@
  57. __le32 config_ncdl; /* ncdl values for memc */
  58. };
  59.  
  60. +int bcm47xx_nvram_read(unsigned int offset, char *val, size_t val_len);
  61. +
  62. static int brcm_nvram_read(void *context, unsigned int offset, void *val,
  63. size_t bytes)
  64. {
  65. +#ifdef CONFIG_BCM47XX_NVRAM
  66. +
  67. + return bcm47xx_nvram_read(offset, val, bytes);
  68. +
  69. +#else
  70. +
  71. struct brcm_nvram *priv = context;
  72. u8 *dst = val;
  73.  
  74. @@ -40,6 +49,8 @@
  75. *dst++ = readb(priv->base + offset++);
  76.  
  77. return 0;
  78. +
  79. +#endif
  80. }
  81.  
  82. static int brcm_nvram_add_cells(struct brcm_nvram *priv, uint8_t *data,
  83.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement