Skip to contentSkip to conversation

nvmem: core: add nvmem_dev_size() helper

PATCH In review Rafał Miłecki 2 participants 8 messages Jan 27, 2023 – Jan 30, 2023

Subsystems (7)
lore
Share & tools
lore
#0 lore raw

PATCH v3 1/6 nvmem: core: add nvmem_dev_size() helper

From: Rafał Miłecki <[email protected]>

This is required by layouts that need to read whole NVMEM space. It applies to NVMEM devices without hardcoded layout (like U-Boot environment data block).

---
V2: Drop "const" from "const size_t"

---
 drivers/nvmem/core.c           | 13 +++++++++++++
 include/linux/nvmem-consumer.h |  1 +
 2 files changed, 14 insertions(+)
drivers/nvmem/core.c +13 -0
index 38a5728bc65c..9e77af0164aa 100644
@@ -2063,6 +2063,19 @@ void nvmem_del_cell_lookups(struct nvmem_cell_lookup *entries, size_t nentries)
 }
 EXPORT_SYMBOL_GPL(nvmem_del_cell_lookups);
 
+/**
+ * nvmem_dev_size() - Get the size of a given nvmem device.
+ *
+ * @nvmem: nvmem device.
+ *
+ * Return: size of the nvmem device.
+ */
+size_t nvmem_dev_size(struct nvmem_device *nvmem)
+{
+	return nvmem->size;
+}
+EXPORT_SYMBOL_GPL(nvmem_dev_size);
+
 /**
  * nvmem_dev_name() - Get the name of a given nvmem device.
  *
include/linux/nvmem-consumer.h +1 -0
index fa030d93b768..c3005ab6cc4f 100644
@@ -78,6 +78,7 @@ ssize_t nvmem_device_cell_read(struct nvmem_device *nvmem,
 int nvmem_device_cell_write(struct nvmem_device *nvmem,
 			    struct nvmem_cell_info *info, void *buf);
 
+size_t nvmem_dev_size(struct nvmem_device *nvmem);
 const char *nvmem_dev_name(struct nvmem_device *nvmem);
 
 void nvmem_add_cell_lookups(struct nvmem_cell_lookup *entries,
Signature · 1 line
2.34.1
#1 lore raw

PATCH v3 2/6 nvmem: core: allow .read_post_process() callbacks to adjust buffer

From: Rafał Miłecki <[email protected]>

Sometimes reading NVMEM cell value involves some data reformatting. it may require resizing available buffer. Support that.

It's required e.g. to provide properly formatted MAC address in case it's stored in a non-binary format (e.g. using ASCII).

---
V2: Pass buffer pointer to allow krealloc() if needed
V3: Don't move unnecessarily code setting *len

---
 drivers/nvmem/core.c             | 21 +++++++++++++--------
 drivers/nvmem/imx-ocotp.c        |  8 ++++----
 drivers/nvmem/layouts/onie-tlv.c |  5 ++---
 drivers/nvmem/layouts/sl28vpd.c  | 10 +++++-----
 include/linux/nvmem-provider.h   |  5 ++---
 5 files changed, 26 insertions(+), 23 deletions(-)
drivers/nvmem/core.c +13 -8
index 9e77af0164aa..162054a39fa1 100644
@@ -1540,28 +1540,29 @@ static void nvmem_shift_read_buffer_in_place(struct nvmem_cell_entry *cell, void
 
 static int __nvmem_cell_read(struct nvmem_device *nvmem,
 			     struct nvmem_cell_entry *cell,
-			     void *buf, size_t *len, const char *id, int index)
+			     void **buf, size_t *len, const char *id, int index)
 {
+	size_t bytes = cell->bytes;
 	int rc;
 
-	rc = nvmem_reg_read(nvmem, cell->offset, buf, cell->bytes);
+	rc = nvmem_reg_read(nvmem, cell->offset, *buf, bytes);
 
 	if (rc)
 		return rc;
 
 	/* shift bits in-place */
 	if (cell->bit_offset || cell->nbits)
-		nvmem_shift_read_buffer_in_place(cell, buf);
+		nvmem_shift_read_buffer_in_place(cell, *buf);
 
 	if (cell->read_post_process) {
 		rc = cell->read_post_process(cell->priv, id, index,
-					     cell->offset, buf, cell->bytes);
+					     cell->offset, buf, &bytes);
 		if (rc)
 			return rc;
 	}
 
 	if (len)
-		*len = cell->bytes;
+		*len = bytes;
 
 	return 0;
 }
