2023-07-18 16:29:05

by Rafał Miłecki

[permalink] [raw]
Subject: [PATCH 1/3] dt-bindings: nvmem: convert U-Boot env to NVMEM layout

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

Use "nvmem-layout" and drop unused "mac" label while at it.

Signed-off-by: Rafał Miłecki <[email protected]>
---
.../bindings/nvmem/layouts/nvmem-layout.yaml | 1 +
.../nvmem/{ => layouts}/u-boot,env.yaml | 17 +++++++++++------
2 files changed, 12 insertions(+), 6 deletions(-)
rename Documentation/devicetree/bindings/nvmem/{ => layouts}/u-boot,env.yaml (87%)

diff --git a/Documentation/devicetree/bindings/nvmem/layouts/nvmem-layout.yaml b/Documentation/devicetree/bindings/nvmem/layouts/nvmem-layout.yaml
index 3b40f7880774..382507060651 100644
--- a/Documentation/devicetree/bindings/nvmem/layouts/nvmem-layout.yaml
+++ b/Documentation/devicetree/bindings/nvmem/layouts/nvmem-layout.yaml
@@ -21,6 +21,7 @@ oneOf:
- $ref: fixed-layout.yaml
- $ref: kontron,sl28-vpd.yaml
- $ref: onie,tlv-layout.yaml
+ - $ref: u-boot,env.yaml

properties:
compatible: true
diff --git a/Documentation/devicetree/bindings/nvmem/u-boot,env.yaml b/Documentation/devicetree/bindings/nvmem/layouts/u-boot,env.yaml
similarity index 87%
rename from Documentation/devicetree/bindings/nvmem/u-boot,env.yaml
rename to Documentation/devicetree/bindings/nvmem/layouts/u-boot,env.yaml
index 36d97fb87865..ebe3b71ba155 100644
--- a/Documentation/devicetree/bindings/nvmem/u-boot,env.yaml
+++ b/Documentation/devicetree/bindings/nvmem/layouts/u-boot,env.yaml
@@ -1,7 +1,7 @@
# 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
@@ -72,11 +72,14 @@ examples:
};

env: partition@40000 {
- compatible = "u-boot,env";
reg = <0x40000 0x10000>;

- mac: ethaddr {
- #nvmem-cell-cells = <1>;
+ nvmem-layout {
+ compatible = "u-boot,env";
+
+ ethaddr {
+ #nvmem-cell-cells = <1>;
+ };
};
};
};
@@ -92,9 +95,11 @@ examples:
label = "u-boot";

partition-u-boot-env {
- compatible = "brcm,env";
+ nvmem-layout {
+ compatible = "brcm,env";

- ethaddr {
+ ethaddr {
+ };
};
};
};
--
2.35.3



2023-07-18 16:52:19

by Rafał Miłecki

[permalink] [raw]
Subject: [PATCH 2/3] nvmem: core: export nvmem device size

From: Michael Walle <[email protected]>

Export the size of the nvmem device. NVMEM layout drivers might need it
and might not have access to the device which is registering the NVMEM
device.

Signed-off-by: Michael Walle <[email protected]>
---
drivers/nvmem/core.c | 13 +++++++++++++
include/linux/nvmem-consumer.h | 6 ++++++
2 files changed, 19 insertions(+)

diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c
index a0c9153cda28..57ccd4422e01 100644
--- a/drivers/nvmem/core.c
+++ b/drivers/nvmem/core.c
@@ -2224,6 +2224,19 @@ const char *nvmem_dev_name(struct nvmem_device *nvmem)
}
EXPORT_SYMBOL_GPL(nvmem_dev_name);

