From patchwork Sun Oct 22 15:51:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Woodhouse X-Patchwork-Id: 1853229 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=infradead.org header.i=@infradead.org header.a=rsa-sha256 header.s=casper.20170209 header.b=vp/q7TUe; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-ppc-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4SD2vQ1lHJz1ygT for ; Mon, 23 Oct 2023 02:54:42 +1100 (AEDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qualz-0006W9-RZ; Sun, 22 Oct 2023 11:53:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qualb-0005UA-W8; Sun, 22 Oct 2023 11:53:28 -0400 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qualT-00004v-Kr; Sun, 22 Oct 2023 11:53:27 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Sender:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description; bh=rUpd9lT/62EWfZvMuWHRTq23AphmaFPcKQZSk/5bZnU=; b=vp/q7TUe6Zc6kDLwHXFkmkm/lQ 7O62P5nNr0Z2egFDK/w3Rogh2x2lxfFIW54BCtvZGWnbDBqfc/g2VCUPW4sThB/iCMZc5d1FRgs91 xYLmMAAxavSq96ILSh2FHPG2TwZ77iGYyo7CeCsRceNh2S3OMTM8ebRxuN38D0U4eLEgO2GYDlou2 v9Hosc4I6XuumUkQTfDcsd3kxT5gZhI1ND/3STQUru/c36GVMaARdhyHvPtgVIsY6MIY6fndoc79v uyPQQVdQOQlPbikqi4UZWcqfYKrJ5qiTLAX/rtreT3DtJKxsvRNVdEUB9G3NGZ2I2DAgj8PNV2PWI QHDMz5Fw==; Received: from [2001:8b0:10b:1::ebe] (helo=i7.infradead.org) by casper.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1quakJ-008TGZ-OI; Sun, 22 Oct 2023 15:52:07 +0000 Received: from dwoodhou by i7.infradead.org with local (Exim 4.96 #2 (Red Hat Linux)) id 1quakJ-001qa0-16; Sun, 22 Oct 2023 16:52:07 +0100 From: David Woodhouse To: qemu-devel@nongnu.org Cc: Richard Henderson , Beniamino Galvani , Peter Maydell , Strahinja Jankovic , Niek Linnenbank , =?utf-8?q?C=C3=A9dric_Le_Goater?= , Andrew Jeffery , Joel Stanley , Igor Mitsyanko , Jean-Christophe Dubois , Andrey Smirnov , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= , Rob Herring , Subbaraya Sundeep , Jan Kiszka , Tyrone Ting , Hao Wu , Radoslaw Biernacki , Leif Lindholm , Marcin Juszkiewicz , "Edgar E. Iglesias" , Alistair Francis , Helge Deller , Paolo Bonzini , Eduardo Habkost , "Michael S. Tsirkin" , Marcel Apfelbaum , Song Gao , Thomas Huth , Laurent Vivier , Huacai Chen , Jiaxun Yang , =?utf-8?q?Herv=C3=A9_Poussineau?= , Aleksandar Rikalo , Aurelien Jarno , Jason Wang , Jia Liu , Stafford Horne , Mark Cave-Ayland , Nicholas Piggin , Daniel Henrique Barboza , David Gibson , Harsh Prateek Bora , Bin Meng , Palmer Dabbelt , Weiwei Li , Liu Zhiwei , David Hildenbrand , Ilya Leoshkevich , Halil Pasic , Christian Borntraeger , Eric Farman , Yoshinori Sato , Magnus Damm , Artyom Tarasenko , Stefano Stabellini , Anthony Perard , Paul Durrant , Max Filippov , qemu-arm@nongnu.org, qemu-ppc@nongnu.org, qemu-riscv@nongnu.org, qemu-s390x@nongnu.org, xen-devel@lists.xenproject.org Subject: [PATCH 26/45] hw/net/lan9118: use qemu_configure_nic_device() Date: Sun, 22 Oct 2023 16:51:41 +0100 Message-Id: <20231022155200.436340-27-dwmw2@infradead.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231022155200.436340-1-dwmw2@infradead.org> References: <20231022155200.436340-1-dwmw2@infradead.org> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html Received-SPF: none client-ip=2001:8b0:10b:1236::1; envelope-from=BATV+88d8721f4af1339c2fab+7364+infradead.org+dwmw2@casper.srs.infradead.org; helo=casper.infradead.org X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-ppc@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-ppc-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-ppc-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: David Woodhouse Some callers instantiate the device unconditionally, others will do so only if there is a NICInfo to go with it. This appears to be fairly random, but preseve the existing behaviour for now. Signed-off-by: David Woodhouse --- hw/arm/kzm.c | 4 ++-- hw/arm/mps2.c | 2 +- hw/arm/realview.c | 6 ++---- hw/arm/vexpress.c | 4 ++-- hw/net/lan9118.c | 5 ++--- include/hw/net/lan9118.h | 2 +- 6 files changed, 10 insertions(+), 13 deletions(-) diff --git a/hw/arm/kzm.c b/hw/arm/kzm.c index b1b281c9ac..9f2d120f57 100644 --- a/hw/arm/kzm.c +++ b/hw/arm/kzm.c @@ -112,8 +112,8 @@ static void kzm_init(MachineState *machine) alias_offset += ram[i].size; } - if (nd_table[0].used) { - lan9118_init(&nd_table[0], KZM_LAN9118_ADDR, + if (qemu_find_nic_info("lan9118", true, NULL)) { + lan9118_init(KZM_LAN9118_ADDR, qdev_get_gpio_in(DEVICE(&s->soc.avic), 52)); } diff --git a/hw/arm/mps2.c b/hw/arm/mps2.c index d92fd60684..cb3da1ef5c 100644 --- a/hw/arm/mps2.c +++ b/hw/arm/mps2.c @@ -458,7 +458,7 @@ static void mps2_common_init(MachineState *machine) /* In hardware this is a LAN9220; the LAN9118 is software compatible * except that it doesn't support the checksum-offload feature. */ - lan9118_init(&nd_table[0], mmc->ethernet_base, + lan9118_init(mmc->ethernet_base, qdev_get_gpio_in(armv7m, mmc->fpga_type == FPGA_AN511 ? 47 : 13)); diff --git a/hw/arm/realview.c b/hw/arm/realview.c index 591f50581e..68f8aefac3 100644 --- a/hw/arm/realview.c +++ b/hw/arm/realview.c @@ -84,7 +84,6 @@ static void realview_init(MachineState *machine, SysBusDevice *busdev; qemu_irq pic[64]; PCIBus *pci_bus = NULL; - NICInfo *nd; DriveInfo *dinfo; I2CBus *i2c; int n; @@ -295,10 +294,9 @@ static void realview_init(MachineState *machine, } } - nd = qemu_find_nic_info(is_pb ? "lan9118" : "smc91c111", true, NULL); - if (nd) { + if (qemu_find_nic_info(is_pb ? "lan9118" : "smc91c111", true, NULL)) { if (is_pb) { - lan9118_init(nd, 0x4e000000, pic[28]); + lan9118_init(0x4e000000, pic[28]); } else { smc91c111_init(0x4e000000, pic[28]); } diff --git a/hw/arm/vexpress.c b/hw/arm/vexpress.c index 8ff37f52ca..4a6cb3bdf5 100644 --- a/hw/arm/vexpress.c +++ b/hw/arm/vexpress.c @@ -686,8 +686,8 @@ static void vexpress_common_init(MachineState *machine) memory_region_add_subregion(sysmem, map[VE_VIDEORAM], &vms->vram); /* 0x4e000000 LAN9118 Ethernet */ - if (nd_table[0].used) { - lan9118_init(&nd_table[0], map[VE_ETHERNET], pic[15]); + if (qemu_find_nic_info("lan9118", true, NULL)) { + lan9118_init(map[VE_ETHERNET], pic[15]); } /* VE_USB: not modelled */ diff --git a/hw/net/lan9118.c b/hw/net/lan9118.c index e5c4af182d..42fe5efd8c 100644 --- a/hw/net/lan9118.c +++ b/hw/net/lan9118.c @@ -1407,14 +1407,13 @@ static void lan9118_register_types(void) /* Legacy helper function. Should go away when machine config files are implemented. */ -void lan9118_init(NICInfo *nd, uint32_t base, qemu_irq irq) +void lan9118_init(uint32_t base, qemu_irq irq) { DeviceState *dev; SysBusDevice *s; - qemu_check_nic_model(nd, "lan9118"); dev = qdev_new(TYPE_LAN9118); - qdev_set_nic_properties(dev, nd); + qemu_configure_nic_device(dev, true, NULL); s = SYS_BUS_DEVICE(dev); sysbus_realize_and_unref(s, &error_fatal); sysbus_mmio_map(s, 0, base); diff --git a/include/hw/net/lan9118.h b/include/hw/net/lan9118.h index 3d0c67f339..4bf9da7a63 100644 --- a/include/hw/net/lan9118.h +++ b/include/hw/net/lan9118.h @@ -15,6 +15,6 @@ #define TYPE_LAN9118 "lan9118" -void lan9118_init(NICInfo *, uint32_t, qemu_irq); +void lan9118_init(uint32_t, qemu_irq); #endif