From patchwork Wed Nov 9 17:00:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 622937 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp379628pvb; Wed, 9 Nov 2022 09:01:25 -0800 (PST) X-Google-Smtp-Source: AMsMyM6RjvQfkuCeb29jX4Fi1rCukC63HrjD1qRTwsaWEATjpYJzlU7UZWke3DZXRRtxYOirRdWi X-Received: by 2002:a05:6214:194d:b0:4c0:3ab5:25ee with SMTP id q13-20020a056214194d00b004c03ab525eemr28637329qvk.10.1668013284938; Wed, 09 Nov 2022 09:01:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668013284; cv=none; d=google.com; s=arc-20160816; b=Ulj/LdlO2pCubRBFjU0d8CfVrnzEIS5f9rFTtJ36LYGyImaCVlIFxWr3Zu8CMSbUTW CI9m5JTD9k9opCOLGGRmfNb10oGVRRK7lzdFdcCNJbsdh/sFjZ1o/S7X2pq/c833R7w+ 7dMVRS9/ROCeLa1OHPXicKLXiqsZUEBG2VOZraoSKpQuleUnn3HNDcY4LSNDpr+SvPk0 vbUItwn8Q4tsZg49KWV/LVf/9Y18npjtGASmN981PtfDhpr+70DU1Pspm2iA8qcS85pR ZL/NpuiZC1DeKVxU63+4TbhihqAIp0DIV63Pz+Jp44thSZ4KxnemZgL18DaDtD1B7tn5 qguA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=P/HzFUMC1BdHvhejcPUHEkS5z3kNmrAEn9w+43U063E=; b=sGQn9jymIF14B2Ml0xuQqmEUwWfzFNPbn9wKOM+rpvJReVLCywZDfYwYU5WUVq+0Xg 93rtiAeeeKoP7q9InAAXWtzd5OSp0q9Ph9yOPOYNL2S40wDNdKow7rRwu0Ec/9QsHUoR Zomk4lFvXPYELVoGmUyIXTZBFi97ElUI63UKAa0W4+gKdzSCKV6rGtLtTAmmT2qrT/uB bmmDF1Iwvq191xiGnqfKBBFsQkCR/baBhzaEfs+bguVDNjfldf7pwyfq06EeLO4J4Boz rSOoF+Q4/VXaZS3uFFlF6aF38rUZMPzJXxnGk9hpCc892nx5Qv8iD8TfHYZs6vmDu1Hd cADw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=o660eO91; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id gd14-20020a05622a5c0e00b003a5214d70e9si9124969qtb.678.2022.11.09.09.01.24 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 09 Nov 2022 09:01:24 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=o660eO91; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1osoR5-0003o8-H3; Wed, 09 Nov 2022 12:00:23 -0500 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 1osoQx-0003n1-Oh for qemu-devel@nongnu.org; Wed, 09 Nov 2022 12:00:15 -0500 Received: from mail-wr1-x42e.google.com ([2a00:1450:4864:20::42e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1osoQw-00019g-5r for qemu-devel@nongnu.org; Wed, 09 Nov 2022 12:00:15 -0500 Received: by mail-wr1-x42e.google.com with SMTP id v1so26663395wrt.11 for ; Wed, 09 Nov 2022 09:00:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=P/HzFUMC1BdHvhejcPUHEkS5z3kNmrAEn9w+43U063E=; b=o660eO91eDH2HCLaNH3uS51pqdcjZRLQ+mSItNPLq37N3hh4tRvnO/j/IB4tvv/7r7 SfIroELONdnArVxIpYjG5rngiq07iVqcJodz3vVGoNxoZ0opxid46zKTfOudlCoYQrO4 E841CGYu+NQ4uPVhmOwSva4fntPpBAW+PaEjPnV0Qe2f13tb64Ooc4O8vfMvLc1Gx9fX LDoA3QzoLvx58Wsn28WbITsXwnIBOHF0KC47H1UcZoGgvF1jS2Qnif/uIxixr19JRXxR njXLEmH0MBG0JYVszW9kgM7pkcNmfqnwq3KbGnBT1BMIhm0Ai5AvyixUzgWw7kdiwHPv 3dzg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=P/HzFUMC1BdHvhejcPUHEkS5z3kNmrAEn9w+43U063E=; b=3hCLBJV8JjHWaCmbcvShemjgmZH+5DoX85VVa1SN2SuRZBkq/ilobC04HSBIetVlKI F73/ChKDKI6DMjZ0yy5aJtqi/EElOKIYAQPDwCWy5v3iZ5QGvqpopOqVxPWTl2+68ImA yeqTBnZxBfzd5f6bUaqT6pTMXN5GrrDRSTNSCCapGuoFEM7sWN1qFEH0fp4Hfm3T4ZYl v55QZKB1H6AX7hjttAetJ8FGDBC9nn2PTw2fMSx5GX7DSYCd0eO8QdPGCf/ySW11QZLY 8InYt013RB0ODe75WqunBNHk36PZx0XEBz0iBT8w7iwySQqONwPcTf2777gygGFmZO44 KZug== X-Gm-Message-State: ACrzQf3HW2ABjEWfH0A3hrKKbm7RYqNJupf0b0NDytWgxcZQuofUOBw0 W0EOowjFjJcHJIMNAOrbKjKDxJg43VomSQ== X-Received: by 2002:adf:f741:0:b0:236:5aa8:a07e with SMTP id z1-20020adff741000000b002365aa8a07emr933201wrp.437.1668013212555; Wed, 09 Nov 2022 09:00:12 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id p5-20020a05600c358500b003c6b9749505sm2514932wmq.30.2022.11.09.09.00.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Nov 2022 09:00:12 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Cc: Mark Cave-Ayland Subject: [PATCH for-8.0 1/2] hw/input/ps2: Convert TYPE_PS2_DEVICE to 3-phase reset Date: Wed, 9 Nov 2022 17:00:08 +0000 Message-Id: <20221109170009.3498451-2-peter.maydell@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221109170009.3498451-1-peter.maydell@linaro.org> References: <20221109170009.3498451-1-peter.maydell@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::42e; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x42e.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@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-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Convert the parent class TYPE_PS2_DEVICE to 3-phase reset. Note that we need an 'exit' phase function as well as the usual 'hold' phase function, because changing outbound IRQ line state is only permitted in 'exit'. (Strictly speaking it's not supposed to be done in a legacy reset handler either, but you can often get away with it.) Signed-off-by: Peter Maydell Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson --- hw/input/ps2.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/hw/input/ps2.c b/hw/input/ps2.c index 05cf7111e31..47a5d68e300 100644 --- a/hw/input/ps2.c +++ b/hw/input/ps2.c @@ -1001,12 +1001,18 @@ void ps2_write_mouse(PS2MouseState *s, int val) } } -static void ps2_reset(DeviceState *dev) +static void ps2_reset_hold(Object *obj) { - PS2State *s = PS2_DEVICE(dev); + PS2State *s = PS2_DEVICE(obj); s->write_cmd = -1; ps2_reset_queue(s); +} + +static void ps2_reset_exit(Object *obj) +{ + PS2State *s = PS2_DEVICE(obj); + ps2_lower_irq(s); } @@ -1281,8 +1287,10 @@ static void ps2_init(Object *obj) static void ps2_class_init(ObjectClass *klass, void *data) { DeviceClass *dc = DEVICE_CLASS(klass); + ResettableClass *rc = RESETTABLE_CLASS(klass); - dc->reset = ps2_reset; + rc->phases.hold = ps2_reset_hold; + rc->phases.exit = ps2_reset_exit; set_bit(DEVICE_CATEGORY_INPUT, dc->categories); } From patchwork Wed Nov 9 17:00:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 622938 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp379629pvb; Wed, 9 Nov 2022 09:01:25 -0800 (PST) X-Google-Smtp-Source: AMsMyM4qnQBDDZsj4eEXs7tCjKOjwqBPrZBkB9m7RpqTE5Et9rExmF9sOW9/hczBBKh0mirBej2J X-Received: by 2002:a05:622a:249:b0:3a5:75a5:d038 with SMTP id c9-20020a05622a024900b003a575a5d038mr19142011qtx.359.1668013284955; Wed, 09 Nov 2022 09:01:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668013284; cv=none; d=google.com; s=arc-20160816; b=USp5aMRnydT0keFO+y1h+hoGgY1bKi93mf7etvVKZs7Sm4txW/t2Hvmxq/SG/VogWY wCYTczXQ8jK8UMmS2MDa1ckB5+m5RqrIxkn8sBaRK9HvXbL/R3gvl23fTCTf5npn8vSi xfGAYiXp/W2L+Rybc0tTQVhPhqmbAL0T5DdxmAzjuRZ6A4eYwCCb2mg9ByHGB34zUFj5 LpXcXs+up3Qzi01hJElZHj/B0Wk6giBn1ZF6C4ggvx3zxdo5Dl/qY2DMNDr/HWfXVrJA AJK+z31wczMnpxwTXtnJuRcL/++9EQU/RNxcd3ju5kkIr0Q8SijgxqgBmmSx+LZUhtwd s23g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=rBlWL4FLtY8mNZis1U2K8M01p6OCavCbUHNH6wH10ks=; b=qjBBrSc1jOHYXTomQ5yWKOOw0xMR9xRHc5uQdIcLE5MfuX/+pV0gPlCw4734ySbfgn OhRk1UdwzsNlqxkCx45uRlncMLxlm9FXcPKaT0pu3kxylPtxKiqvuYIBUgIx/OVmaCd6 SWXOfjTE44PuR0S3Z8Fmoi0v9CKr6cQUOi2C42WbMfrLmq8ljDm8Gf/V823GSXPFdQZ5 BfeMMt5vSOhtkoUtX2rVHyxlCmlJZFkVW0wfFUsDEzdSrhvoSKJTMKgjiaFmLUkbki0K 5tAOOsVOP28EQ+rqR1OOglOgfJpOPm6yfWxWgF4IWO8sVWSbuvQyzL2XoYhc9LZc1MvC aPMg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=cnIOyNhi; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id j26-20020ac84c9a000000b003a515ddc92esi7714494qtv.227.2022.11.09.09.01.24 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 09 Nov 2022 09:01:24 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=cnIOyNhi; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1osoRp-00040y-RM; Wed, 09 Nov 2022 12:01:10 -0500 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 1osoQz-0003nc-2O for qemu-devel@nongnu.org; Wed, 09 Nov 2022 12:00:22 -0500 Received: from mail-wm1-x32f.google.com ([2a00:1450:4864:20::32f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1osoQx-0001AD-C1 for qemu-devel@nongnu.org; Wed, 09 Nov 2022 12:00:16 -0500 Received: by mail-wm1-x32f.google.com with SMTP id 187-20020a1c02c4000000b003cf9c3f3b80so1689280wmc.0 for ; Wed, 09 Nov 2022 09:00:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=rBlWL4FLtY8mNZis1U2K8M01p6OCavCbUHNH6wH10ks=; b=cnIOyNhigbJdv0VAYsfj2TpeBr28bxf6/i7swW4drNVDB7CKtQl8NC+hq3G2zXNEwi Dh86RL2wu8YYOp/nN/QP+Ngd+IRhO7ErUTg/cLfae9naJKUExA7gvZzQZkP8pkrb1yZA e8w0GKFLje1kg1VBr2ymkQgtp4tL8fj9xlQq1Eqj4Dt5xpMgYQS7n1Ok4Ul5yVueXRig F0Vbtx/6dAI3FiaABJZKP7J1Y00f8+pKI3PJqgNwrAgMmqEQttZjPpp+ylqpmr3ElT/x 1kCqwzqy2Kk2Niafw5+rZepuv4NBktFc2jBB7l8ROpVlUvU2I5QavdORt0BNsMiWgVBS FVJA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=rBlWL4FLtY8mNZis1U2K8M01p6OCavCbUHNH6wH10ks=; b=FT11A2YamsAkG8Qdfrmx6dHg/JXQ6leiQdwnVvWr/0FdSwcgc8dHl1HLs5HA9x7NdY DLgK2CMWptgbDIUT+MIrP2rnKi4KI6VBHUPPstTBvpnqug8K0eg1lmjpXd7I4ajRhUOC QrLh4CZvcXPjUhConepzvqaS3V7hCeLYjNiI5pCcVIYpT9LHoftuOuMasO5NpaeLfnMs lSRur6hfr9vsQ8jq2McjGGjQckVm+DJYO+mefZUoqhP4WQkbQBM5kFwxd945tGcDIVEr ZfBN8++pwPKvkSKgF+W0Hu5XJjLX3ZateEDxsqwoZIlIAHQisJl0uL89Uc6msyu//qKN HCYQ== X-Gm-Message-State: ACrzQf2qzCnyVv8v8AeGF18SCTTnYFarBAzv+h8tnxVFOFTNZq2IiXpI Wt62C/9SQ4kALWOBcRoCCwW4QBup2wFmmg== X-Received: by 2002:a05:600c:3482:b0:3cf:6af4:c4fa with SMTP id a2-20020a05600c348200b003cf6af4c4famr938490wmq.117.1668013213636; Wed, 09 Nov 2022 09:00:13 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id p5-20020a05600c358500b003c6b9749505sm2514932wmq.30.2022.11.09.09.00.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Nov 2022 09:00:13 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Cc: Mark Cave-Ayland Subject: [PATCH for-8.0 2/2] hw/input/ps2.c: Convert TYPE_PS2_{KBD, MOUSE}_DEVICE to 3-phase reset Date: Wed, 9 Nov 2022 17:00:09 +0000 Message-Id: <20221109170009.3498451-3-peter.maydell@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221109170009.3498451-1-peter.maydell@linaro.org> References: <20221109170009.3498451-1-peter.maydell@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32f; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x32f.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@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-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Convert the child classes TYPE_PS2_KBD_DEVICE and TYPE_PS2_MOUSE_DEVICE to the 3-phase reset system. This allows us to stop using the old device_class_set_parent_reset() function. We don't need to register an 'exit' phase function for the subclasses, because they have no work to do in that phase. Passing NULL to resettable_class_set_parent_phases() will result in the parent class method being called for that phase, so we don't need to register a function purely to chain to the parent 'exit' phase function. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé --- include/hw/input/ps2.h | 2 +- hw/input/ps2.c | 31 ++++++++++++++++++++----------- 2 files changed, 21 insertions(+), 12 deletions(-) diff --git a/include/hw/input/ps2.h b/include/hw/input/ps2.h index ff777582cd6..cd61a634c39 100644 --- a/include/hw/input/ps2.h +++ b/include/hw/input/ps2.h @@ -36,7 +36,7 @@ struct PS2DeviceClass { SysBusDeviceClass parent_class; - DeviceReset parent_reset; + ResettablePhases parent_phases; }; /* diff --git a/hw/input/ps2.c b/hw/input/ps2.c index 47a5d68e300..3253ab6a92c 100644 --- a/hw/input/ps2.c +++ b/hw/input/ps2.c @@ -1042,13 +1042,16 @@ static void ps2_common_post_load(PS2State *s) q->cwptr = ccount ? (q->rptr + ccount) & (PS2_BUFFER_SIZE - 1) : -1; } -static void ps2_kbd_reset(DeviceState *dev) +static void ps2_kbd_reset_hold(Object *obj) { - PS2DeviceClass *ps2dc = PS2_DEVICE_GET_CLASS(dev); - PS2KbdState *s = PS2_KBD_DEVICE(dev); + PS2DeviceClass *ps2dc = PS2_DEVICE_GET_CLASS(obj); + PS2KbdState *s = PS2_KBD_DEVICE(obj); trace_ps2_kbd_reset(s); - ps2dc->parent_reset(dev); + + if (ps2dc->parent_phases.hold) { + ps2dc->parent_phases.hold(obj); + } s->scan_enabled = 1; s->translate = 0; @@ -1056,13 +1059,16 @@ static void ps2_kbd_reset(DeviceState *dev) s->modifiers = 0; } -static void ps2_mouse_reset(DeviceState *dev) +static void ps2_mouse_reset_hold(Object *obj) { - PS2DeviceClass *ps2dc = PS2_DEVICE_GET_CLASS(dev); - PS2MouseState *s = PS2_MOUSE_DEVICE(dev); + PS2DeviceClass *ps2dc = PS2_DEVICE_GET_CLASS(obj); + PS2MouseState *s = PS2_MOUSE_DEVICE(obj); trace_ps2_mouse_reset(s); - ps2dc->parent_reset(dev); + + if (ps2dc->parent_phases.hold) { + ps2dc->parent_phases.hold(obj); + } s->mouse_status = 0; s->mouse_resolution = 0; @@ -1245,10 +1251,12 @@ static void ps2_mouse_realize(DeviceState *dev, Error **errp) static void ps2_kbd_class_init(ObjectClass *klass, void *data) { DeviceClass *dc = DEVICE_CLASS(klass); + ResettableClass *rc = RESETTABLE_CLASS(klass); PS2DeviceClass *ps2dc = PS2_DEVICE_CLASS(klass); dc->realize = ps2_kbd_realize; - device_class_set_parent_reset(dc, ps2_kbd_reset, &ps2dc->parent_reset); + resettable_class_set_parent_phases(rc, NULL, ps2_kbd_reset_hold, NULL, + &ps2dc->parent_phases); dc->vmsd = &vmstate_ps2_keyboard; } @@ -1262,11 +1270,12 @@ static const TypeInfo ps2_kbd_info = { static void ps2_mouse_class_init(ObjectClass *klass, void *data) { DeviceClass *dc = DEVICE_CLASS(klass); + ResettableClass *rc = RESETTABLE_CLASS(klass); PS2DeviceClass *ps2dc = PS2_DEVICE_CLASS(klass); dc->realize = ps2_mouse_realize; - device_class_set_parent_reset(dc, ps2_mouse_reset, - &ps2dc->parent_reset); + resettable_class_set_parent_phases(rc, NULL, ps2_mouse_reset_hold, NULL, + &ps2dc->parent_phases); dc->vmsd = &vmstate_ps2_mouse; }