From nobody Fri May 3 23:26:57 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1532006932199317.61363586657455; Thu, 19 Jul 2018 06:28:52 -0700 (PDT) Received: from localhost ([::1]:42779 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fg8no-0002Qs-HE for importer@patchew.org; Thu, 19 Jul 2018 09:17:04 -0400 Received: from eggs.gnu.org ([208.118.235.92]:38282) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fg8mZ-0001uF-Jp for qemu-devel@nongnu.org; Thu, 19 Jul 2018 09:15:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fg8mU-0000Ki-Su for qemu-devel@nongnu.org; Thu, 19 Jul 2018 09:15:47 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:52972 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fg8mP-000077-4j; Thu, 19 Jul 2018 09:15:37 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 654BA400225D; Thu, 19 Jul 2018 13:15:36 +0000 (UTC) Received: from thh440s.str.redhat.com (dhcp-200-180.str.redhat.com [10.33.200.180]) by smtp.corp.redhat.com (Postfix) with ESMTP id A2F3C2026D6B; Thu, 19 Jul 2018 13:15:35 +0000 (UTC) From: Thomas Huth To: qemu-devel@nongnu.org, Peter Maydell , Andrzej Zaborowski Date: Thu, 19 Jul 2018 15:15:34 +0200 Message-Id: <1532006134-7701-1-git-send-email-thuth@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Thu, 19 Jul 2018 13:15:36 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Thu, 19 Jul 2018 13:15:36 +0000 (UTC) for IP:'10.11.54.4' DOMAIN:'int-mx04.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'thuth@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PATCH] hw/arm/spitz: Move problematic nand_init() code to realize function X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-arm@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" nand_init() does not only create the NAND device, it also realizes the device with qdev_init_nofail() already. So we must not call nand_init() from an instance_init function like sl_nand_init(), otherwise we get superfluous NAND devices in the QOM tree after introspecting the 'sl-nand' device. So move the nand_init() to the realize function of 'sl-nand' instead. Signed-off-by: Thomas Huth Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- hw/arm/spitz.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/hw/arm/spitz.c b/hw/arm/spitz.c index 3cc27a1..c4bc3de 100644 --- a/hw/arm/spitz.c +++ b/hw/arm/spitz.c @@ -169,16 +169,22 @@ static void sl_nand_init(Object *obj) { SLNANDState *s =3D SL_NAND(obj); SysBusDevice *dev =3D SYS_BUS_DEVICE(obj); - DriveInfo *nand; =20 s->ctl =3D 0; + + memory_region_init_io(&s->iomem, obj, &sl_ops, s, "sl", 0x40); + sysbus_init_mmio(dev, &s->iomem); +} + +static void sl_nand_realize(DeviceState *dev, Error **errp) +{ + SLNANDState *s =3D SL_NAND(dev); + DriveInfo *nand; + /* FIXME use a qdev drive property instead of drive_get() */ nand =3D drive_get(IF_MTD, 0, 0); s->nand =3D nand_init(nand ? blk_by_legacy_dinfo(nand) : NULL, s->manf_id, s->chip_id); - - memory_region_init_io(&s->iomem, obj, &sl_ops, s, "sl", 0x40); - sysbus_init_mmio(dev, &s->iomem); } =20 /* Spitz Keyboard */ @@ -1079,6 +1085,7 @@ static void sl_nand_class_init(ObjectClass *klass, vo= id *data) =20 dc->vmsd =3D &vmstate_sl_nand_info; dc->props =3D sl_nand_properties; + dc->realize =3D sl_nand_realize; /* Reason: init() method uses drive_get() */ dc->user_creatable =3D false; } --=20 1.8.3.1