From: Vivek Gautam <vivek.gautam@codeaurora.org>
To: srinivas.kandagatla@linaro.org, maxime.ripard@free-electrons.com
Cc: sboyd@codeaurora.org, linux-kernel@vger.kernel.org,
linux-arm-msm@vger.kernel.org,
Vivek Gautam <vivek.gautam@codeaurora.org>
Subject: [PATCH] nvmem: core: Allow ignoring length when reading a cell
Date: Mon, 19 Dec 2016 12:23:09 +0530 [thread overview]
Message-ID: <1482130389-3164-1-git-send-email-vivek.gautam@codeaurora.org> (raw)
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>
---
Based on torvalds's master branch.
- Tested against 'next-20161219' tag on db410c (apq8016) target
for thermal sensors.
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 965911d..4c38842 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 char * buffer on success.
* The buffer should be freed by the consumer with a kfree().
--
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project
next reply other threads:[~2016-12-19 6:53 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-12-19 6:53 Vivek Gautam [this message]
2016-12-19 21:47 ` Stephen Boyd
2016-12-20 4:03 ` Vivek Gautam
2017-01-05 5:34 ` Vivek Gautam
2017-01-05 9:40 ` Srinivas Kandagatla
2017-01-05 9:46 ` Vivek Gautam
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=1482130389-3164-1-git-send-email-vivek.gautam@codeaurora.org \
--to=vivek.gautam@codeaurora.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=maxime.ripard@free-electrons.com \
--cc=sboyd@codeaurora.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
all inboxes | Powered by JetHome®