Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1564591

[PATCH 3/5] nvmem: core: Allow ignoring length when reading a cell

From Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Newsgroups linux.kernel
Subject [PATCH 3/5] nvmem: core: Allow ignoring length when reading a cell
Date 2017-01-23 00:10 +0100
Message-ID <t2zqO-73O-19@gated-at.bofh.it> (permalink)
References <t2zqN-73O-5@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


From: Vivek Gautam <vivek.gautam@codeaurora.org>

nvmem_cell_read() API fills in the argument 'len' with
the number of bytes read from the cell. Many users don't
care about this length value. So allow users to pass a
NULL pointer to this len field.

Signed-off-by: Vivek Gautam <vivek.gautam@codeaurora.org>
Reviewed-by: Stephen Boyd <sboyd@codeaurora.org>
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
---
 drivers/nvmem/core.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c
index 398ea7f..78aa06a 100644
--- a/drivers/nvmem/core.c
+++ b/drivers/nvmem/core.c
@@ -970,7 +970,8 @@ static int __nvmem_cell_read(struct nvmem_device *nvmem,
 	if (cell->bit_offset || cell->nbits)
 		nvmem_shift_read_buffer_in_place(cell, buf);
 
-	*len = cell->bytes;
+	if (len)
+		*len = cell->bytes;
 
 	return 0;
 }
@@ -979,7 +980,8 @@ static int __nvmem_cell_read(struct nvmem_device *nvmem,
  * nvmem_cell_read() - Read a given nvmem cell
  *
  * @cell: nvmem cell to be read.
- * @len: pointer to length of cell which will be populated on successful read.
+ * @len: pointer to length of cell which will be populated on successful read;
+ *	 can be NULL.
  *
  * Return: ERR_PTR() on error or a valid pointer to a buffer on success. The
  * buffer should be freed by the consumer with a kfree().
-- 
2.7.4

Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 0/5] nvmem: patches for v4.11 Srinivas Kandagatla <srinivas.kandagatla@linaro.org> - 2017-01-23 00:10 +0100
  [PATCH 2/5] devicetree: bindings: nvmem: Add compatible string for imx6ul Srinivas Kandagatla <srinivas.kandagatla@linaro.org> - 2017-01-23 00:10 +0100
  [PATCH 5/5] nvmem: core: Allow getting nvmem cell with a NULL cell id Srinivas Kandagatla <srinivas.kandagatla@linaro.org> - 2017-01-23 00:10 +0100
  [PATCH 3/5] nvmem: core: Allow ignoring length when reading a cell Srinivas Kandagatla <srinivas.kandagatla@linaro.org> - 2017-01-23 00:10 +0100
  [PATCH 1/5] driver: nvmem: Add ocotp driver support for imx6ul Srinivas Kandagatla <srinivas.kandagatla@linaro.org> - 2017-01-23 00:10 +0100
  Re: [PATCH 0/5] nvmem: patches for v4.11 Greg KH <gregkh@linuxfoundation.org> - 2017-01-25 11:50 +0100

csiph-web