From patchwork Mon Feb 25 17:08:59 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 15076 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 3EFC223E24 for ; Mon, 25 Feb 2013 17:09:13 +0000 (UTC) Received: from mail-vc0-f178.google.com (mail-vc0-f178.google.com [209.85.220.178]) by fiordland.canonical.com (Postfix) with ESMTP id F07B0A18AB8 for ; Mon, 25 Feb 2013 17:09:12 +0000 (UTC) Received: by mail-vc0-f178.google.com with SMTP id m8so1826979vcd.37 for ; Mon, 25 Feb 2013 09:09:12 -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=BM2kg8bqyjRKE72WtNcEYTaxCmuiteQGyCT9scjapBI=; b=Cn0prV51pwOLoEqW4VoToO6Jrtl7qVMSpKjr6sQgyTDkPdfjP0/ci7KyIrZPvDe/EO C7ECe8/ZAn5WCPhvyqE4P+8gCD/gwzFDhjp3xsiD+niZBs8nnbnbKZh9dgi3VZntlkl2 7IfQg2+SfQrL2QKR9Px8dH2XEUg9Sr1KUFqLcEmCCxUT6Z+AXIRWsFtJA6EtFrJBT5hh pRTOhiLyneg/7nwnVRb5FD/C+Fb1dMS7u6s5+MruqrCN7dk6NK+e8YfVhFznqEz8iFu+ wKxbNi2uwhIwU2hRpoaoVItHln5dmAZWSHXxIRVQ55OiF2lrq8zsBWHyYCzduYBSTsMd G5jw== X-Received: by 10.52.177.163 with SMTP id cr3mr8867871vdc.94.1361812152466; Mon, 25 Feb 2013 09:09:12 -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.58.145.101 with SMTP id st5csp68605veb; Mon, 25 Feb 2013 09:09:11 -0800 (PST) X-Received: by 10.204.143.141 with SMTP id v13mr5260153bku.135.1361812145915; Mon, 25 Feb 2013 09:09:05 -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 fk13si3802359bkc.147.2013.02.25.09.09.04 (version=TLSv1 cipher=RC4-SHA bits=128/128); Mon, 25 Feb 2013 09:09:05 -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 1UA1Xy-0006wB-Ei; Mon, 25 Feb 2013 17:09:02 +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 v2 2/5] musicpal: qdevify musicpal-misc Date: Mon, 25 Feb 2013 17:08:59 +0000 Message-Id: <1361812142-26640-3-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 1.7.2.5 In-Reply-To: <1361812142-26640-1-git-send-email-peter.maydell@linaro.org> References: <1361812142-26640-1-git-send-email-peter.maydell@linaro.org> X-Gm-Message-State: ALoCoQmZlPht8VIqV6bDuYAYzo+6acoajsLy8eVNrmmKUfoS9Po2o4WPXPF9wlLAPcUX2B6sW4pb 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 --- 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)