From patchwork Thu Nov 2 10:05:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Thomas Huth X-Patchwork-Id: 740437 Delivered-To: patch@linaro.org Received: by 2002:a5d:538f:0:b0:32d:baff:b0ca with SMTP id d15csp736987wrv; Thu, 2 Nov 2023 03:06:37 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHB1Wx3B4gGCcN/DT8gpsZOSAuzuPNKoLOwnx42BS0Be0RQE6ZL3AclAMjG8bs8RVvHy1nF X-Received: by 2002:a05:6214:29ee:b0:670:635f:6c67 with SMTP id jv14-20020a05621429ee00b00670635f6c67mr17427743qvb.63.1698919597280; Thu, 02 Nov 2023 03:06:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698919597; cv=none; d=google.com; s=arc-20160816; b=v6sqbf2EpYzVjCrLqYV2XojvDQ4YotFVEPNl+Zq0jY/90CGaC58BlLgP9vqaCsSPb0 S2iP/tSK6mPRrSIXJrrf+l9uuZ0FQwD00QuBiEZ8cHAUhH4QqpdIbvhhdJQZiwpaxYkA oLyBQU/T4TrjSCvqcb3Pdm0YIIOrj3UeAzLMWoXCvsa1zkgC6YA9Ubgyg6amHyvTOC/c sqf2Vv1DjkOvM6OzP5eE9dmKpOGLdLS6D0Ct7FJoOkGTGMa9fqxAvPlKigLG1jynmnH+ FkUwopoJfO94HQd7QqOsY/KUCsp2hza9ISRnaxXBn55k+Hizfy098TqSU3kHDDNL/Aa5 qSOg== 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; bh=b4aU3XAKLeX+XGRwvVl+KDuHHFhHb9tLltsT3xNn8sc=; fh=iCN9tuTwM5rayWWWJtHoGNfuTLfrQgz//t8J35Hw7Ts=; b=0azjOUJHykB0Xb8JF6NKy0+vEhjGpTvRXK/s9hC4dHQ/Pw/7wMxfOjR0y67ZtfCTpY t0NysoftWStiknubuMfarlUDeeT48VljZYpL9XAUJRPvhmXg57b6ly+prGXIMf+WTpXR sP11XmDKZVfuAbU4e9KUv2y12HwWb/KkaJnV3iPXLPbGOWKybpKBTBzF3xjO9XC4N+l4 rwIleJoC32Th2ex+efJPvYGYm5s92dXKkKvPAVSKcl5IUlFiMgjC9Daayfbch6LCxzWU X9xLCUNF13SBdoC2XyJA73bJHrCjEVg8h/fv436Kwk81oTISwdjddbHJ61OAlCSYGyiK KGCA== ARC-Authentication-Results: i=1; mx.google.com; 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" Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id v6-20020ad45286000000b0065d051fc43dsi4101017qvr.187.2023.11.02.03.06.37 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 02 Nov 2023 03:06:37 -0700 (PDT) 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; 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" Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qyUaN-0001oV-Rn; Thu, 02 Nov 2023 06:05:59 -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 1qyUaM-0001np-06 for qemu-devel@nongnu.org; Thu, 02 Nov 2023 06:05:58 -0400 Received: from mail-ej1-f46.google.com ([209.85.218.46]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qyUaK-0003GO-Dn for qemu-devel@nongnu.org; Thu, 02 Nov 2023 06:05:57 -0400 Received: by mail-ej1-f46.google.com with SMTP id a640c23a62f3a-9d224dca585so110991766b.1 for ; Thu, 02 Nov 2023 03:05:56 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698919555; x=1699524355; 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=b4aU3XAKLeX+XGRwvVl+KDuHHFhHb9tLltsT3xNn8sc=; b=XgoW3ISEbTnof3S9+0vOsUIyDpiHoC2tjynBpw4g3ac2E6eg38fJBtdJ2uQtJHK+70 0iRDY7eVh2iOrbHJDcGaQfRsdd8w80AZepSZAJy7dcHHXq8qXmf1enVesBaxoh4mQldN psg6d05YntWlMvdDFY9cdFs06LBG2NKaAkMcnk7cpmwjKjXusI5hNlUHxjQseHV4kCYT /gOE7Ay3uRMPBM0NNN1tGwRvp1WfPYB896TJ0Ag5NtWaXGOQp6nqijj7dKL/YV2vHlVT +XZuDsWq+ZEpJw/0qlgh8uqr5Xr11LbrjmYEDs5uoPexn6UIojZTIChHH/eHVn/6apOb K8/g== X-Gm-Message-State: AOJu0YxPIS3BuiQ0EhHvuDajw0zzHznraNneoDHykgRd3R1jIug0pDDs bhpBtSlIITFFyFeXy2B1OO0R7+0XnqQ= X-Received: by 2002:a17:907:a45:b0:9a6:1446:852c with SMTP id be5-20020a1709070a4500b009a61446852cmr4074504ejc.27.1698919554884; Thu, 02 Nov 2023 03:05:54 -0700 (PDT) Received: from localhost.localdomain (ip-109-42-115-39.web.vodafone.de. [109.42.115.39]) by smtp.gmail.com with ESMTPSA id o21-20020a170906359500b009b97d9ae329sm927236ejb.198.2023.11.02.03.05.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Nov 2023 03:05:54 -0700 (PDT) From: Thomas Huth To: qemu-devel@nongnu.org, Stefan Hajnoczi Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PULL 04/10] hw/m68k/mcf_intc: Pass CPU using QOM link property Date: Thu, 2 Nov 2023 11:05:37 +0100 Message-ID: <20231102100543.4875-5-huth@tuxfamily.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231102100543.4875-1-huth@tuxfamily.org> References: <20231102100543.4875-1-huth@tuxfamily.org> MIME-Version: 1.0 Received-SPF: pass client-ip=209.85.218.46; envelope-from=th.huth@gmail.com; helo=mail-ej1-f46.google.com X-Spam_score_int: -13 X-Spam_score: -1.4 X-Spam_bar: - X-Spam_report: (-1.4 / 5.0 requ) BAYES_00=-1.9, FREEMAIL_FORGED_FROMDOMAIN=0.249, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no 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 From: Philippe Mathieu-Daudé QOM objects shouldn't access each other internals fields except using the QOM API. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson Tested-by: Thomas Huth Reviewed-by: Thomas Huth Message-ID: <20231024083010.12453-5-philmd@linaro.org> Signed-off-by: Thomas Huth --- hw/m68k/mcf_intc.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/hw/m68k/mcf_intc.c b/hw/m68k/mcf_intc.c index 1f74ea0e14..1d3b34e18c 100644 --- a/hw/m68k/mcf_intc.c +++ b/hw/m68k/mcf_intc.c @@ -14,6 +14,7 @@ #include "hw/irq.h" #include "hw/sysbus.h" #include "hw/m68k/mcf.h" +#include "hw/qdev-properties.h" #include "qom/object.h" #define TYPE_MCF_INTC "mcf-intc" @@ -176,10 +177,17 @@ static void mcf_intc_instance_init(Object *obj) sysbus_init_mmio(SYS_BUS_DEVICE(obj), &s->iomem); } +static Property mcf_intc_properties[] = { + DEFINE_PROP_LINK("m68k-cpu", mcf_intc_state, cpu, + TYPE_M68K_CPU, M68kCPU *), + DEFINE_PROP_END_OF_LIST(), +}; + static void mcf_intc_class_init(ObjectClass *oc, void *data) { DeviceClass *dc = DEVICE_CLASS(oc); + device_class_set_props(dc, mcf_intc_properties); set_bit(DEVICE_CATEGORY_MISC, dc->categories); dc->reset = mcf_intc_reset; } @@ -204,16 +212,13 @@ qemu_irq *mcf_intc_init(MemoryRegion *sysmem, M68kCPU *cpu) { DeviceState *dev; - mcf_intc_state *s; dev = qdev_new(TYPE_MCF_INTC); + object_property_set_link(OBJECT(dev), "m68k-cpu", + OBJECT(cpu), &error_abort); sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal); - - s = MCF_INTC(dev); - s->cpu = cpu; - memory_region_add_subregion(sysmem, base, sysbus_mmio_get_region(SYS_BUS_DEVICE(dev), 0)); - return qemu_allocate_irqs(mcf_intc_set_irq, s, 64); + return qemu_allocate_irqs(mcf_intc_set_irq, dev, 64); }