----- Original Message ----- > From: "Marcel Apfelbaum" <mar...@redhat.com> > To: "Eduardo Habkost" <ehabk...@redhat.com>, qemu-devel@nongnu.org > Cc: "Paolo Bonzini" <pbonz...@redhat.com>, "Andrzej Zaborowski" > <balr...@gmail.com>, "Peter Maydell" > <peter.mayd...@linaro.org>, "Michael S. Tsirkin" <m...@redhat.com>, > "Alexander Graf" <ag...@suse.de> > Sent: Wednesday, June 8, 2016 1:25:41 PM > Subject: Re: [PATCH] vl: Eliminate usb_enabled() > > On 06/07/2016 07:56 PM, Eduardo Habkost wrote: > > This wrapper for machine_usb(current_machine) is not necessary, > > replace all usages of usb_enabled() with machine_usb(). > > > > Signed-off-by: Eduardo Habkost <ehabk...@redhat.com> > > --- > > hw/arm/nseries.c | 2 +- > > hw/arm/pxa2xx.c | 7 +++++-- > > hw/arm/realview.c | 2 +- > > hw/arm/versatilepb.c | 2 +- > > hw/i386/pc_piix.c | 2 +- > > hw/i386/pc_q35.c | 2 +- > > hw/ppc/mac_oldworld.c | 2 +- > > hw/ppc/prep.c | 2 +- > > include/sysemu/sysemu.h | 1 - > > vl.c | 11 +++-------- > > 10 files changed, 15 insertions(+), 18 deletions(-) > > > > diff --git a/hw/arm/nseries.c b/hw/arm/nseries.c > > index d4eb141..fea911e 100644 > > --- a/hw/arm/nseries.c > > +++ b/hw/arm/nseries.c > > @@ -1351,7 +1351,7 @@ static void n8x0_init(MachineState *machine, > > n8x0_dss_setup(s); > > n8x0_cbus_setup(s); > > n8x0_uart_setup(s); > > - if (usb_enabled()) { > > + if (machine_usb(machine)) { > > n8x0_usb_setup(s); > > } > > > > diff --git a/hw/arm/pxa2xx.c b/hw/arm/pxa2xx.c > > index e41a7c9..6d8606d 100644 > > --- a/hw/arm/pxa2xx.c > > +++ b/hw/arm/pxa2xx.c > > @@ -13,6 +13,7 @@ > > #include "cpu.h" > > #include "hw/sysbus.h" > > #include "hw/arm/pxa.h" > > +#include "hw/boards.h" > > #include "sysemu/sysemu.h" > > #include "hw/char/serial.h" > > #include "hw/i2c/i2c.h" > > Hi Eduardo, > > > @@ -2062,6 +2063,7 @@ PXA2xxState *pxa270_init(MemoryRegion *address_space, > > int i; > > DriveInfo *dinfo; > > s = g_new0(PXA2xxState, 1); > > + MachineState *machine = MACHINE(qdev_get_machine()); > > > > All the callers of pxa270_init have a reference to the machine, > you can pass it as parameter IMO.
Another possibility is to pass a "bool usb_enabled" argument. Paolo