linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
To: gregkh@linuxfoundation.org
Cc: linux-kernel@vger.kernel.org, Yangtao Li <tiny.windzz@gmail.com>,
	Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Subject: [PATCH 03/14] nvmem: core: add nvmem_cell_read_u64
Date: Tue, 10 Mar 2020 13:22:46 +0000	[thread overview]
Message-ID: <20200310132257.23358-4-srinivas.kandagatla@linaro.org> (raw)
In-Reply-To: <20200310132257.23358-1-srinivas.kandagatla@linaro.org>

From: Yangtao Li <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>
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
---
 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 b3619f335693..4634af1f6341 100644
--- a/drivers/nvmem/core.c
+++ b/drivers/nvmem/core.c
@@ -1146,6 +1146,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.21.0


  parent reply	other threads:[~2020-03-10 13:24 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-10 13:22 [PATCH 00/14] nvmem: patches for 5.7 Srinivas Kandagatla
2020-03-10 13:22 ` [PATCH 01/14] nvmem: imx: ocotp: add i.MX8MP support Srinivas Kandagatla
2020-03-10 13:22 ` [PATCH 02/14] nvmem: core: add nvmem_cell_read_common Srinivas Kandagatla
2020-03-10 13:22 ` Srinivas Kandagatla [this message]
2020-03-10 13:22 ` [PATCH 04/14] nvmem: remove a stray newline in nvmem_register() Srinivas Kandagatla
2020-03-10 13:22 ` [PATCH 05/14] nvmem: add a newline for readability Srinivas Kandagatla
2020-03-10 13:22 ` [PATCH 06/14] nvmem: fix memory leak in error path Srinivas Kandagatla
2020-03-10 13:22 ` [PATCH 07/14] nvmem: release the write-protect pin Srinivas Kandagatla
2020-03-10 13:22 ` [PATCH 08/14] nvmem: core: validate nvmem config before parsing Srinivas Kandagatla
2020-03-10 13:22 ` [PATCH 09/14] nvmem: check for NULL reg_read and reg_write before dereferencing Srinivas Kandagatla
2020-03-10 13:22 ` [PATCH 10/14] nvmem: imx-ocotp: Drop unnecessary initializations Srinivas Kandagatla
2020-03-10 13:22 ` [PATCH 11/14] Bindings: nvmem: add bindings for JZ4780 efuse Srinivas Kandagatla
2020-03-10 13:22 ` [PATCH 12/14] nvmem: add driver " Srinivas Kandagatla
2020-03-10 13:22 ` [PATCH 13/14] Documentation: ABI: nvmem: add documentation for JZ4780 efuse ABI Srinivas Kandagatla
2020-03-10 13:22 ` [PATCH 14/14] nvmem: jz4780-efuse: fix build warnings on ARCH=x86_64 or riscv 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=20200310132257.23358-4-srinivas.kandagatla@linaro.org \
    --to=srinivas.kandagatla@linaro.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tiny.windzz@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).