Re: [PATCH 1/4] device_tree: add qemu_fdt_setprop_reg64 helper

2022-04-19 Thread Alistair Francis
On Mon, Apr 18, 2022 at 7:15 AM Ben Dooks  wrote:
>
> Add a macro qemu_fdt_setprop_reg64() 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 
> ---
>  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..28352e7fcb 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:
> + * @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(fdt, path, map)  \

Maybe the name should include memmap?

qemu_fdt_setprop_reg64_memmap() ?

Alistair

> +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
>
>



[PATCH 1/4] device_tree: add qemu_fdt_setprop_reg64 helper

2022-04-17 Thread Ben Dooks
Add a macro qemu_fdt_setprop_reg64() 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 
---
 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..28352e7fcb 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:
+ * @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(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