Skip to content

Commit 165589f

Browse files
brglgregkh
authored andcommitted
nvmem: make the naming of arguments in nvmem_cell_get() consistent
The argument representing the cell name in the nvmem_cell_get() family of functions is not consistend between function prototypes and definitions. Name it 'id' in all those routines. This is in line with other frameworks and can represent both the DT cell name from the nvmem-cell-names property as well as the con_id field from cell lookup entries. Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com> Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent b1c1db9 commit 165589f

File tree

2 files changed

+20
-19
lines changed

2 files changed

+20
-19
lines changed

drivers/nvmem/core.c

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -977,25 +977,24 @@ nvmem_cell_get_from_lookup(struct device *dev, const char *con_id)
977977
* of_nvmem_cell_get() - Get a nvmem cell from given device node and cell id
978978
*
979979
* @np: Device tree node that uses the nvmem cell.
980-
* @name: nvmem cell name from nvmem-cell-names property, or NULL
981-
* for the cell at index 0 (the lone cell with no accompanying
982-
* nvmem-cell-names property).
980+
* @id: nvmem cell name from nvmem-cell-names property, or NULL
981+
* for the cell at index 0 (the lone cell with no accompanying
982+
* nvmem-cell-names property).
983983
*
984984
* Return: Will be an ERR_PTR() on error or a valid pointer
985985
* to a struct nvmem_cell. The nvmem_cell will be freed by the
986986
* nvmem_cell_put().
987987
*/
988-
struct nvmem_cell *of_nvmem_cell_get(struct device_node *np,
989-
const char *name)
988+
struct nvmem_cell *of_nvmem_cell_get(struct device_node *np, const char *id)
990989
{
991990
struct device_node *cell_np, *nvmem_np;
992991
struct nvmem_device *nvmem;
993992
struct nvmem_cell *cell;
994993
int index = 0;
995994

996995
/* if cell name exists, find index to the name */
997-
if (name)
998-
index = of_property_match_string(np, "nvmem-cell-names", name);
996+
if (id)
997+
index = of_property_match_string(np, "nvmem-cell-names", id);
999998

1000999
cell_np = of_parse_phandle(np, "nvmem-cells", index);
10011000
if (!cell_np)
@@ -1025,27 +1024,29 @@ EXPORT_SYMBOL_GPL(of_nvmem_cell_get);
10251024
* nvmem_cell_get() - Get nvmem cell of device form a given cell name
10261025
*
10271026
* @dev: Device that requests the nvmem cell.
1028-
* @cell_id: nvmem cell name to get.
1027+
* @id: nvmem cell name to get (this corresponds with the name from the
1028+
* nvmem-cell-names property for DT systems and with the con_id from
1029+
* the lookup entry for non-DT systems).
10291030
*
10301031
* Return: Will be an ERR_PTR() on error or a valid pointer
10311032
* to a struct nvmem_cell. The nvmem_cell will be freed by the
10321033
* nvmem_cell_put().
10331034
*/
1034-
struct nvmem_cell *nvmem_cell_get(struct device *dev, const char *cell_id)
1035+
struct nvmem_cell *nvmem_cell_get(struct device *dev, const char *id)
10351036
{
10361037
struct nvmem_cell *cell;
10371038

10381039
if (dev->of_node) { /* try dt first */
1039-
cell = of_nvmem_cell_get(dev->of_node, cell_id);
1040+
cell = of_nvmem_cell_get(dev->of_node, id);
10401041
if (!IS_ERR(cell) || PTR_ERR(cell) == -EPROBE_DEFER)
10411042
return cell;
10421043
}
10431044

1044-
/* NULL cell_id only allowed for device tree; invalid otherwise */
1045-
if (!cell_id)
1045+
/* NULL cell id only allowed for device tree; invalid otherwise */
1046+
if (!id)
10461047
return ERR_PTR(-EINVAL);
10471048

1048-
return nvmem_cell_get_from_lookup(dev, cell_id);
1049+
return nvmem_cell_get_from_lookup(dev, id);
10491050
}
10501051
EXPORT_SYMBOL_GPL(nvmem_cell_get);
10511052

include/linux/nvmem-consumer.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ enum {
5555
#if IS_ENABLED(CONFIG_NVMEM)
5656

5757
/* Cell based interface */
58-
struct nvmem_cell *nvmem_cell_get(struct device *dev, const char *name);
59-
struct nvmem_cell *devm_nvmem_cell_get(struct device *dev, const char *name);
58+
struct nvmem_cell *nvmem_cell_get(struct device *dev, const char *id);
59+
struct nvmem_cell *devm_nvmem_cell_get(struct device *dev, const char *id);
6060
void nvmem_cell_put(struct nvmem_cell *cell);
6161
void devm_nvmem_cell_put(struct device *dev, struct nvmem_cell *cell);
6262
void *nvmem_cell_read(struct nvmem_cell *cell, size_t *len);
@@ -91,13 +91,13 @@ int nvmem_unregister_notifier(struct notifier_block *nb);
9191
#else
9292

9393
static inline struct nvmem_cell *nvmem_cell_get(struct device *dev,
94-
const char *name)
94+
const char *id)
9595
{
9696
return ERR_PTR(-ENOSYS);
9797
}
9898

9999
static inline struct nvmem_cell *devm_nvmem_cell_get(struct device *dev,
100-
const char *name)
100+
const char *id)
101101
{
102102
return ERR_PTR(-ENOSYS);
103103
}
@@ -201,12 +201,12 @@ static inline int nvmem_unregister_notifier(struct notifier_block *nb)
201201

202202
#if IS_ENABLED(CONFIG_NVMEM) && IS_ENABLED(CONFIG_OF)
203203
struct nvmem_cell *of_nvmem_cell_get(struct device_node *np,
204-
const char *name);
204+
const char *id);
205205
struct nvmem_device *of_nvmem_device_get(struct device_node *np,
206206
const char *name);
207207
#else
208208
static inline struct nvmem_cell *of_nvmem_cell_get(struct device_node *np,
209-
const char *name)
209+
const char *id)
210210
{
211211
return ERR_PTR(-ENOSYS);
212212
}

0 commit comments

Comments
 (0)