From: Yangtao Li <tiny.windzz@gmail.com>
To: srinivas.kandagatla@linaro.org, linux-kernel@vger.kernel.org
Cc: Yangtao Li <tiny.windzz@gmail.com>
Subject: [PATCH 2/2] nvmem: core: add nvmem_cell_read_u64
Date: Sun, 26 Jan 2020 19:56:19 +0000 [thread overview]
Message-ID: <20200126195619.27596-2-tiny.windzz@gmail.com> (raw)
In-Reply-To: <20200126195619.27596-1-tiny.windzz@gmail.com>
Add nvmem_cell_read_u64() helper to ease read of an u64 value on consumer
side. This helper is useful on some sunxi platform that has 64 bits data
cells stored in no volatile memory.
Signed-off-by: Yangtao Li <tiny.windzz@gmail.com>
---
drivers/nvmem/core.c | 15 +++++++++++++++
include/linux/nvmem-consumer.h | 7 +++++++
2 files changed, 22 insertions(+)
diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c
index f4226546e49a..6c9ad0f75847 100644
--- a/drivers/nvmem/core.c
+++ b/drivers/nvmem/core.c
@@ -1129,6 +1129,21 @@ int nvmem_cell_read_u32(struct device *dev, const char *cell_id, u32 *val)
}
EXPORT_SYMBOL_GPL(nvmem_cell_read_u32);
+/**
+ * nvmem_cell_read_u64() - Read a cell value as an u64
+ *
+ * @dev: Device that requests the nvmem cell.
+ * @cell_id: Name of nvmem cell to read.
+ * @val: pointer to output value.
+ *
+ * Return: 0 on success or negative errno.
+ */
+int nvmem_cell_read_u64(struct device *dev, const char *cell_id, u64 *val)
+{
+ return nvmem_cell_read_common(dev, cell_id, val, sizeof(*val));
+}
+EXPORT_SYMBOL_GPL(nvmem_cell_read_u64);
+
/**
* nvmem_device_cell_read() - Read a given nvmem device and cell
*
diff --git a/include/linux/nvmem-consumer.h b/include/linux/nvmem-consumer.h
index d3776be48c53..1b311d27c9b8 100644
--- a/include/linux/nvmem-consumer.h
+++ b/include/linux/nvmem-consumer.h
@@ -63,6 +63,7 @@ void *nvmem_cell_read(struct nvmem_cell *cell, size_t *len);
int nvmem_cell_write(struct nvmem_cell *cell, void *buf, size_t len);
int nvmem_cell_read_u16(struct device *dev, const char *cell_id, u16 *val);
int nvmem_cell_read_u32(struct device *dev, const char *cell_id, u32 *val);
+int nvmem_cell_read_u64(struct device *dev, const char *cell_id, u64 *val);
/* direct nvmem device read/write interface */
struct nvmem_device *nvmem_device_get(struct device *dev, const char *name);
@@ -138,6 +139,12 @@ static inline int nvmem_cell_read_u32(struct device *dev,
return -EOPNOTSUPP;
}
+static inline int nvmem_cell_read_u64(struct device *dev,
+ const char *cell_id, u64 *val)
+{
+ return -EOPNOTSUPP;
+}
+
static inline struct nvmem_device *nvmem_device_get(struct device *dev,
const char *name)
{
--
2.17.1
next prev parent reply other threads:[~2020-01-26 19:56 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-01-26 19:56 [PATCH 1/2] nvmem: core: add nvmem_cell_read_common Yangtao Li
2020-01-26 19:56 ` Yangtao Li [this message]
2020-02-05 11:50 ` Frank Lee
2020-02-17 10:47 ` Srinivas Kandagatla
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=20200126195619.27596-2-tiny.windzz@gmail.com \
--to=tiny.windzz@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=srinivas.kandagatla@linaro.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox