From patchwork Wed Oct 21 13:25:37 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gerd Hoffmann X-Patchwork-Id: 36587 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id B409BB7B93 for ; Thu, 22 Oct 2009 01:32:16 +1100 (EST) Received: from localhost ([127.0.0.1]:58232 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1N0cEX-00027h-IQ for incoming@patchwork.ozlabs.org; Wed, 21 Oct 2009 10:32:13 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1N0bCe-000877-EG for qemu-devel@nongnu.org; Wed, 21 Oct 2009 09:26:12 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1N0bCY-0007zu-PZ for qemu-devel@nongnu.org; Wed, 21 Oct 2009 09:26:11 -0400 Received: from [199.232.76.173] (port=55736 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1N0bCY-0007zW-0W for qemu-devel@nongnu.org; Wed, 21 Oct 2009 09:26:06 -0400 Received: from mx1.redhat.com ([209.132.183.28]:14961) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1N0bCX-0007Se-IC for qemu-devel@nongnu.org; Wed, 21 Oct 2009 09:26:05 -0400 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id n9LDQ5cZ006084 for ; Wed, 21 Oct 2009 09:26:05 -0400 Received: from zweiblum.home.kraxel.org (vpn2-9-113.ams2.redhat.com [10.36.9.113]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with SMTP id n9LDPxqg027263; Wed, 21 Oct 2009 09:26:01 -0400 Received: by zweiblum.home.kraxel.org (Postfix, from userid 500) id 1386F70116; Wed, 21 Oct 2009 15:25:44 +0200 (CEST) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Wed, 21 Oct 2009 15:25:37 +0200 Message-Id: <1256131543-28416-17-git-send-email-kraxel@redhat.com> In-Reply-To: <1256131543-28416-1-git-send-email-kraxel@redhat.com> References: <1256131543-28416-1-git-send-email-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.12 X-detected-operating-system: by monty-python.gnu.org: Genre and OS details not recognized. Cc: Gerd Hoffmann Subject: [Qemu-devel] [PATCH 16/22] smc91c111: use qdev properties for configuration. X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Signed-off-by: Gerd Hoffmann --- hw/smc91c111.c | 28 +++++++++++++++++++--------- 1 files changed, 19 insertions(+), 9 deletions(-) diff --git a/hw/smc91c111.c b/hw/smc91c111.c index d58821a..4006035 100644 --- a/hw/smc91c111.c +++ b/hw/smc91c111.c @@ -19,6 +19,7 @@ typedef struct { SysBusDevice busdev; VLANClientState *vc; + NICConf conf; uint16_t tcr; uint16_t rcr; uint16_t cr; @@ -42,7 +43,6 @@ typedef struct { uint8_t data[NUM_PACKETS][2048]; uint8_t int_level; uint8_t int_mask; - uint8_t macaddr[6]; int mmio_index; } smc91c111_state; @@ -474,7 +474,7 @@ static uint32_t smc91c111_readb(void *opaque, target_phys_addr_t offset) /* Not implemented. */ return 0; case 4: case 5: case 6: case 7: case 8: case 9: /* IA */ - return s->macaddr[offset - 4]; + return s->conf.macaddr.a[offset - 4]; case 10: /* General Purpose */ return s->gpr & 0xff; case 11: @@ -696,8 +696,7 @@ static void smc91c111_cleanup(VLANClientState *vc) { smc91c111_state *s = vc->opaque; - cpu_unregister_io_memory(s->mmio_index); - qemu_free(s); + s->vc = NULL; } static int smc91c111_init1(SysBusDevice *dev) @@ -708,21 +707,32 @@ static int smc91c111_init1(SysBusDevice *dev) smc91c111_writefn, s); sysbus_init_mmio(dev, 16, s->mmio_index); sysbus_init_irq(dev, &s->irq); - qdev_get_macaddr(&dev->qdev, s->macaddr); + qemu_macaddr_default_if_unset(&s->conf.macaddr); smc91c111_reset(s); - s->vc = qdev_get_vlan_client(&dev->qdev, + s->vc = qemu_new_vlan_client(s->conf.vlan, s->conf.peer, + dev->qdev.info->name, dev->qdev.id, smc91c111_can_receive, smc91c111_receive, NULL, smc91c111_cleanup, s); - qemu_format_nic_info_str(s->vc, s->macaddr); + qemu_format_nic_info_str(s->vc, s->conf.macaddr.a); /* ??? Save/restore. */ return 0; } +static SysBusDeviceInfo smc91c111_info = { + .init = smc91c111_init1, + .qdev.name = "smc91c111", + .qdev.size = sizeof(smc91c111_state), + .qdev.props = (Property[]) { + DEFINE_NIC_PROPERTIES(smc91c111_state, conf), + DEFINE_PROP_END_OF_LIST(), + } +}; + static void smc91c111_register_devices(void) { - sysbus_register_dev("smc91c111", sizeof(smc91c111_state), smc91c111_init1); + sysbus_register_withprop(&smc91c111_info); } /* Legacy helper function. Should go away when machine config files are @@ -734,7 +744,7 @@ void smc91c111_init(NICInfo *nd, uint32_t base, qemu_irq irq) qemu_check_nic_model(nd, "smc91c111"); dev = qdev_create(NULL, "smc91c111"); - dev->nd = nd; + qdev_set_nic_properties(dev, nd); qdev_init_nofail(dev); s = sysbus_from_qdev(dev); sysbus_mmio_map(s, 0, base);