From nobody Mon Feb 9 22:08:15 2026 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; dkim=fail; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1528786834354511.1488403466674; Tue, 12 Jun 2018 00:00:34 -0700 (PDT) Received: from localhost ([::1]:53287 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fSdI6-0006bj-92 for importer@patchew.org; Tue, 12 Jun 2018 03:00:30 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58917) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fSd3n-0002kT-Nb for qemu-devel@nongnu.org; Tue, 12 Jun 2018 02:45:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fSd3m-0001uY-ON for qemu-devel@nongnu.org; Tue, 12 Jun 2018 02:45:43 -0400 Received: from ozlabs.org ([2401:3900:2:1::2]:46009) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fSd3l-0001pf-W1; Tue, 12 Jun 2018 02:45:42 -0400 Received: by ozlabs.org (Postfix, from userid 1007) id 414gPV1ZjTzB3sg; Tue, 12 Jun 2018 16:45:34 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1528785934; bh=GrvWzIR6bhLHuUi20B2cMDZgFFwzB91K4qBbXoPlIvk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qCzPWeft54AjtjwzEH7keBD5ZNcWAualuijwluRuEyGXc/KBQEjItBjfLSptzTsEV PSLQP1sQOwenrZWUz5nt5BdbYLllwk/sNpkqkcxjHkb4xE/5Q4PJ6nNjUT8xGGi2EG AHLI6aFRplQ8IzH3xnSyZw+FJm5OmUOCCDgaBCXc= From: David Gibson To: peter.maydell@linaro.org Date: Tue, 12 Jun 2018 16:44:50 +1000 Message-Id: <20180612064503.14282-21-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180612064503.14282-1-david@gibson.dropbear.id.au> References: <20180612064503.14282-1-david@gibson.dropbear.id.au> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2401:3900:2:1::2 Subject: [Qemu-devel] [PULL 20/33] mos6522: move timer frequency initialisation to mos6522_reset 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: lvivier@redhat.com, Mark Cave-Ayland , qemu-devel@nongnu.org, groug@kaod.org, qemu-ppc@nongnu.org, clg@kaod.org, David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Mark Cave-Ayland The 6522 VIA timer frequency cannot be set by altering registers within the device itself and hence it is a fixed property of the machine. Move the initialisation of the timer frequency to the mos6522 reset function and ensure that any subclasses always call the parent reset function so that it isn't required to store the timer frequency within vmstate_mos6522_timer itself. By moving the frequency initialisation to the device reset function then we find that the realize function for both mos6522 and mos6522_cuda becomes obsolete and can simply be removed. Signed-off-by: Mark Cave-Ayland Signed-off-by: David Gibson --- hw/misc/macio/cuda.c | 6 +++--- hw/misc/mos6522.c | 13 +++---------- include/hw/misc/mos6522.h | 2 +- 3 files changed, 7 insertions(+), 14 deletions(-) diff --git a/hw/misc/macio/cuda.c b/hw/misc/macio/cuda.c index 8aba2e63ec..9651ed9744 100644 --- a/hw/misc/macio/cuda.c +++ b/hw/misc/macio/cuda.c @@ -597,12 +597,12 @@ static void mos6522_cuda_portB_write(MOS6522State *s) cuda_update(cs); } =20 -static void mos6522_cuda_realize(DeviceState *dev, Error **errp) +static void mos6522_cuda_reset(DeviceState *dev) { MOS6522State *ms =3D MOS6522(dev); MOS6522DeviceClass *mdc =3D MOS6522_DEVICE_GET_CLASS(ms); =20 - mdc->parent_realize(dev, errp); + mdc->parent_reset(dev); =20 ms->timers[0].frequency =3D CUDA_TIMER_FREQ; ms->timers[1].frequency =3D (SCALE_US * 6000) / 4700; @@ -613,7 +613,7 @@ static void mos6522_cuda_class_init(ObjectClass *oc, vo= id *data) DeviceClass *dc =3D DEVICE_CLASS(oc); MOS6522DeviceClass *mdc =3D MOS6522_DEVICE_CLASS(oc); =20 - dc->realize =3D mos6522_cuda_realize; + dc->reset =3D mos6522_cuda_reset; mdc->portB_write =3D mos6522_cuda_portB_write; mdc->get_timer1_counter_value =3D cuda_get_counter_value; mdc->get_timer2_counter_value =3D cuda_get_counter_value; diff --git a/hw/misc/mos6522.c b/hw/misc/mos6522.c index 524a250329..2f58b9707f 100644 --- a/hw/misc/mos6522.c +++ b/hw/misc/mos6522.c @@ -427,18 +427,12 @@ static void mos6522_reset(DeviceState *dev) /* s->ier =3D T1_INT | SR_INT; */ s->anh =3D 0; =20 + s->timers[0].frequency =3D s->frequency; s->timers[0].latch =3D 0xffff; set_counter(s, &s->timers[0], 0xffff); =20 - s->timers[1].latch =3D 0xffff; -} - -static void mos6522_realize(DeviceState *dev, Error **errp) -{ - MOS6522State *s =3D MOS6522(dev); - - s->timers[0].frequency =3D s->frequency; s->timers[1].frequency =3D s->frequency; + s->timers[1].latch =3D 0xffff; } =20 static void mos6522_init(Object *obj) @@ -469,11 +463,10 @@ static void mos6522_class_init(ObjectClass *oc, void = *data) DeviceClass *dc =3D DEVICE_CLASS(oc); MOS6522DeviceClass *mdc =3D MOS6522_DEVICE_CLASS(oc); =20 - dc->realize =3D mos6522_realize; dc->reset =3D mos6522_reset; dc->vmsd =3D &vmstate_mos6522; dc->props =3D mos6522_properties; - mdc->parent_realize =3D dc->realize; + mdc->parent_reset =3D dc->reset; mdc->set_sr_int =3D mos6522_set_sr_int; mdc->portB_write =3D mos6522_portB_write; mdc->portA_write =3D mos6522_portA_write; diff --git a/include/hw/misc/mos6522.h b/include/hw/misc/mos6522.h index cb0fd7db78..f52b41920b 100644 --- a/include/hw/misc/mos6522.h +++ b/include/hw/misc/mos6522.h @@ -130,7 +130,7 @@ typedef struct MOS6522State { typedef struct MOS6522DeviceClass { DeviceClass parent_class; =20 - DeviceRealize parent_realize; + DeviceReset parent_reset; void (*set_sr_int)(MOS6522State *dev); void (*portB_write)(MOS6522State *dev); void (*portA_write)(MOS6522State *dev); --=20 2.17.1