]> git.itanic.dy.fi Git - linux-stable/commit
nvmem: core: add an index parameter to the cell
authorMichael Walle <michael@walle.cc>
Mon, 6 Feb 2023 13:43:46 +0000 (13:43 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 6 Feb 2023 18:06:59 +0000 (19:06 +0100)
commit5d8e6e6c10a3d37486d263b16ddc15991a7e4a88
tree1e697b87dca46cf6d93fc4c007b3c4348f1018d9
parente2d8172043d2e50df19fcd59c11e5593de8188d7
nvmem: core: add an index parameter to the cell

Sometimes a cell can represend multiple values. For example, a base
ethernet address stored in the NVMEM can be expanded into multiple
discreet ones by adding an offset.

For this use case, introduce an index parameter which is then used to
distiguish between values. This parameter will then be passed to the
post process hook which can then use it to create different values
during reading.

At the moment, there is only support for the device tree path. You can
add the index to the phandle, e.g.

  &net {
          nvmem-cells = <&base_mac_address 2>;
          nvmem-cell-names = "mac-address";
  };

  &nvmem_provider {
          base_mac_address: base-mac-address@0 {
                  #nvmem-cell-cells = <1>;
                  reg = <0 6>;
          };
  };

Signed-off-by: Michael Walle <michael@walle.cc>
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Link: https://lore.kernel.org/r/20230206134356.839737-13-srinivas.kandagatla@linaro.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/nvmem/core.c
drivers/nvmem/imx-ocotp.c
include/linux/nvmem-provider.h