diff mbox series

[1/4] device_tree: add qemu_fdt_setprop_reg64_map helper

Message ID 20220618201433.240973-2-qemu@ben.fluff.org (mailing list archive)
State New, archived
Headers show
Series [1/4] device_tree: add qemu_fdt_setprop_reg64_map helper | expand

Commit Message

Ben Dooks June 18, 2022, 8:14 p.m. UTC
Add a macro qemu_fdt_setprop_reg64_map() to set the given
node's reg property directly from the memory map entry
to avoid open coding of the following:

    qemu_fdt_setprop_cells(fdt, nodename, "reg",
        0x0, memmap[SIFIVE_U_DEV_OTP].base,
        0x0, memmap[SIFIVE_U_DEV_OTP].size);

Signed-off-by: Ben Dooks <qemu@ben.fluff.org>
--
v2:
- changed qemu_fdt_setprop_reg64 to qemu_fdt_setprop_reg64_map
---
 include/sysemu/device_tree.h | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

Comments

Alistair Francis June 20, 2022, 6:41 a.m. UTC | #1
On Sun, Jun 19, 2022 at 6:15 AM Ben Dooks <qemu@ben.fluff.org> wrote:
>
> Add a macro qemu_fdt_setprop_reg64_map() to set the given
> node's reg property directly from the memory map entry
> to avoid open coding of the following:
>
>     qemu_fdt_setprop_cells(fdt, nodename, "reg",
>         0x0, memmap[SIFIVE_U_DEV_OTP].base,
>         0x0, memmap[SIFIVE_U_DEV_OTP].size);
>
> Signed-off-by: Ben Dooks <qemu@ben.fluff.org>
> --
> v2:
> - changed qemu_fdt_setprop_reg64 to qemu_fdt_setprop_reg64_map
> ---
>  include/sysemu/device_tree.h | 15 +++++++++++++++
>  1 file changed, 15 insertions(+)
>
> diff --git a/include/sysemu/device_tree.h b/include/sysemu/device_tree.h
> index ef060a9759..79ce009a22 100644
> --- a/include/sysemu/device_tree.h
> +++ b/include/sysemu/device_tree.h
> @@ -135,6 +135,21 @@ int qemu_fdt_add_path(void *fdt, const char *path);
>                           sizeof(qdt_tmp));                                    \
>      } while (0)
>
> +/**
> + * qemu_fdt_setprop_reg64_map:
> + * @fdt: the device tree path
> + * @node_path: node to set property on
> + * @map: the map entry to set the reg from
> + *
> + * A helper tp set the 'reg' node on the specified node from the given map

A helper to

Otherwise:

Reviewed-by: Alistair Francis <alistair.francis@wdc.com>

Alistair

> + * entry.
> + */
> +#define qemu_fdt_setprop_reg64_map(fdt, path, map)              \
> +    qemu_fdt_setprop_cells(fdt, path, "reg",                    \
> +                           (map)->base >> 32, (map)->base,      \
> +                           (map)->size >> 32, (map)->size)
> +
> +
>  void qemu_fdt_dumpdtb(void *fdt, int size);
>
>  /**
> --
> 2.35.1
>
>
diff mbox series

Patch

diff --git a/include/sysemu/device_tree.h b/include/sysemu/device_tree.h
index ef060a9759..79ce009a22 100644
--- a/include/sysemu/device_tree.h
+++ b/include/sysemu/device_tree.h
@@ -135,6 +135,21 @@  int qemu_fdt_add_path(void *fdt, const char *path);
                          sizeof(qdt_tmp));                                    \
     } while (0)
 
+/**
+ * qemu_fdt_setprop_reg64_map:
+ * @fdt: the device tree path
+ * @node_path: node to set property on
+ * @map: the map entry to set the reg from
+ *
+ * A helper tp set the 'reg' node on the specified node from the given map
+ * entry.
+ */
+#define qemu_fdt_setprop_reg64_map(fdt, path, map)              \
+    qemu_fdt_setprop_cells(fdt, path, "reg",                    \
+                           (map)->base >> 32, (map)->base,      \
+                           (map)->size >> 32, (map)->size)
+
+
 void qemu_fdt_dumpdtb(void *fdt, int size);
 
 /**