+/**
+ * nvmem_device_size() - Get the size of a given nvmem device.
+ *
+ * @nvmem: nvmem device.
+ *
+ * Return: size of the nvmem device.
+ */
+size_t nvmem_device_size(struct nvmem_device *nvmem)
+{
+ return nvmem->size;
+}
+EXPORT_SYMBOL_GPL(nvmem_device_size);
+
static int __init nvmem_init(void)
{
return bus_register(&nvmem_bus_type);
diff --git a/include/linux/nvmem-consumer.h b/include/linux/nvmem-consumer.h
index fa030d93b768..3270ad81e140 100644
--- a/include/linux/nvmem-consumer.h
+++ b/include/linux/nvmem-consumer.h
@@ -77,6 +77,7 @@ ssize_t nvmem_device_cell_read(struct nvmem_device *nvmem,
struct nvmem_cell_info *info, void *buf);
int nvmem_device_cell_write(struct nvmem_device *nvmem,
struct nvmem_cell_info *info, void *buf);
+size_t nvmem_device_size(struct nvmem_device *nvmem);

const char *nvmem_dev_name(struct nvmem_device *nvmem);

@@ -206,6 +207,11 @@ static inline int nvmem_device_write(struct nvmem_device *nvmem,
return -EOPNOTSUPP;
}

+static inline size_t nvmem_device_size(struct nvmem_device *nvmem)
+{
+ return 0;
+}
+
static inline const char *nvmem_dev_name(struct nvmem_device *nvmem)
{
return NULL;
--
2.35.3


2023-07-19 16:48:21

by Conor Dooley

[permalink] [raw]
Subject: Re: [PATCH 1/3] dt-bindings: nvmem: convert U-Boot env to NVMEM layout

On Tue, Jul 18, 2023 at 06:06:50PM +0200, Rafał Miłecki wrote:
> From: Rafał Miłecki <[email protected]>
>
> Use "nvmem-layout" and drop unused "mac" label while at it.

Stupid question perhaps, does the "old" way of doing this still work
after this series?

Thanks
Conor.

>
> Signed-off-by: Rafał Miłecki <[email protected]>
> ---
> .../bindings/nvmem/layouts/nvmem-layout.yaml | 1 +
> .../nvmem/{ => layouts}/u-boot,env.yaml | 17 +++++++++++------
> 2 files changed, 12 insertions(+), 6 deletions(-)
> rename Documentation/devicetree/bindings/nvmem/{ => layouts}/u-boot,env.yaml (87%)
>
> diff --git a/Documentation/devicetree/bindings/nvmem/layouts/nvmem-layout.yaml b/Documentation/devicetree/bindings/nvmem/layouts/nvmem-layout.yaml
> index 3b40f7880774..382507060651 100644
> --- a/Documentation/devicetree/bindings/nvmem/layouts/nvmem-layout.yaml
> +++ b/Documentation/devicetree/bindings/nvmem/layouts/nvmem-layout.yaml
> @@ -21,6 +21,7 @@ oneOf:
> - $ref: fixed-layout.yaml
> - $ref: kontron,sl28-vpd.yaml
> - $ref: onie,tlv-layout.yaml
> + - $ref: u-boot,env.yaml
>
> properties:
> compatible: true
> diff --git a/Documentation/devicetree/bindings/nvmem/u-boot,env.yaml b/Documentation/devicetree/bindings/nvmem/layouts/u-boot,env.yaml
> similarity index 87%
> rename from Documentation/devicetree/bindings/nvmem/u-boot,env.yaml
> rename to Documentation/devicetree/bindings/nvmem/layouts/u-boot,env.yaml
> index 36d97fb87865..ebe3b71ba155 100644
> --- a/Documentation/devicetree/bindings/nvmem/u-boot,env.yaml
> +++ b/Documentation/devicetree/bindings/nvmem/layouts/u-boot,env.yaml
> @@ -1,7 +1,7 @@
> # 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
> @@ -72,11 +72,14 @@ examples:
> };
>
> env: partition@40000 {
> - compatible = "u-boot,env";
> reg = <0x40000 0x10000>;
>
> - mac: ethaddr {
> - #nvmem-cell-cells = <1>;
> + nvmem-layout {
> + compatible = "u-boot,env";
> +
> + ethaddr {
> + #nvmem-cell-cells = <1>;
> + };
> };
> };
> };
> @@ -92,9 +95,11 @@ examples:
> label = "u-boot";
>
> partition-u-boot-env {
> - compatible = "brcm,env";
> + nvmem-layout {
> + compatible = "brcm,env";
>
> - ethaddr {
> + ethaddr {
> + };
> };
> };
> };
> --
> 2.35.3
>


Attachments:
(No filename) (2.84 kB)
signature.asc (235.00 B)
Download all attachments