* Re: [Qemu-devel] [PATCH v2 1/5] sysbus: make SysBusDeviceClass::init optional
[not found] ` <1361812142-26640-2-git-send-email-peter.maydell@linaro.org>
@ 2013-03-04 2:23 ` Peter Crosthwaite
0 siblings, 0 replies; 4+ messages in thread
From: Peter Crosthwaite @ 2013-03-04 2:23 UTC (permalink / raw)
To: Peter Maydell
Cc: patches, qemu-devel, Michael Walle, Jan Kiszka, Paolo Bonzini,
Andreas Färber
On Tue, Feb 26, 2013 at 3:08 AM, Peter Maydell <peter.maydell@linaro.org> wrote:
> Make the SysBusDeviceClass::init optional, for devices which
> genuinely don't need to do anything here. In particular, simple
> devices which can do all their initialization in their
> instance_init method don't need either a DeviceClass::realize
> or SysBusDeviceClass::init method.
>
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> Acked-by: Andreas Färber <afaerber@suse.de>
Reviewed-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
> ---
> hw/sysbus.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/hw/sysbus.c b/hw/sysbus.c
> index 6d9d1df..e9a16ac 100644
> --- a/hw/sysbus.c
> +++ b/hw/sysbus.c
> @@ -118,6 +118,9 @@ static int sysbus_device_init(DeviceState *dev)
> SysBusDevice *sd = SYS_BUS_DEVICE(dev);
> SysBusDeviceClass *sbc = SYS_BUS_DEVICE_GET_CLASS(sd);
>
> + if (!sbc->init) {
> + return 0;
> + }
> return sbc->init(sd);
> }
>
> --
> 1.7.9.5
>
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PATCH v2 2/5] musicpal: qdevify musicpal-misc
[not found] ` <1361812142-26640-3-git-send-email-peter.maydell@linaro.org>
@ 2013-03-04 3:22 ` Peter Crosthwaite
2013-03-04 11:22 ` Andreas Färber
1 sibling, 0 replies; 4+ messages in thread
From: Peter Crosthwaite @ 2013-03-04 3:22 UTC (permalink / raw)
To: Peter Maydell
Cc: patches, qemu-devel, Michael Walle, Jan Kiszka, Paolo Bonzini,
Andreas Färber
On Tue, Feb 26, 2013 at 3:08 AM, Peter Maydell <peter.maydell@linaro.org> wrote:
> Make musicpal-misc into its own (trivial) qdev device, so we
> can get rid of the abuse of sysbus_add_memory().
>
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
> ---
> hw/musicpal.c | 28 +++++++++++++++++++++++-----
> 1 file changed, 23 insertions(+), 5 deletions(-)
>
> diff --git a/hw/musicpal.c b/hw/musicpal.c
> index 272cb80..042b7f1 100644
> --- a/hw/musicpal.c
> +++ b/hw/musicpal.c
> @@ -1031,6 +1031,15 @@ static const TypeInfo mv88w8618_flashcfg_info = {
>
> #define MP_BOARD_REVISION 0x31
>
> +typedef struct {
> + SysBusDevice busdev;
> + MemoryRegion iomem;
> +} MusicPalMiscState;
> +
> +#define TYPE_MUSICPAL_MISC "musicpal-misc"
> +#define MUSICPAL_MISC(obj) \
> + OBJECT_CHECK(MusicPalMiscState, (obj), TYPE_MUSICPAL_MISC)
> +
> static uint64_t musicpal_misc_read(void *opaque, hwaddr offset,
> unsigned size)
> {
> @@ -1054,15 +1063,23 @@ static const MemoryRegionOps musicpal_misc_ops = {
> .endianness = DEVICE_NATIVE_ENDIAN,
> };
>
> -static void musicpal_misc_init(SysBusDevice *dev)
> +static void musicpal_misc_init(Object *obj)
> {
> - MemoryRegion *iomem = g_new(MemoryRegion, 1);
> + SysBusDevice *sd = SYS_BUS_DEVICE(obj);
> + MusicPalMiscState *s = MUSICPAL_MISC(obj);
>
> - memory_region_init_io(iomem, &musicpal_misc_ops, NULL,
> + memory_region_init_io(&s->iomem, &musicpal_misc_ops, NULL,
> "musicpal-misc", MP_MISC_SIZE);
> - sysbus_add_memory(dev, MP_MISC_BASE, iomem);
> + sysbus_init_mmio(sd, &s->iomem);
> }
>
> +static const TypeInfo musicpal_misc_info = {
> + .name = TYPE_MUSICPAL_MISC,
> + .parent = TYPE_SYS_BUS_DEVICE,
> + .instance_init = musicpal_misc_init,
> + .instance_size = sizeof(MusicPalMiscState),
> +};
> +
> /* WLAN register offsets */
> #define MP_WLAN_MAGIC1 0x11c
> #define MP_WLAN_MAGIC2 0x124
> @@ -1612,7 +1629,7 @@ static void musicpal_init(QEMUMachineInitArgs *args)
>
> sysbus_create_simple("mv88w8618_wlan", MP_WLAN_BASE, NULL);
>
> - musicpal_misc_init(SYS_BUS_DEVICE(dev));
> + sysbus_create_simple(TYPE_MUSICPAL_MISC, MP_MISC_BASE, NULL);
>
> dev = sysbus_create_simple("musicpal_gpio", MP_GPIO_BASE, pic[MP_GPIO_IRQ]);
> i2c_dev = sysbus_create_simple("gpio_i2c", -1, NULL);
> @@ -1692,6 +1709,7 @@ static void musicpal_register_types(void)
> type_register_static(&musicpal_lcd_info);
> type_register_static(&musicpal_gpio_info);
> type_register_static(&musicpal_key_info);
> + type_register_static(&musicpal_misc_info);
> }
>
> type_init(musicpal_register_types)
> --
> 1.7.9.5
>
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PATCH v2 2/5] musicpal: qdevify musicpal-misc
[not found] ` <1361812142-26640-3-git-send-email-peter.maydell@linaro.org>
2013-03-04 3:22 ` [Qemu-devel] [PATCH v2 2/5] musicpal: qdevify musicpal-misc Peter Crosthwaite
@ 2013-03-04 11:22 ` Andreas Färber
2013-03-04 11:53 ` Peter Maydell
1 sibling, 1 reply; 4+ messages in thread
From: Andreas Färber @ 2013-03-04 11:22 UTC (permalink / raw)
To: Peter Maydell
Cc: Paolo Bonzini, Michael Walle, Jan Kiszka, qemu-devel, patches
Am 25.02.2013 18:08, schrieb Peter Maydell:
> Make musicpal-misc into its own (trivial) qdev device, so we
> can get rid of the abuse of sysbus_add_memory().
>
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> ---
> hw/musicpal.c | 28 +++++++++++++++++++++++-----
> 1 file changed, 23 insertions(+), 5 deletions(-)
>
> diff --git a/hw/musicpal.c b/hw/musicpal.c
> index 272cb80..042b7f1 100644
> --- a/hw/musicpal.c
> +++ b/hw/musicpal.c
> @@ -1031,6 +1031,15 @@ static const TypeInfo mv88w8618_flashcfg_info = {
>
> #define MP_BOARD_REVISION 0x31
>
> +typedef struct {
> + SysBusDevice busdev;
I believe I asked for this field to be named parent_obj, is there a
compatibility reason (macro?) to keep the old-style naming?
Otherwise looks good.
Andreas
> + MemoryRegion iomem;
> +} MusicPalMiscState;
> +
> +#define TYPE_MUSICPAL_MISC "musicpal-misc"
> +#define MUSICPAL_MISC(obj) \
> + OBJECT_CHECK(MusicPalMiscState, (obj), TYPE_MUSICPAL_MISC)
> +
> static uint64_t musicpal_misc_read(void *opaque, hwaddr offset,
> unsigned size)
> {
> @@ -1054,15 +1063,23 @@ static const MemoryRegionOps musicpal_misc_ops = {
> .endianness = DEVICE_NATIVE_ENDIAN,
> };
>
> -static void musicpal_misc_init(SysBusDevice *dev)
> +static void musicpal_misc_init(Object *obj)
> {
> - MemoryRegion *iomem = g_new(MemoryRegion, 1);
> + SysBusDevice *sd = SYS_BUS_DEVICE(obj);
> + MusicPalMiscState *s = MUSICPAL_MISC(obj);
>
> - memory_region_init_io(iomem, &musicpal_misc_ops, NULL,
> + memory_region_init_io(&s->iomem, &musicpal_misc_ops, NULL,
> "musicpal-misc", MP_MISC_SIZE);
> - sysbus_add_memory(dev, MP_MISC_BASE, iomem);
> + sysbus_init_mmio(sd, &s->iomem);
> }
>
> +static const TypeInfo musicpal_misc_info = {
> + .name = TYPE_MUSICPAL_MISC,
> + .parent = TYPE_SYS_BUS_DEVICE,
> + .instance_init = musicpal_misc_init,
> + .instance_size = sizeof(MusicPalMiscState),
> +};
> +
> /* WLAN register offsets */
> #define MP_WLAN_MAGIC1 0x11c
> #define MP_WLAN_MAGIC2 0x124
> @@ -1612,7 +1629,7 @@ static void musicpal_init(QEMUMachineInitArgs *args)
>
> sysbus_create_simple("mv88w8618_wlan", MP_WLAN_BASE, NULL);
>
> - musicpal_misc_init(SYS_BUS_DEVICE(dev));
> + sysbus_create_simple(TYPE_MUSICPAL_MISC, MP_MISC_BASE, NULL);
>
> dev = sysbus_create_simple("musicpal_gpio", MP_GPIO_BASE, pic[MP_GPIO_IRQ]);
> i2c_dev = sysbus_create_simple("gpio_i2c", -1, NULL);
> @@ -1692,6 +1709,7 @@ static void musicpal_register_types(void)
> type_register_static(&musicpal_lcd_info);
> type_register_static(&musicpal_gpio_info);
> type_register_static(&musicpal_key_info);
> + type_register_static(&musicpal_misc_info);
> }
>
> type_init(musicpal_register_types)
>
--
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PATCH v2 2/5] musicpal: qdevify musicpal-misc
2013-03-04 11:22 ` Andreas Färber
@ 2013-03-04 11:53 ` Peter Maydell
0 siblings, 0 replies; 4+ messages in thread
From: Peter Maydell @ 2013-03-04 11:53 UTC (permalink / raw)
To: Andreas Färber
Cc: Paolo Bonzini, Michael Walle, Jan Kiszka, qemu-devel, patches
On 4 March 2013 19:22, Andreas Färber <afaerber@suse.de> wrote:
> Am 25.02.2013 18:08, schrieb Peter Maydell:
>> --- a/hw/musicpal.c
>> +++ b/hw/musicpal.c
>> @@ -1031,6 +1031,15 @@ static const TypeInfo mv88w8618_flashcfg_info = {
>>
>> #define MP_BOARD_REVISION 0x31
>>
>> +typedef struct {
>> + SysBusDevice busdev;
>
> I believe I asked for this field to be named parent_obj, is there a
> compatibility reason (macro?) to keep the old-style naming?
Apologies, you did but I missed the request when I was going back
through the mail thread for review comments on this patch. Will fix.
-- PMM
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2013-03-04 11:53 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <1361812142-26640-1-git-send-email-peter.maydell@linaro.org>
[not found] ` <1361812142-26640-2-git-send-email-peter.maydell@linaro.org>
2013-03-04 2:23 ` [Qemu-devel] [PATCH v2 1/5] sysbus: make SysBusDeviceClass::init optional Peter Crosthwaite
[not found] ` <1361812142-26640-3-git-send-email-peter.maydell@linaro.org>
2013-03-04 3:22 ` [Qemu-devel] [PATCH v2 2/5] musicpal: qdevify musicpal-misc Peter Crosthwaite
2013-03-04 11:22 ` Andreas Färber
2013-03-04 11:53 ` Peter Maydell
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).