@@ -1579,7 +1580,7 @@ static int __nvmem_cell_read(struct nvmem_device *nvmem,
 void *nvmem_cell_read(struct nvmem_cell *cell, size_t *len)
 {
 	struct nvmem_device *nvmem = cell->entry->nvmem;
-	u8 *buf;
+	void *buf;
 	int rc;
 
 	if (!nvmem)
@@ -1589,7 +1590,7 @@ void *nvmem_cell_read(struct nvmem_cell *cell, size_t *len)
 	if (!buf)
 		return ERR_PTR(-ENOMEM);
 
-	rc = __nvmem_cell_read(nvmem, cell->entry, buf, len, cell->id, cell->index);
+	rc = __nvmem_cell_read(nvmem, cell->entry, &buf, len, cell->id, cell->index);
 	if (rc) {
 		kfree(buf);
 		return ERR_PTR(rc);
@@ -1906,11 +1907,15 @@ ssize_t nvmem_device_cell_read(struct nvmem_device *nvmem,
 	if (!nvmem)
 		return -EINVAL;
 
+	/* Cells with read_post_process hook may realloc buffer we can't allow here */
+	if (info->read_post_process)
+		return -EINVAL;
+
 	rc = nvmem_cell_info_to_nvmem_cell_entry_nodup(nvmem, info, &cell);
 	if (rc)
 		return rc;
 
-	rc = __nvmem_cell_read(nvmem, &cell, buf, &len, NULL, 0);
+	rc = __nvmem_cell_read(nvmem, &cell, &buf, &len, NULL, 0);
 	if (rc)
 		return rc;
 
drivers/nvmem/imx-ocotp.c +4 -4
index ac0edb6398f1..e17500bc0acc 100644
@@ -223,15 +223,15 @@ static int imx_ocotp_read(void *context, unsigned int offset,
 }
 
 static int imx_ocotp_cell_pp(void *context, const char *id, int index,
-			     unsigned int offset, void *data, size_t bytes)
+			     unsigned int offset, void **data, size_t *bytes)
 {
-	u8 *buf = data;
+	u8 *buf = *data;
 	int i;
 
 	/* Deal with some post processing of nvmem cell data */
 	if (id && !strcmp(id, "mac-address"))
-		for (i = 0; i < bytes / 2; i++)
-			swap(buf[i], buf[bytes - i - 1]);
+		for (i = 0; i < *bytes / 2; i++)
+			swap(buf[i], buf[*bytes - i - 1]);
 
 	return 0;
 }
drivers/nvmem/layouts/onie-tlv.c +2 -3
index 767f39fff717..f26bcce2a44d 100644
@@ -75,10 +75,9 @@ static const char *onie_tlv_cell_name(u8 type)
 }
 
 static int onie_tlv_mac_read_cb(void *priv, const char *id, int index,
-				unsigned int offset, void *buf,
-				size_t bytes)
+				unsigned int offset, void **buf, size_t *bytes)
 {
-	eth_addr_add(buf, index);
+	eth_addr_add(*buf, index);
 
 	return 0;
 }
drivers/nvmem/layouts/sl28vpd.c +5 -5
index a36800f201a3..869cb513d79a 100644
@@ -22,19 +22,19 @@ struct sl28vpd_v1 {
 } __packed;
 
 static int sl28vpd_mac_address_pp(void *priv, const char *id, int index,
-				  unsigned int offset, void *buf,
-				  size_t bytes)
+				  unsigned int offset, void **buf,
+				  size_t *bytes)
 {
-	if (bytes != ETH_ALEN)
+	if (*bytes != ETH_ALEN)
 		return -EINVAL;
 
 	if (index < 0)
 		return -EINVAL;
 
-	if (!is_valid_ether_addr(buf))
+	if (!is_valid_ether_addr(*buf))
 		return -EINVAL;
 
-	eth_addr_add(buf, index);
+	eth_addr_add(*buf, index);
 
 	return 0;
 }
