From patchwork Fri Feb 15 11:45:03 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 14841 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 3780F23EAD for ; Fri, 15 Feb 2013 11:45:11 +0000 (UTC) Received: from mail-vb0-f43.google.com (mail-vb0-f43.google.com [209.85.212.43]) by fiordland.canonical.com (Postfix) with ESMTP id C722FA18892 for ; Fri, 15 Feb 2013 11:45:10 +0000 (UTC) Received: by mail-vb0-f43.google.com with SMTP id fs19so2108123vbb.30 for ; Fri, 15 Feb 2013 03:45:10 -0800 (PST) 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=+YqtYjY3C7brLDjFW55YPMWeHlAEb9Dis5fpJT2oe9s=; b=UIH7dJRkdqYQ+085yH0dS5nE1IKx1DR+NlzOCTqU3yz1pzHeQi+yq6l2+HK8pnUQ76 Pq+T6Z6pPWHxLWalgOsI5mrdB2rwif/UfmZCBIK/raOEEp3Wtsb8tyC4d3Ip7WBCmw43 ZkgWV7o+2XM+Wrrw/kzVc0esZOV0bIWf7w6SF6tg9GzuH574X6GhZvQtVOSAL/u4jJcM LtkmhqE7ebpEu+oD4QKgNv8yiI2S1ZjkK3nOknsNfnyNQqlUkGsOX2uvhsFOMmTf1IU/ O8tsjHCeaepQ5lC/9om6jZBmfxNzz0wCPKovgclVXbOBNR4LTNMQ0rvLeJkCsfOw/xar 70Yg== X-Received: by 10.58.85.134 with SMTP id h6mr2793035vez.18.1360928710081; Fri, 15 Feb 2013 03:45:10 -0800 (PST) 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.221.4.5 with SMTP id oa5csp8006vcb; Fri, 15 Feb 2013 03:45:09 -0800 (PST) X-Received: by 10.180.7.232 with SMTP id m8mr3541448wia.8.1360928708744; Fri, 15 Feb 2013 03:45:08 -0800 (PST) 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 a6si991134wie.36.2013.02.15.03.45.07 (version=TLSv1 cipher=RC4-SHA bits=128/128); Fri, 15 Feb 2013 03:45:08 -0800 (PST) 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 1U6Jj0-0003Oq-DF; Fri, 15 Feb 2013 11:45:06 +0000 From: Peter Maydell To: qemu-devel@nongnu.org Cc: patches@linaro.org, Michael Walle , Jan Kiszka Subject: [PATCH 2/5] musicpal: qdevify musicpal-misc Date: Fri, 15 Feb 2013 11:45:03 +0000 Message-Id: <1360928706-13041-3-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 1.7.2.5 In-Reply-To: <1360928706-13041-1-git-send-email-peter.maydell@linaro.org> References: <1360928706-13041-1-git-send-email-peter.maydell@linaro.org> X-Gm-Message-State: ALoCoQk9Ns1MqOmsJNIpORRpljzYrD0zpjRE5+xRmxkd67LdgVvKZ/KT+VlrMrLRtgyFGatnoZVk 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 --- hw/musicpal.c | 34 +++++++++++++++++++++++++++++----- 1 file changed, 29 insertions(+), 5 deletions(-) diff --git a/hw/musicpal.c b/hw/musicpal.c index 272cb80..819e420 100644 --- a/hw/musicpal.c +++ b/hw/musicpal.c @@ -1031,6 +1031,21 @@ static const TypeInfo mv88w8618_flashcfg_info = { #define MP_BOARD_REVISION 0x31 +typedef struct { + SysBusDevice busdev; + MemoryRegion iomem; +} MusicPalMiscState; + +typedef SysBusDeviceClass MusicPalMiscClass; + +#define TYPE_MUSICPAL_MISC "musicpal-misc" +#define MUSICPAL_MISC(obj) \ + OBJECT_CHECK(MusicPalMiscState, (obj), TYPE_MUSICPAL_MISC) +#define MUSICPAL_MISC_CLASS(klass) \ + OBJECT_CLASS_CHECK(MusicPalMiscClass, (klass), TYPE_MUSICPAL_MISC) +#define MUSICPAL_MISC_GET_CLASS(obj) \ + OBJECT_GET_CLASS(MusicPalMiscClass, (obj), TYPE_MUSICPAL_MISC) + static uint64_t musicpal_misc_read(void *opaque, hwaddr offset, unsigned size) { @@ -1054,15 +1069,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 +1635,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 +1715,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)