[PATCH 1/2] firmware: bcm47xx_nvram: allow to read from buffered nvram data

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

 



The bcm47xx code makes a copy of the NVRAM data in ram. Allow access to
this data so property values can be read using nvmem cell api.

[ arinc.unal: Improved patch subject and log ]

Signed-off-by: Willem-Jan de Hoog <wdehoog@xxxxxxxxxxxxxx>
Signed-off-by: Arınç ÜNAL <arinc.unal@xxxxxxxxxx>
---
 drivers/firmware/broadcom/bcm47xx_nvram.c | 14 ++++++++++++++
 include/linux/bcm47xx_nvram.h             |  6 ++++++
 2 files changed, 20 insertions(+)

diff --git a/drivers/firmware/broadcom/bcm47xx_nvram.c b/drivers/firmware/broadcom/bcm47xx_nvram.c
index 5f47dbf4889a..7e5c62dc702f 100644
--- a/drivers/firmware/broadcom/bcm47xx_nvram.c
+++ b/drivers/firmware/broadcom/bcm47xx_nvram.c
@@ -182,6 +182,20 @@ static int nvram_init(void)
 	return -ENXIO;
 }
 
+int bcm47xx_nvram_read(unsigned int offset, char *val, size_t val_len)
+{
+	if (!nvram_len)
+		return -ENXIO;
+
+	if ((offset+val_len) > nvram_len)
+		return -EINVAL;
+
+	while (val_len--)
+		*val++ = nvram_buf[offset++];
+
+	return 0;
+}
+
 int bcm47xx_nvram_getenv(const char *name, char *val, size_t val_len)
 {
 	char *var, *value, *end, *eq;
diff --git a/include/linux/bcm47xx_nvram.h b/include/linux/bcm47xx_nvram.h
index 7615f8d7b1ed..b265b8ce6434 100644
--- a/include/linux/bcm47xx_nvram.h
+++ b/include/linux/bcm47xx_nvram.h
@@ -20,6 +20,7 @@ static inline void bcm47xx_nvram_release_contents(char *nvram)
 {
 	vfree(nvram);
 };
+int bcm47xx_nvram_read(unsigned int offset, char *val, size_t val_len);
 #else
 static inline int bcm47xx_nvram_init_from_iomem(void __iomem *nvram_start,
 						size_t res_size)
@@ -48,6 +49,11 @@ static inline char *bcm47xx_nvram_get_contents(size_t *val_len)
 static inline void bcm47xx_nvram_release_contents(char *nvram)
 {
 };
+
+static inline int bcm47xx_nvram_read(unsigned int offset, char *val, size_t val_len)
+{
+	return -ENOTSUPP;
+}:
 #endif
 
 #endif /* __BCM47XX_NVRAM_H */
-- 
2.37.2




[Index of Archives]     [LKML Archive]     [Linux ARM Kernel]     [Linux ARM]     [Git]     [Yosemite News]     [Linux SCSI]     [Linux Hams]

  Powered by Linux