From: Alistair Francis <alistair23@gmail.com> To: Ben Dooks <qemu@ben.fluff.org> Cc: Alistair Francis <Alistair.Francis@wdc.com>, Bin Meng <bin.meng@windriver.com>, Palmer Dabbelt <palmer@dabbelt.com>, "qemu-devel@nongnu.org Developers" <qemu-devel@nongnu.org>, "open list:RISC-V" <qemu-riscv@nongnu.org> Subject: Re: [PATCH 3/4] device_tree: add qemu_fdt_setprop_strings() helper Date: Wed, 20 Apr 2022 08:19:42 +1000 [thread overview] Message-ID: <CAKmqyKOo1kD-eWgpnMgbskyv8pZBuziKjtGDD=4c-X79zq49QA@mail.gmail.com> (raw) In-Reply-To: <20220416193034.538161-4-qemu@ben.fluff.org> On Mon, Apr 18, 2022 at 7:14 AM Ben Dooks <qemu@ben.fluff.org> wrote: > > Add a helper to set a property from a set of strings > to reduce the following code: > > static const char * const clint_compat[2] = { > "sifive,clint0", "riscv,clint0" > }; > > qemu_fdt_setprop_string_array(fdt, nodename, "compatible", > (char **)&clint_compat, ARRAY_SIZE(clint_compat)); > > Signed-off-by: Ben Dooks <qemu@ben.fluff.org> > --- > 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 28352e7fcb..6ad09564d7 100644 > --- a/include/sysemu/device_tree.h > +++ b/include/sysemu/device_tree.h > @@ -87,6 +87,21 @@ int qemu_fdt_setprop_string(void *fdt, const char *node_path, > int qemu_fdt_setprop_string_array(void *fdt, const char *node_path, > const char *prop, char **array, int len); > > +/** > + * qemu_fdt_setprop_strings: set a property from a set of strings > + * > + * @fdt: pointer to the dt blob > + * @name: node name This should be path instead of name (or change prop to name) Alistair > + * @prop: property array > + */ > +#define qemu_fdt_setprop_strings(fdt, path, prop, ...) \ > + do { \ > + static const char * const __strs[] = { __VA_ARGS__ }; \ > + qemu_fdt_setprop_string_array(fdt, path, prop, \ > + (char **)&__strs, ARRAY_SIZE(__strs)); \ > + } while(0) > + > + > int qemu_fdt_setprop_phandle(void *fdt, const char *node_path, > const char *property, > const char *target_node_path); > -- > 2.35.1 > >
WARNING: multiple messages have this Message-ID (diff)
From: Alistair Francis <alistair23@gmail.com> To: Ben Dooks <qemu@ben.fluff.org> Cc: "qemu-devel@nongnu.org Developers" <qemu-devel@nongnu.org>, Palmer Dabbelt <palmer@dabbelt.com>, Alistair Francis <Alistair.Francis@wdc.com>, Bin Meng <bin.meng@windriver.com>, "open list:RISC-V" <qemu-riscv@nongnu.org> Subject: Re: [PATCH 3/4] device_tree: add qemu_fdt_setprop_strings() helper Date: Wed, 20 Apr 2022 08:19:42 +1000 [thread overview] Message-ID: <CAKmqyKOo1kD-eWgpnMgbskyv8pZBuziKjtGDD=4c-X79zq49QA@mail.gmail.com> (raw) In-Reply-To: <20220416193034.538161-4-qemu@ben.fluff.org> On Mon, Apr 18, 2022 at 7:14 AM Ben Dooks <qemu@ben.fluff.org> wrote: > > Add a helper to set a property from a set of strings > to reduce the following code: > > static const char * const clint_compat[2] = { > "sifive,clint0", "riscv,clint0" > }; > > qemu_fdt_setprop_string_array(fdt, nodename, "compatible", > (char **)&clint_compat, ARRAY_SIZE(clint_compat)); > > Signed-off-by: Ben Dooks <qemu@ben.fluff.org> > --- > 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 28352e7fcb..6ad09564d7 100644 > --- a/include/sysemu/device_tree.h > +++ b/include/sysemu/device_tree.h > @@ -87,6 +87,21 @@ int qemu_fdt_setprop_string(void *fdt, const char *node_path, > int qemu_fdt_setprop_string_array(void *fdt, const char *node_path, > const char *prop, char **array, int len); > > +/** > + * qemu_fdt_setprop_strings: set a property from a set of strings > + * > + * @fdt: pointer to the dt blob > + * @name: node name This should be path instead of name (or change prop to name) Alistair > + * @prop: property array > + */ > +#define qemu_fdt_setprop_strings(fdt, path, prop, ...) \ > + do { \ > + static const char * const __strs[] = { __VA_ARGS__ }; \ > + qemu_fdt_setprop_string_array(fdt, path, prop, \ > + (char **)&__strs, ARRAY_SIZE(__strs)); \ > + } while(0) > + > + > int qemu_fdt_setprop_phandle(void *fdt, const char *node_path, > const char *property, > const char *target_node_path); > -- > 2.35.1 > >
next prev parent reply other threads:[~2022-04-19 22:21 UTC|newest] Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top 2022-04-16 19:30 A couple of new device-tree helpers Ben Dooks 2022-04-16 19:30 ` Ben Dooks 2022-04-16 19:30 ` [PATCH 1/4] device_tree: add qemu_fdt_setprop_reg64 helper Ben Dooks 2022-04-16 19:30 ` Ben Dooks 2022-04-19 22:18 ` Alistair Francis 2022-04-19 22:18 ` Alistair Francis 2022-04-16 19:30 ` [PATCH 2/4] hw/riscv: use qemu_fdt_setprop_reg64() in sifive_u.c Ben Dooks 2022-04-16 19:30 ` Ben Dooks 2022-04-16 19:30 ` [PATCH 3/4] device_tree: add qemu_fdt_setprop_strings() helper Ben Dooks 2022-04-16 19:30 ` Ben Dooks 2022-04-19 22:19 ` Alistair Francis [this message] 2022-04-19 22:19 ` Alistair Francis 2022-04-16 19:30 ` [PATCH 4/4] hw/riscv: use qemu_fdt_setprop_strings() in sifive_u.c Ben Dooks 2022-04-16 19:30 ` Ben Dooks 2022-04-17 21:38 ` Ben Dooks 2022-04-17 21:38 ` Ben Dooks 2022-04-22 2:19 ` Bin Meng 2022-04-22 2:19 ` Bin Meng 2022-06-18 19:40 ` Ben Dooks 2022-06-18 20:14 [v2] pair of device-tree helpers Ben Dooks 2022-06-18 20:14 ` [PATCH 3/4] device_tree: add qemu_fdt_setprop_strings() helper Ben Dooks 2022-06-20 6:47 ` Alistair Francis
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to='CAKmqyKOo1kD-eWgpnMgbskyv8pZBuziKjtGDD=4c-X79zq49QA@mail.gmail.com' \ --to=alistair23@gmail.com \ --cc=Alistair.Francis@wdc.com \ --cc=bin.meng@windriver.com \ --cc=palmer@dabbelt.com \ --cc=qemu-devel@nongnu.org \ --cc=qemu-riscv@nongnu.org \ --cc=qemu@ben.fluff.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.