From patchwork Fri Mar 15 14:34:20 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 15380 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id EA24923E14 for ; Fri, 15 Mar 2013 14:34:31 +0000 (UTC) Received: from mail-vb0-f47.google.com (mail-vb0-f47.google.com [209.85.212.47]) by fiordland.canonical.com (Postfix) with ESMTP id A612FA1901E for ; Fri, 15 Mar 2013 14:34:31 +0000 (UTC) Received: by mail-vb0-f47.google.com with SMTP id e21so1907673vbm.20 for ; Fri, 15 Mar 2013 07:34:31 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:x-forwarded-to:x-forwarded-for:delivered-to:x-received :received-spf:from:to:cc:subject:date:message-id:x-mailer :in-reply-to:references:x-gm-message-state; bh=bHA51MMS46ip+OTqxZe6IjrrHJuDXcL65dJaOXgNMtY=; b=VnU0v1sroMOFyPMmRdQFCAyfdVIfLPPoX3E8V7CnrD5zosy7P1Za56jZwIF1puWjSA 1TgmXlFaNURMq7inGuNtIh6OXHLoHm5tJAZP9/ScnDSpeg35ajRbR8zgPMZ3gjDJs+M8 ATmWxyFsI7u7jZBviHfYAq/aCrc70sEQ1/xHh6Dtn2+IoAcBMNaQswuQBvgM10FnrRoD lY1mJqjPPOD+xXXJCGTUfgGym0rESmjyRHhBiZiWDf6YMOlLgZq9GExMX9IoDZHshvY8 NyStpHGUcYV0kSJkM5VYuSZJUKmVgrcfuy3YSlrREc3yYWTu2TZ3P7q6zMHlnTgDKgAk OfNg== X-Received: by 10.52.88.237 with SMTP id bj13mr6261451vdb.75.1363358071139; Fri, 15 Mar 2013 07:34:31 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.58.127.98 with SMTP id nf2csp123172veb; Fri, 15 Mar 2013 07:34:30 -0700 (PDT) X-Received: by 10.205.26.67 with SMTP id rl3mr3193725bkb.62.1363358067834; Fri, 15 Mar 2013 07:34:27 -0700 (PDT) Received: from mnementh.archaic.org.uk (1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.d.1.0.0.b.8.0.1.0.0.2.ip6.arpa. [2001:8b0:1d0::1]) by mx.google.com with ESMTPS id gm9si2277948bkc.79.2013.03.15.07.34.27 (version=TLSv1 cipher=RC4-SHA bits=128/128); Fri, 15 Mar 2013 07:34:27 -0700 (PDT) Received-SPF: neutral (google.com: 2001:8b0:1d0::1 is neither permitted nor denied by best guess record for domain of pm215@archaic.org.uk) client-ip=2001:8b0:1d0::1; Authentication-Results: mx.google.com; spf=neutral (google.com: 2001:8b0:1d0::1 is neither permitted nor denied by best guess record for domain of pm215@archaic.org.uk) smtp.mail=pm215@archaic.org.uk Received: from pm215 by mnementh.archaic.org.uk with local (Exim 4.72) (envelope-from ) id 1UGViB-0006FA-IO; Fri, 15 Mar 2013 14:34:23 +0000 From: Peter Maydell To: qemu-devel@nongnu.org Cc: patches@linaro.org, Michael Walle , Jan Kiszka , =?UTF-8?q?Andreas=20F=C3=A4rber?= , Paolo Bonzini Subject: [PATCH v3 2/5] musicpal: qdevify musicpal-misc Date: Fri, 15 Mar 2013 14:34:20 +0000 Message-Id: <1363358063-23973-3-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 1.7.2.5 In-Reply-To: <1363358063-23973-1-git-send-email-peter.maydell@linaro.org> References: <1363358063-23973-1-git-send-email-peter.maydell@linaro.org> X-Gm-Message-State: ALoCoQlyMtXW3i76EI8WNSAO5yt62m0QkGVXnBtNz446YTbPgRAkPcZF3oy9ehMdLfYmCQ/KJiIK 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 Reviewed-by: Peter Crosthwaite Reviewed-by: Andreas Färber --- hw/arm/musicpal.c | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/hw/arm/musicpal.c b/hw/arm/musicpal.c index a37dbd7..63d8e13 100644 --- a/hw/arm/musicpal.c +++ b/hw/arm/musicpal.c @@ -1031,6 +1031,15 @@ static const TypeInfo mv88w8618_flashcfg_info = { #define MP_BOARD_REVISION 0x31 +typedef struct { + SysBusDevice parent_obj; + 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)