diff options
author | Vivek Gautam <vivek.gautam@codeaurora.org> | 2017-01-23 02:02:38 +0300 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2017-01-25 13:49:39 +0300 |
commit | 3b4a687726f0019115bd903d9724db6cdcbb00fe (patch) | |
tree | e6209f4fd1eeae6e56b8dbd5575bdcaee1541001 /drivers/nvmem/core.c | |
parent | 1e928fff9a7444cbfbbb2420eb8cec79bfa53c6f (diff) | |
download | linux-3b4a687726f0019115bd903d9724db6cdcbb00fe.tar.xz |
nvmem: core: Allow ignoring length when reading a cell
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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/nvmem/core.c')
-rw-r--r-- | drivers/nvmem/core.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c index 398ea7f54826..78aa06a578d0 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(). |