Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1564590
| From | Srinivas Kandagatla <srinivas.kandagatla@linaro.org> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH 5/5] nvmem: core: Allow getting nvmem cell with a NULL cell id |
| Date | 2017-01-23 00:10 +0100 |
| Message-ID | <t2zqO-73O-15@gated-at.bofh.it> (permalink) |
| References | <t2zqN-73O-5@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
From: Vivek Gautam <vivek.gautam@codeaurora.org> The nvmem cell with a NULL cell name/id should be the one with no accompanying 'nvmem-cell-names' property, and thus will be the cell at index 0 in the device tree. So, we default to index 0 and update the cell index only when nvmem cell name id exists. Suggested-by: Stephen Boyd <sboyd@codeaurora.org> 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 | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c index 9c05921..408b521 100644 --- a/drivers/nvmem/core.c +++ b/drivers/nvmem/core.c @@ -747,7 +747,9 @@ static struct nvmem_cell *nvmem_cell_get_from_list(const char *cell_id) * of_nvmem_cell_get() - Get a nvmem cell from given device node and cell id * * @np: Device tree node that uses the nvmem cell. - * @name: nvmem cell name from nvmem-cell-names property. + * @name: nvmem cell name from nvmem-cell-names property, or NULL + * for the cell at index 0 (the lone cell with no accompanying + * nvmem-cell-names property). * * Return: Will be an ERR_PTR() on error or a valid pointer * to a struct nvmem_cell. The nvmem_cell will be freed by the @@ -760,9 +762,12 @@ struct nvmem_cell *of_nvmem_cell_get(struct device_node *np, struct nvmem_cell *cell; struct nvmem_device *nvmem; const __be32 *addr; - int rval, len, index; + int rval, len; + int index = 0; - index = of_property_match_string(np, "nvmem-cell-names", name); + /* if cell name exists, find index to the name */ + if (name) + index = of_property_match_string(np, "nvmem-cell-names", name); cell_np = of_parse_phandle(np, "nvmem-cells", index); if (!cell_np) -- 2.7.4
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll 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