include/linux/nvmem-provider.h +2 -3
index 0cf9f9490514..e70766013f97 100644
@@ -19,9 +19,8 @@ typedef int (*nvmem_reg_read_t)(void *priv, unsigned int offset,
 typedef int (*nvmem_reg_write_t)(void *priv, unsigned int offset,
 				 void *val, size_t bytes);
 /* used for vendor specific post processing of cell data */
-typedef int (*nvmem_cell_post_process_t)(void *priv, const char *id, int index,
-					 unsigned int offset, void *buf,
-					 size_t bytes);
+typedef int (*nvmem_cell_post_process_t)(void *priv, const char *id, int index, unsigned int offset,
+					 void **buf, size_t *bytes);
 
 enum nvmem_type {
 	NVMEM_TYPE_UNKNOWN = 0,
Signature · 1 line
2.34.1
#2 lore raw

PATCH v3 3/6 dt-bindings: nvmem: convert U-Boot env vars to NVMEM layout

In reply to Rafał Miłecki

From: Rafał Miłecki <[email protected]>

U-Boot environment variables can be found of various underlaying storage entities. This binding should be defined as a layout on top on NVMEM device not a NVMEM device itself.

---
 .../bindings/nvmem/layouts/nvmem-layout.yaml  |  1 +
 .../nvmem/{ => layouts}/u-boot,env.yaml       | 29 ++++++++++---------
 MAINTAINERS                                   |  2 +-
 3 files changed, 17 insertions(+), 15 deletions(-)
 rename Documentation/devicetree/bindings/nvmem/{ => layouts}/u-boot,env.yaml (77%)
Documentation/devicetree/bindings/nvmem/layouts/nvmem-layout.yaml +1 -0
index 8512ee538c4c..8835b1781a9f 100644
@@ -20,6 +20,7 @@ description: |
 oneOf:
   - $ref: kontron,sl28-vpd.yaml
   - $ref: onie,tlv-layout.yaml
+  - $ref: u-boot,env.yaml
 
 properties:
   compatible: true
Documentation/devicetree/bindings/nvmem/layouts/u-boot,env.yaml renamed from Documentation/devicetree/bindings/nvmem/u-boot,env.yaml +15 -14
similarity index 77%
rename from Documentation/devicetree/bindings/nvmem/u-boot,env.yaml
rename to Documentation/devicetree/bindings/nvmem/layouts/u-boot,env.yaml
index cbc5c69fd405..fb273b174fe7 100644
@@ -1,10 +1,10 @@
 # SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
 %YAML 1.2
 ---
-$id: http://devicetree.org/schemas/nvmem/u-boot,env.yaml#
+$id: http://devicetree.org/schemas/nvmem/layouts/u-boot,env.yaml#
 $schema: http://devicetree.org/meta-schemas/core.yaml#
 
-title: U-Boot environment variables
+title: NVMEM layout of U-Boot environment variables
 
 description: |
   U-Boot uses environment variables to store device parameters and
@@ -14,16 +14,11 @@ description: |
   Data is stored using U-Boot specific formats (variant specific header and NUL
   separated key-value pairs).
 
-  Environment data can be stored on various storage entities, e.g.:
+  Environment data can be stored on NVMEM devices of various underlaying storage
+  entities, e.g.:
   1. Raw flash partition
   2. UBI volume
 
-  This binding allows marking storage device (as containing env data) and
-  specifying used format.
-
-  Right now only flash partition case is covered but it may be extended to e.g.
-  UBI volumes in the future.
-
   Variables can be defined as NVMEM device subnodes.
 
 maintainers:
@@ -67,11 +62,14 @@ examples:
             read-only;
         };
 
-        env: partition@40000 {
-            compatible = "u-boot,env";
+        partition@40000 {
             reg = <0x40000 0x10000>;
 
-            mac: ethaddr {
+            nvmem-layout {
+                compatible = "u-boot,env";
+
+                mac: ethaddr {
+                };
             };
         };
     };
@@ -87,9 +85,12 @@ examples:
             label = "u-boot";
 
             partition-u-boot-env {
-                compatible = "brcm,env";
 
-                ethaddr {
+                nvmem-layout {
+                    compatible = "brcm,env";
+
+                    ethaddr {
+                    };
                 };
             };
         };
MAINTAINERS +1 -1
index 35385df2302c..1373154c0b49 100644
@@ -21214,7 +21214,7 @@ F:	drivers/media/pci/tw686x/
 U-BOOT ENVIRONMENT VARIABLES
 M:	Rafał Miłecki <[email protected]>
 S:	Maintained
-F:	Documentation/devicetree/bindings/nvmem/u-boot,env.yaml
+F:	Documentation/devicetree/bindings/nvmem/layouts/u-boot,env.yaml
 F:	drivers/nvmem/u-boot-env.c
 
 UACCE ACCELERATOR FRAMEWORK
Signature · 1 line
2.34.1
#3 lore raw

PATCH v3 4/6 nvmem: u-boot-env: convert to layout driver

In reply to Rafał Miłecki

From: Rafał Miłecki <[email protected]>

U-Boot environment variables can be found on various NVMEM devices (not just MTD) so convert this driver to a generic layout one.

This way - thanks to using NVMEM generic API - this driver can be reused in other scenarios.

For backward DT compatibility we need to support the old compatible brinding string for now. Luckily it's just a one line of code.

---
 MAINTAINERS                        |   2 +-
 drivers/mtd/mtdcore.c              |   7 +-
 drivers/nvmem/Kconfig              |  14 +-
 drivers/nvmem/Makefile             |   2 -
 drivers/nvmem/layouts/Kconfig      |  10 ++
 drivers/nvmem/layouts/Makefile     |   1 +
 drivers/nvmem/layouts/u-boot-env.c | 176 ++++++++++++++++++++++
 drivers/nvmem/u-boot-env.c         | 233 -----------------------------
 8 files changed, 199 insertions(+), 246 deletions(-)
 create mode 100644 drivers/nvmem/layouts/u-boot-env.c
 delete mode 100644 drivers/nvmem/u-boot-env.c
MAINTAINERS +1 -1
index 1373154c0b49..3f58e14fba6f 100644
@@ -21215,7 +21215,7 @@ U-BOOT ENVIRONMENT VARIABLES
 M:	Rafał Miłecki <[email protected]>
 S:	Maintained
 F:	Documentation/devicetree/bindings/nvmem/layouts/u-boot,env.yaml
-F:	drivers/nvmem/u-boot-env.c
+F:	drivers/nvmem/layouts/u-boot-env.c
 
 UACCE ACCELERATOR FRAMEWORK
 M:	Zhangfei Gao <[email protected]>
drivers/mtd/mtdcore.c +6 -1
index 0feacb9fbdac..621e0b87b781 100644
@@ -518,6 +518,11 @@ static int mtd_nvmem_add(struct mtd_info *mtd)
 {
 	struct device_node *node = mtd_get_of_node(mtd);
 	struct nvmem_config config = {};
+	bool use_dev_of_node = false;
+
+	if (of_device_is_compatible(node, "nvmem-cells") ||
+	    (IS_ENABLED(CONFIG_NVMEM_U_BOOT_ENV) && of_device_is_compatible(node, "brcm,env")))
+		use_dev_of_node = true;
 
 	config.id = -1;
 	config.dev = &mtd->dev;
@@ -530,7 +535,7 @@ static int mtd_nvmem_add(struct mtd_info *mtd)
 	config.read_only = true;
 	config.root_only = true;
 	config.ignore_wp = true;
-	config.no_of_node = !of_device_is_compatible(node, "nvmem-cells");
+	config.no_of_node = !use_dev_of_node;
 	config.priv = mtd;
 
 	mtd->nvmem = nvmem_register(&config);
drivers/nvmem/Kconfig +5 -9
index ed8ef7460be2..789729ff7e50 100644
@@ -338,17 +338,13 @@ config NVMEM_SUNXI_SID
 	  will be called nvmem_sunxi_sid.
 
 config NVMEM_U_BOOT_ENV
-	tristate "U-Boot environment variables support"
+	bool "U-Boot environment variables deprecated binding support"
 	depends on OF && MTD
-	select CRC32
+	select NVMEM_LAYOUT_U_BOOT_ENV
 	help
-	  U-Boot stores its setup as environment variables. This driver adds
-	  support for verifying & exporting such data. It also exposes variables
-	  as NVMEM cells so they can be referenced by other drivers.
-
-	  Currently this drivers works only with env variables on top of MTD.
-
-	  If compiled as module it will be called nvmem_u-boot-env.
+	  This option enables support for deprecated DT binding for U-Boot
+	  environment variables. It was used by DT files before introducing
+	  nvmem-layout node based syntax.
 
 config NVMEM_UNIPHIER_EFUSE
 	tristate "UniPhier SoCs eFuse support"
drivers/nvmem/Makefile +0 -2
index f82431ec8aef..442f9a4876a5 100644
@@ -67,8 +67,6 @@ obj-$(CONFIG_NVMEM_SUNPLUS_OCOTP)	+= nvmem_sunplus_ocotp.o
 nvmem_sunplus_ocotp-y			:= sunplus-ocotp.o
 obj-$(CONFIG_NVMEM_SUNXI_SID)		+= nvmem_sunxi_sid.o
 nvmem_sunxi_sid-y			:= sunxi_sid.o
-obj-$(CONFIG_NVMEM_U_BOOT_ENV)		+= nvmem_u-boot-env.o
-nvmem_u-boot-env-y			:= u-boot-env.o
 obj-$(CONFIG_NVMEM_UNIPHIER_EFUSE)	+= nvmem-uniphier-efuse.o
 nvmem-uniphier-efuse-y			:= uniphier-efuse.o
 obj-$(CONFIG_NVMEM_VF610_OCOTP)		+= nvmem-vf610-ocotp.o
drivers/nvmem/layouts/Kconfig +10 -0
index 9ad50474cb77..8a38c514943a 100644
@@ -20,4 +20,14 @@ config NVMEM_LAYOUT_ONIE_TLV
 
 	  If unsure, say N.
 
+config NVMEM_LAYOUT_U_BOOT_ENV
+	bool "U-Boot environment variables support"
+	select CRC32
+	help
+	  U-Boot stores its setup as environment variables. This driver adds
+	  support for verifying & exporting such data. It also exposes variables
+	  as NVMEM cells so they can be referenced by other drivers.
+
+	  If unsure, say N.
+
 endmenu
drivers/nvmem/layouts/Makefile +1 -0
index 2974bd7d33ed..4940c9db0665 100644
@@ -5,3 +5,4 @@
 
 obj-$(CONFIG_NVMEM_LAYOUT_SL28_VPD) += sl28vpd.o
 obj-$(CONFIG_NVMEM_LAYOUT_ONIE_TLV) += onie-tlv.o
+obj-$(CONFIG_NVMEM_LAYOUT_U_BOOT_ENV) += u-boot-env.o
drivers/nvmem/layouts/u-boot-env.c new file +176 -0

176 lines not on this page · raw message

drivers/nvmem/u-boot-env.c deleted +0 -233

233 lines not on this page · raw message

Signature · 1 line
2.34.1
#4 lore raw

PATCH v3 5/6 dt-bindings: nvmem: u-boot,env: add MAC's #nvmem-cell-cells

In reply to Rafał Miłecki

From: Rafał Miłecki <[email protected]>

U-Boot's "ethaddr" environment variable is very often used to store *base* MAC address. It's used as a base for calculating addresses for multiple interfaces. It's done by adding proper values. Actual offsets are picked by manufacturers and vary across devices.

---
 .../devicetree/bindings/nvmem/layouts/u-boot,env.yaml      | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
Documentation/devicetree/bindings/nvmem/layouts/u-boot,env.yaml +6 -1
index fb273b174fe7..dbff702f2e5d 100644
@@ -45,7 +45,11 @@ properties:
 
   ethaddr:
     type: object
-    description: Ethernet interface's MAC address
+    description: Ethernet interfaces base MAC address.
+    properties:
+      "#nvmem-cell-cells":
+        description: The first argument is a MAC address offset.
+        const: 1
 
 additionalProperties: false
 
@@ -69,6 +73,7 @@ examples:
                 compatible = "u-boot,env";
 
                 mac: ethaddr {
+                    #nvmem-cell-cells = <1>;
                 };
             };
         };
Signature · 1 line
2.34.1
#5 lore raw

PATCH v3 6/6 nvmem: u-boot-env: post process "ethaddr" env variable

In reply to Rafał Miłecki

From: Rafał Miłecki <[email protected]>

U-Boot environment variables are stored in ASCII format so "ethaddr" requires parsing into binary to make it work with Ethernet interfaces.

This includes support for indexes to support #nvmem-cell-cells = <1>.

---
 drivers/nvmem/layouts/Kconfig      |  1 +
 drivers/nvmem/layouts/u-boot-env.c | 25 +++++++++++++++++++++++++
 2 files changed, 26 insertions(+)
drivers/nvmem/layouts/Kconfig +1 -0
index 8a38c514943a..566b4f25630d 100644
@@ -23,6 +23,7 @@ config NVMEM_LAYOUT_ONIE_TLV
 config NVMEM_LAYOUT_U_BOOT_ENV
 	bool "U-Boot environment variables support"
 	select CRC32
+	select GENERIC_NET_UTILS
 	help
 	  U-Boot stores its setup as environment variables. This driver adds
 	  support for verifying & exporting such data. It also exposes variables
drivers/nvmem/layouts/u-boot-env.c +25 -0
index 95c314553952..e99b853a44c4 100644
@@ -4,6 +4,8 @@
  */
 
 #include <linux/crc32.h>
+#include <linux/etherdevice.h>
+#include <linux/if_ether.h>
 #include <linux/mod_devicetable.h>
 #include <linux/module.h>
 #include <linux/nvmem-consumer.h>
@@ -36,6 +38,27 @@ struct u_boot_env_image_broadcom {
 	uint8_t data[];
 } __packed;
 
+static int u_boot_env_read_post_process_ethaddr(void *context, const char *id, int index,
+						unsigned int offset, void **data, size_t *bytes)
+{
+	u8 mac[ETH_ALEN];
+
+	if (*bytes != 3 * ETH_ALEN - 1)
+		return -EINVAL;
+
+	if (!mac_pton(*data, mac))
+		return -EINVAL;
+
+	if (index)
+		eth_addr_add(mac, index);
+
+	/* We need *smaller* buffer so don't bother to krealloc() */
+	ether_addr_copy(*data, mac);
+	*bytes = ETH_ALEN;
+
+	return 0;
+}
+
 static int u_boot_env_parse_data(struct device *dev, struct nvmem_device *nvmem, uint8_t *buf,
 				 size_t data_offset, size_t data_len)
 {
@@ -67,6 +90,8 @@ static int u_boot_env_parse_data(struct device *dev, struct nvmem_device *nvmem,
 		info.offset = data_offset + value - data;
 		info.bytes = strlen(value);
 		info.np = of_get_child_by_name(np, info.name);
+		if (!strcmp(var, "ethaddr"))
+			info.read_post_process = u_boot_env_read_post_process_ethaddr;
 
 		err = nvmem_add_one_cell(nvmem, &info);
 		if (err) {
Signature · 1 line
2.34.1
maintainer Reviewed-by on v3 1/6
#6 lore raw
In reply to Rafał Miłecki

Hi Rafał,

[email protected] wrote on Fri, 27 Jan 2023 13:57:04 +0100:

Quoted 9 lines

From: Rafał Miłecki <[email protected]>

This is required by layouts that need to read whole NVMEM space. It applies to NVMEM devices without hardcoded layout (like U-Boot environment data block).

---
V2: Drop "const" from "const size_t"

It would be good if you could always add a cover-letter, just so that we can reply to the whole series. In my case I wanted to add a global

Because I gave this series a quick review and it looks good to me.

Thanks,
Miquèl

Quoted 41 lines
---
 drivers/nvmem/core.c           | 13 +++++++++++++
 include/linux/nvmem-consumer.h |  1 +
 2 files changed, 14 insertions(+)
drivers/nvmem/core.c +13 -0
index 38a5728bc65c..9e77af0164aa 100644
@@ -2063,6 +2063,19 @@ void nvmem_del_cell_lookups(struct nvmem_cell_lookup *entries, size_t nentries)
 }
 EXPORT_SYMBOL_GPL(nvmem_del_cell_lookups);
 
+/**
+ * nvmem_dev_size() - Get the size of a given nvmem device.
+ *
+ * @nvmem: nvmem device.
+ *
+ * Return: size of the nvmem device.
+ */
+size_t nvmem_dev_size(struct nvmem_device *nvmem)
+{
+	return nvmem->size;
+}
+EXPORT_SYMBOL_GPL(nvmem_dev_size);
+
 /**
  * nvmem_dev_name() - Get the name of a given nvmem device.
  *
include/linux/nvmem-consumer.h +1 -0
index fa030d93b768..c3005ab6cc4f 100644
@@ -78,6 +78,7 @@ ssize_t nvmem_device_cell_read(struct nvmem_device *nvmem,
 int nvmem_device_cell_write(struct nvmem_device *nvmem,
 			    struct nvmem_cell_info *info, void *buf);
 
+size_t nvmem_dev_size(struct nvmem_device *nvmem);
 const char *nvmem_dev_name(struct nvmem_device *nvmem);
 
 void nvmem_add_cell_lookups(struct nvmem_cell_lookup *entries,
#7 lore raw
Quoted 14 lines · Miquel Raynal

Hi Rafał,

[email protected] wrote on Fri, 27 Jan 2023 13:57:04 +0100:

Quoted 9 lines

From: Rafał Miłecki <[email protected]>

This is required by layouts that need to read whole NVMEM space. It applies to NVMEM devices without hardcoded layout (like U-Boot environment data block).

---
V2: Drop "const" from "const size_t"

Quoted 6 lines

It would be good if you could always add a cover-letter, just so that we can reply to the whole series. In my case I wanted to add a global

Because I gave this series a quick review and it looks good to me.

Good point, I'll keep that in mind and do that in future for all bigger series.
Thank you.