nvmem: core: rework nvmem cell instance creation
authorSrinivas Kandagatla <srinivas.kandagatla@linaro.org>
Wed, 13 Oct 2021 13:19:55 +0000 (14:19 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 13 Oct 2021 13:33:17 +0000 (15:33 +0200)
commit7ae6478b304bc004c3139b422665b0e23b57f05c
tree7902df5571aba8b2f6e3b6594bdc928e1ae71483
parent880732ae31e890a568a71eb50d5747284b3c4dbe
nvmem: core: rework nvmem cell instance creation

In the existing design, we do not create a instance per nvmem cell consumer
but we directly refer cell from nvmem cell list that are added to provider.

However this design has some limitations when consumers want to assign name
or connection id the nvmem cell instance, ex: via "nvmem-cell-names" or
id in nvmem_cell_get(id).

Having a name associated with nvmem cell consumer instance will help
provider drivers in performing post processing of nvmem cell data if required
before data is seen by the consumers. This is pretty normal with some vendors
storing nvmem cells like mac-address in a vendor specific data layouts that
are not directly usable by the consumer drivers.

With this patch nvmem cell will be created dynamically during nvmem_cell_get
and destroyed in nvmem_cell_put, allowing consumers to associate name with
nvmem cell consumer instance.

With this patch a new struct nvmem_cell_entry replaces struct nvmem_cell
for storing nvmem cell information within the core.
This patch does not change nvmem-consumer interface based on nvmem_cell.

Tested-by: Joakim Zhang <qiangqing.zhang@nxp.com>
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Link: https://lore.kernel.org/r/20211013131957.30271-2-srinivas.kandagatla@linaro.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/nvmem/core.c