Commit fd0c478c authored by Vivek Gautam's avatar Vivek Gautam Committed by Greg Kroah-Hartman

nvmem: core: Allow getting nvmem cell with a NULL cell id

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: default avatarStephen Boyd <sboyd@codeaurora.org>
Signed-off-by: default avatarVivek Gautam <vivek.gautam@codeaurora.org>
Reviewed-by: default avatarStephen Boyd <sboyd@codeaurora.org>
Signed-off-by: default avatarSrinivas Kandagatla <srinivas.kandagatla@linaro.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 29143268
...@@ -747,7 +747,9 @@ static struct nvmem_cell *nvmem_cell_get_from_list(const char *cell_id) ...@@ -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 * of_nvmem_cell_get() - Get a nvmem cell from given device node and cell id
* *
* @np: Device tree node that uses the nvmem cell. * @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 * 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 * 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, ...@@ -760,9 +762,12 @@ struct nvmem_cell *of_nvmem_cell_get(struct device_node *np,
struct nvmem_cell *cell; struct nvmem_cell *cell;
struct nvmem_device *nvmem; struct nvmem_device *nvmem;
const __be32 *addr; 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); cell_np = of_parse_phandle(np, "nvmem-cells", index);
if (!cell_np) if (!cell_np)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment