All of lore.kernel.org
 help / color / mirror / Atom feed
From: Willem-Jan de Hoog <arinc9.unal@gmail.com>
To: "Rafał Miłecki" <zajec5@gmail.com>,
	"Srinivas Kandagatla" <srinivas.kandagatla@linaro.org>,
	"Linus Walleij" <linus.walleij@linaro.org>,
	"Willem-Jan de Hoog" <wdehoog@exalondelft.nl>,
	"Florian Fainelli" <f.fainelli@gmail.com>
Cc: "Arınç ÜNAL" <arinc.unal@arinc9.com>,
	"Rafał Miłecki" <rafal@milecki.pl>,
	linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org,
	erkin.bozoglu@xeront.com
Subject: [PATCH 1/2] firmware: bcm47xx_nvram: allow to read from buffered nvram data
Date: Mon,  6 Feb 2023 13:05:01 +0300	[thread overview]
Message-ID: <20230206100502.20243-2-wdehoog@exalondelft.nl> (raw)
In-Reply-To: <20230206100502.20243-1-wdehoog@exalondelft.nl>

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@exalondelft.nl>
Signed-off-by: Arınç ÜNAL <arinc.unal@arinc9.com>
---
 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


  reply	other threads:[~2023-02-06 10:06 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-06 10:05 [PATCH 0/2] nvmem: brcm_nvram: use buffered nvram data for cell values Willem-Jan de Hoog
2023-02-06 10:05 ` Willem-Jan de Hoog [this message]
2023-02-07  6:21   ` [PATCH 1/2] firmware: bcm47xx_nvram: allow to read from buffered nvram data kernel test robot
2023-02-08 16:49   ` kernel test robot
2023-02-15 14:50   ` kernel test robot
2023-02-06 10:05 ` [PATCH 2/2] nvmem: brcm_nvram: use bcm47xx buffered data Willem-Jan de Hoog
2023-02-10  4:47 [PATCH 1/2] firmware: bcm47xx_nvram: allow to read from buffered nvram data kernel test robot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230206100502.20243-2-wdehoog@exalondelft.nl \
    --to=arinc9.unal@gmail.com \
    --cc=arinc.unal@arinc9.com \
    --cc=erkin.bozoglu@xeront.com \
    --cc=f.fainelli@gmail.com \
    --cc=linus.walleij@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mips@vger.kernel.org \
    --cc=rafal@milecki.pl \
    --cc=srinivas.kandagatla@linaro.org \
    --cc=wdehoog@exalondelft.nl \
    --cc=zajec5@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.