From patchwork Thu Nov 2 10:05:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Thomas Huth X-Patchwork-Id: 740438 Delivered-To: patch@linaro.org Received: by 2002:a5d:538f:0:b0:32d:baff:b0ca with SMTP id d15csp737634wrv; Thu, 2 Nov 2023 03:07:28 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHvY+JdzdNgpP7w86r8kbqzVdib/NjhgDp3Q2CHHF3tFC2hHfP6ON/ZkUh4l9MdI0QMDKh4 X-Received: by 2002:a05:6808:1389:b0:3b2:e60d:27f6 with SMTP id c9-20020a056808138900b003b2e60d27f6mr22855782oiw.29.1698919648447; Thu, 02 Nov 2023 03:07:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698919648; cv=none; d=google.com; s=arc-20160816; b=tucKqdkSc2THnHO/JIJ8qcvMxQma7nPLVIUj0Fy9AG4HlZffXEnGJyJTVDuawP4Gc3 /rIaAcwckXGgy6FC78uzFbsFWTYLWOAlyATdKS0Qq2qY+71PQnS7EQgaBhAer4Y8Zf2l EiBD7PfdiSV4D9QV4uxLGJEetZn2WBPiGo2NUpLmJjaZAzsfQvot3k7jvsYmQIvaiZAh c1AjPPB44mv4mbywpTA+zdcgZw8EFnctnNMlzTopcCb8Ji/l8L0rbHviJsEfy4SEoiXa USH+xaOrRd8Y+5K+ZyDhCri+wlEA+GRphoph8O71c+4h5mGVmS+lGoRhBjjzlKv9dx0X PE8w== 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=Q9wRpJQSdYBWKaTUTBDuByfEDItBoYOl7xYTvQ6DLvg=; fh=iCN9tuTwM5rayWWWJtHoGNfuTLfrQgz//t8J35Hw7Ts=; b=M99MudtWD2bopaqS3IH5FeAw0hZFQQbfwgk1H4ead5fAC1FcrCBCDkU4RItgZEafD1 CTWwyc1GlSsWOTO1LsFjh/whV9tCEkKRTAE7MsFrU+qZGCdt6qMHl3aUVIawiquwi05m sm2/2VRRnDWcA50+I/fk2OXnsQGzsfECIKg7CVaTYeUYoIQmM/JUhCM79n0S7mIebeOc f4SctyaT/UtwTwQsgTE5nG3mtU36VL1Jzj/5O7I0cczijA+Tn8F+aPL5LC4dMmfOQWWl LYsKHE6RUYc7tV8wZl+NfQDPXoiNbGt3UMtAIMLzRhmfI21u/n1GxFJORepxnGTTkAdz 61pA== 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 x13-20020a05620a098d00b0077a2952b488si4016530qkx.689.2023.11.02.03.07.28 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 02 Nov 2023 03:07:28 -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 1qyUaT-0001qY-TV; Thu, 02 Nov 2023 06:06:05 -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 1qyUaP-0001ol-Us for qemu-devel@nongnu.org; Thu, 02 Nov 2023 06:06:01 -0400 Received: from mail-ej1-f50.google.com ([209.85.218.50]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qyUaN-0003IM-9j for qemu-devel@nongnu.org; Thu, 02 Nov 2023 06:06:01 -0400 Received: by mail-ej1-f50.google.com with SMTP id a640c23a62f3a-9d2c54482fbso113566666b.2 for ; Thu, 02 Nov 2023 03:05:58 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698919558; x=1699524358; 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=Q9wRpJQSdYBWKaTUTBDuByfEDItBoYOl7xYTvQ6DLvg=; b=mDBo5n7CRjVIceoZYM/Dc7p0tKtRAsj4jaBpUnYQS0SOUlzkaNbKALR2VvpwcBn5iQ 0Dst488KgwNFvFTDNdKUoELdeHf5zd2QtG5pV2SIFtaw8/Kf/BVCkTXuWIgcOpcsCi0M JZWSf2suEN+x/Wh/CR+RDQPtFhV4zJypLaBCb/O73DdCitF990PEoXxRTiEcuw9NWSg6 /YmecjGSE99xp/m92h7rEMlQp4HvYnJEiwNSDTT24eUxaegAQm8/iDJRSpvKQEcfvPFD NqYXE/IJwqqv9JsvJ4a6uMEvIdtAI9Wzdh0LCoaz5HaaBag/glxaDppCfOR+kbIhKlMM DplA== X-Gm-Message-State: AOJu0YylFnw3IV1WSMqjDtmXgLm0UkBabkND8Od3g74+vdr02QQkd+SP D0nya+sXnh1Scan08obO57+McYkB64o= X-Received: by 2002:a17:907:36c5:b0:9d5:7c41:cd0a with SMTP id bj5-20020a17090736c500b009d57c41cd0amr4059888ejc.19.1698919557884; Thu, 02 Nov 2023 03:05:57 -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.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Nov 2023 03:05:57 -0700 (PDT) From: Thomas Huth To: qemu-devel@nongnu.org, Stefan Hajnoczi Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PULL 07/10] hw/char/mcf_uart: Have mcf_uart_create() return DeviceState Date: Thu, 2 Nov 2023 11:05:40 +0100 Message-ID: <20231102100543.4875-8-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.50; envelope-from=th.huth@gmail.com; helo=mail-ej1-f50.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é There is no point in having mcf_uart_init() demote the DeviceState pointer and return a void one. Directly return the real typedef. mcf_uart_init() do both init + realize: rename as mcf_uart_create(). Similarly, mcf_uart_mm_init() do init / realize / mmap: rename as mcf_uart_create_mmap(). Signed-off-by: Philippe Mathieu-Daudé Message-ID: <20231019104929.16517-1-philmd@linaro.org> Signed-off-by: Thomas Huth --- hw/char/mcf_uart.c | 13 +++++++------ hw/m68k/mcf5206.c | 6 +++--- hw/m68k/mcf5208.c | 6 +++--- include/hw/m68k/mcf.h | 4 ++-- 4 files changed, 15 insertions(+), 14 deletions(-) diff --git a/hw/char/mcf_uart.c b/hw/char/mcf_uart.c index 6fa4ac502c..f9cbc9bdc4 100644 --- a/hw/char/mcf_uart.c +++ b/hw/char/mcf_uart.c @@ -342,25 +342,26 @@ static void mcf_uart_register(void) type_init(mcf_uart_register) -void *mcf_uart_init(qemu_irq irq, Chardev *chrdrv) +DeviceState *mcf_uart_create(qemu_irq irq, Chardev *chrdrv) { - DeviceState *dev; + DeviceState *dev; dev = qdev_new(TYPE_MCF_UART); if (chrdrv) { qdev_prop_set_chr(dev, "chardev", chrdrv); } sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal); - sysbus_connect_irq(SYS_BUS_DEVICE(dev), 0, irq); return dev; } -void mcf_uart_mm_init(hwaddr base, qemu_irq irq, Chardev *chrdrv) +DeviceState *mcf_uart_create_mmap(hwaddr base, qemu_irq irq, Chardev *chrdrv) { - DeviceState *dev; + DeviceState *dev; - dev = mcf_uart_init(irq, chrdrv); + dev = mcf_uart_create(irq, chrdrv); sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, base); + + return dev; } diff --git a/hw/m68k/mcf5206.c b/hw/m68k/mcf5206.c index f920ca2ceb..a46a23538d 100644 --- a/hw/m68k/mcf5206.c +++ b/hw/m68k/mcf5206.c @@ -168,7 +168,7 @@ typedef struct { MemoryRegion iomem; qemu_irq *pic; m5206_timer_state *timer[2]; - void *uart[2]; + DeviceState *uart[2]; uint8_t scr; uint8_t icr[14]; uint16_t imr; /* 1 == interrupt is masked. */ @@ -600,8 +600,8 @@ static void mcf5206_mbar_realize(DeviceState *dev, Error **errp) s->pic = qemu_allocate_irqs(m5206_mbar_set_irq, s, 14); s->timer[0] = m5206_timer_init(s->pic[9]); s->timer[1] = m5206_timer_init(s->pic[10]); - s->uart[0] = mcf_uart_init(s->pic[12], serial_hd(0)); - s->uart[1] = mcf_uart_init(s->pic[13], serial_hd(1)); + s->uart[0] = mcf_uart_create(s->pic[12], serial_hd(0)); + s->uart[1] = mcf_uart_create(s->pic[13], serial_hd(1)); } static Property mcf5206_mbar_properties[] = { diff --git a/hw/m68k/mcf5208.c b/hw/m68k/mcf5208.c index be1033f84f..d22d8536db 100644 --- a/hw/m68k/mcf5208.c +++ b/hw/m68k/mcf5208.c @@ -261,9 +261,9 @@ static void mcf5208evb_init(MachineState *machine) /* Internal peripherals. */ pic = mcf_intc_init(address_space_mem, 0xfc048000, cpu); - mcf_uart_mm_init(0xfc060000, pic[26], serial_hd(0)); - mcf_uart_mm_init(0xfc064000, pic[27], serial_hd(1)); - mcf_uart_mm_init(0xfc068000, pic[28], serial_hd(2)); + mcf_uart_create_mmap(0xfc060000, pic[26], serial_hd(0)); + mcf_uart_create_mmap(0xfc064000, pic[27], serial_hd(1)); + mcf_uart_create_mmap(0xfc068000, pic[28], serial_hd(2)); mcf5208_sys_init(address_space_mem, pic); diff --git a/include/hw/m68k/mcf.h b/include/hw/m68k/mcf.h index 8cbd587bbf..5d9f876ffe 100644 --- a/include/hw/m68k/mcf.h +++ b/include/hw/m68k/mcf.h @@ -10,8 +10,8 @@ uint64_t mcf_uart_read(void *opaque, hwaddr addr, unsigned size); void mcf_uart_write(void *opaque, hwaddr addr, uint64_t val, unsigned size); -void *mcf_uart_init(qemu_irq irq, Chardev *chr); -void mcf_uart_mm_init(hwaddr base, qemu_irq irq, Chardev *chr); +DeviceState *mcf_uart_create(qemu_irq irq, Chardev *chr); +DeviceState *mcf_uart_create_mmap(hwaddr base, qemu_irq irq, Chardev *chr); /* mcf_intc.c */ qemu_irq *mcf_intc_init(struct MemoryRegion *sysmem,