From: Markus Armbruster <armbru@redhat.com>
To: Li Qiang <liq3ea@gmail.com>
Cc: pbonzini@redhat.com, rth@twiddle.net, ehabkost@redhat.com,
mst@redhat.com, marcel.apfelbaum@gmail.com,
mark.cave-ayland@ilande.co.uk, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH 1/2] hw: pc: use TYPE_XXX instead of constant strings
Date: Tue, 27 Nov 2018 07:59:34 +0100 [thread overview]
Message-ID: <87y39fuht5.fsf@dusky.pond.sub.org> (raw)
In-Reply-To: <1542868372-2602-2-git-send-email-liq3ea@gmail.com> (Li Qiang's message of "Wed, 21 Nov 2018 22:32:51 -0800")
Li Qiang <liq3ea@gmail.com> writes:
> Signed-off-by: Li Qiang <liq3ea@gmail.com>
> ---
> hw/i386/pc.c | 9 +++------
> hw/sparc64/sun4u.c | 2 +-
> include/hw/i386/pc.h | 7 +++++++
> 3 files changed, 11 insertions(+), 7 deletions(-)
>
> diff --git a/hw/i386/pc.c b/hw/i386/pc.c
> index f095725dba..5d3fd86b83 100644
> --- a/hw/i386/pc.c
> +++ b/hw/i386/pc.c
> @@ -502,9 +502,6 @@ void pc_cmos_init(PCMachineState *pcms,
> qemu_register_reset(pc_cmos_init_late, &arg);
> }
>
> -#define TYPE_PORT92 "port92"
> -#define PORT92(obj) OBJECT_CHECK(Port92State, (obj), TYPE_PORT92)
> -
> /* port 92 stuff: could be split off */
> typedef struct Port92State {
> ISADevice parent_obj;
> @@ -1543,10 +1540,10 @@ static void pc_superio_init(ISABus *isa_bus, bool create_fdctrl, bool no_vmport)
> fdctrl_init_isa(isa_bus, fd);
> }
>
> - i8042 = isa_create_simple(isa_bus, "i8042");
> + i8042 = isa_create_simple(isa_bus, TYPE_I8042);
> if (!no_vmport) {
> vmport_init(isa_bus);
> - vmmouse = isa_try_create(isa_bus, "vmmouse");
> + vmmouse = isa_try_create(isa_bus, TYPE_VMMOUSE);
> } else {
> vmmouse = NULL;
> }
> @@ -1555,7 +1552,7 @@ static void pc_superio_init(ISABus *isa_bus, bool create_fdctrl, bool no_vmport)
> qdev_prop_set_ptr(dev, "ps2_mouse", i8042);
> qdev_init_nofail(dev);
> }
> - port92 = isa_create_simple(isa_bus, "port92");
> + port92 = isa_create_simple(isa_bus, TYPE_PORT92);
>
> a20_line = qemu_allocate_irqs(handle_a20_line_change, first_cpu, 2);
> i8042_setup_a20_line(i8042, a20_line[0]);
> diff --git a/hw/sparc64/sun4u.c b/hw/sparc64/sun4u.c
> index f76b19e4e9..c49a416b95 100644
> --- a/hw/sparc64/sun4u.c
> +++ b/hw/sparc64/sun4u.c
> @@ -305,7 +305,7 @@ static void ebus_realize(PCIDevice *pci_dev, Error **errp)
> parallel_hds_isa_init(s->isa_bus, MAX_PARALLEL_PORTS);
>
> /* Keyboard */
> - isa_create_simple(s->isa_bus, "i8042");
> + isa_create_simple(s->isa_bus, TYPE_I8042);
>
> /* Floppy */
> for (i = 0; i < MAX_FD; i++) {
> diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h
> index 136fe497b6..29db770d86 100644
> --- a/include/hw/i386/pc.h
> +++ b/include/hw/i386/pc.h
> @@ -169,6 +169,13 @@ void gsi_handler(void *opaque, int n, int level);
> #define TYPE_VMPORT "vmport"
> typedef uint32_t (VMPortReadFunc)(void *opaque, uint32_t address);
>
> +#define TYPE_PORT92 "port92"
> +#define PORT92(obj) OBJECT_CHECK(Port92State, (obj), TYPE_PORT92)
Why move these to the header? They're used only in hw/i386/pc.c.
> +
> +/* vmmouse.c */
> +#define TYPE_VMMOUSE "vmmouse"
> +#define VMMOUSE(obj) OBJECT_CHECK(VMMouseState, (obj), TYPE_VMMOUSE)
> +
Likewise, why define these in the header?
TYPE_VMMOUSE is used just once, in hw/i386/pc.c. VMMOUSE() isn't used
at all. I'm okay with adding macros anyway, for consistency.
> static inline void vmport_init(ISABus *bus)
> {
> isa_create_simple(bus, TYPE_VMPORT);
next prev parent reply other threads:[~2018-11-27 6:59 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-11-22 6:32 [Qemu-devel] [PATCH 0/2] hw: vmmouse: use link property instead of DEFINE_PROP_PTR Li Qiang
2018-11-22 6:32 ` [Qemu-devel] [PATCH 1/2] hw: pc: use TYPE_XXX instead of constant strings Li Qiang
2018-11-27 6:59 ` Markus Armbruster [this message]
2018-11-27 10:12 ` Li Qiang
2018-11-22 6:32 ` [Qemu-devel] [PATCH 2/2] hw: vmmouse: drop DEFINE_PROP_PTR() Li Qiang
2018-11-27 7:06 ` Markus Armbruster
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=87y39fuht5.fsf@dusky.pond.sub.org \
--to=armbru@redhat.com \
--cc=ehabkost@redhat.com \
--cc=liq3ea@gmail.com \
--cc=marcel.apfelbaum@gmail.com \
--cc=mark.cave-ayland@ilande.co.uk \
--cc=mst@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=rth@twiddle.net \
/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: link
Be 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.