From nobody Fri Apr 4 03:30:57 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1741565263; cv=none; d=zohomail.com; s=zohoarc; b=R79gFMI3R/16xB5Wu0/+o8hr0WfJWVzBP9abL/j7EJWJkKSxm0kWLpVkHL5hg4KqkAPln/TuQEckEC/8KBAnVCn3DD8CfA62Xfz0QTDBHfuiw1mamCgJkb3O25xIBZq+5hUU3QBkWoG1fItonckm56AElScwFwJGUwbxKEVQhf0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1741565263; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=ZOP1JCepoOpEGtD0DeikejYc/lpyX9gmrkBY6224GqM=; b=gdeDoAVCu97ZXTQ+0CsE5+CjD7Dshg+8MQDoGAsezlwBqA1RozfTjWxozkEjkN3ryCJF8U3UVPeNh9qEys53bRXuF6xuKNDJ7TDkbNYHeCcKWrjG9WgeCGLFRvm0LfVi8GlzpfdOk3Y1k0WtDR/GqcCIrpyQ5ZsIY5pdXfjxjmA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1741565263808340.3934418579486; Sun, 9 Mar 2025 17:07:43 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1trQfg-00026L-0h; Sun, 09 Mar 2025 20:07:04 -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 1trQfa-00022f-TB for qemu-devel@nongnu.org; Sun, 09 Mar 2025 20:06:59 -0400 Received: from mail-wr1-x42a.google.com ([2a00:1450:4864:20::42a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1trQfZ-0007My-1v for qemu-devel@nongnu.org; Sun, 09 Mar 2025 20:06:58 -0400 Received: by mail-wr1-x42a.google.com with SMTP id ffacd0b85a97d-3912fdddf8fso1699506f8f.1 for ; Sun, 09 Mar 2025 17:06:56 -0700 (PDT) Received: from localhost.localdomain (88-187-86-199.subs.proxad.net. [88.187.86.199]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3912bfe0004sm12885561f8f.40.2025.03.09.17.06.54 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Sun, 09 Mar 2025 17:06:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1741565216; x=1742170016; darn=nongnu.org; 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=ZOP1JCepoOpEGtD0DeikejYc/lpyX9gmrkBY6224GqM=; b=M2HY8597TyFM9qb24Gu96A+k+r5X6Te+fHAgXNag0yUv9lcB0+fHlgq5IbV79IsIUi DUYfGnkP7q6pW43mIsgQStZEFWAbsrFSatyxyjROVaDCTVMWglcPC0bzigSEXLEfamLE MlsU+FeiohwySuxV5GbhMqzOl1vxzDli38aMn4Kl52Z/sRLUyALkOcSLy3rQ3fxIsAv4 vZCP+1muSoSp2wGhFtEuRsOjOhfYGZ+hupZGGjytNm8h11ra7uIrKw0GM8M5imOgrFlQ Ws9ATEjwxnhsB776Z8HEOMUdojWTKSed1U7yB4ui5yEA2CH57uV4o9mzRq8gZN0u3Vpe cQpQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1741565216; x=1742170016; 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=ZOP1JCepoOpEGtD0DeikejYc/lpyX9gmrkBY6224GqM=; b=J1qtLclOPIintZekomsDNVbFxJX45MxppXvib0oErEWioinaUK3iIR98uX4Y3LKRo9 JyMWial7+YeSTkW+llhOcl73HgxYUeYOCM9k1R/tOBzBbMEFF7AJMgky42nKyOxmMPVL QmN5Ozmu3MSqLUdh9QTVqlcKOUFwTV2VdRxY/52Hp1FxdX09jxARKu9niCubXITaeK/o kgBZifq562BdsZOrHCzlsdmm4rdXdaOR0aQZQv+PDSQXsl6NWx7wDkwACdk2l2UswTAe lK6vx1CFxJ91MFn5cDEIJCbgVuZQTkF4AqoPk45sV9yWGdcwUASi9SFyQQANi6SAUFIa eIJg== X-Forwarded-Encrypted: i=1; AJvYcCVSauE1kwwsWX0Lvt8MNCq9bVaysct8aOs0Dbk1TL40LR5Rjqvo4Ls3fOESToXpvW2o/yDtjk7z2+if@nongnu.org X-Gm-Message-State: AOJu0YynnivJhtjYX5Tr86pJ2NJI7HgWpf9E8ff3ASWBHXt3qtyqNCyp XC2shRdr+7i+5ypKwnMIRPi2KTa+QlpEudl1d6V1VVCOcarSrEK4PdjU8bBtDbQ= X-Gm-Gg: ASbGncs9eQDgQK5rght81A+mFOryt23HmTSCKv4oocP4vqx+MMpeTYPz8b/rhEqNMkp CJrC4HXjG17ZiLnXCIhuLJNo8is7BPt2/LJ+9Sheg3wAtycw5q/bihKUfoO1v/cWrH7aJDeKoW8 SesPZgPHKT2Bz+YFXr7dLq7n7aGB40BF568i+WX0rTqmNoc0BrBXd0xCYIKWYlxiEZr/ay8rOEJ XbSczoko6H+v4neaCOtgsK1z0qvPLTkrRzFCxxrjuzr+JfMeqwDz2jx0Dee+0OqWcEMBdDHOllD QzogMvN1wHrGJUuBbsEx0khkf6ZAHyt9MsoUWjhD5qUsemHQE4vS3GgHqM+05o7Zuc6sC2eGoNq Fmjapn/sZNqFCN1/x/u4= X-Google-Smtp-Source: AGHT+IHZn5VNBCcyaAnuhIVlrKNkJ1fO3I+O/PeMTYOLZEWuAXd6veEaEqResUHxa0p0v8isyn7U9A== X-Received: by 2002:a5d:47cb:0:b0:391:21e2:ec3b with SMTP id ffacd0b85a97d-3913aed7e68mr4257819f8f.3.1741565215639; Sun, 09 Mar 2025 17:06:55 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: BALATON Zoltan , qemu-devel@nongnu.org Cc: Steven Lee , Joel Stanley , Bernhard Beschow , Peter Maydell , qemu-arm@nongnu.org, Andrey Smirnov , Paolo Bonzini , Bin Meng , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Eduardo Habkost , qemu-ppc@nongnu.org, =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Guenter Roeck , Andrew Jeffery , Troy Lee , Jean-Christophe Dubois , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-block@nongnu.org, Jamin Lin Subject: [PATCH v5 06/14] hw/sd/sdhci: Introduce SDHCIClass stub Date: Mon, 10 Mar 2025 01:06:12 +0100 Message-ID: <20250310000620.70120-7-philmd@linaro.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250310000620.70120-1-philmd@linaro.org> References: <20250310000620.70120-1-philmd@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::42a; envelope-from=philmd@linaro.org; helo=mail-wr1-x42a.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=unavailable 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1741565266936019000 TYPE_SYSBUS_SDHCI is a bit odd because it uses an union to work with both SysBus / PCI parent. For this reason, we can not use the OBJECT_DECLARE_TYPE() macro twice (on SYSBUS_SDHCI & PCI_SDHCI) and we must keep a pair of lower DECLARE_INSTANCE_CHECKER) and DECLARE_CLASS_CHECKERS() for PCI, in order to avoid: include/hw/sd/sdhci.h:165:1: error: redefinition of 'glib_autoptr_clear_S= DHCIState' include/hw/sd/sdhci.h:165:1: error: redefinition of 'glib_autoptr_cleanup= _SDHCIState' include/hw/sd/sdhci.h:165:1: error: redefinition of 'glib_autoptr_destroy= _SDHCIState' include/hw/sd/sdhci.h:165:1: error: redefinition of 'glib_listautoptr_cle= anup_SDHCIState' include/hw/sd/sdhci.h:165:1: error: redefinition of 'glib_slistautoptr_cl= eanup_SDHCIState' include/hw/sd/sdhci.h:165:1: error: redefinition of 'glib_queueautoptr_cl= eanup_SDHCIState' 165 | OBJECT_DECLARE_TYPE(SDHCIState, SDHCIClass, SYSBUS_SDHCI) | ^ include/hw/sd/sdhci.h:158:1: note: previous definition is here 158 | OBJECT_DECLARE_TYPE(SDHCIState, SDHCIClass, PCI_SDHCI) | ^ Since we can not use SYSBUS_SDHCI_GET_CLASS() on PCI instances, cache the class reference in the object state as 'sc'. As this is not a normal use, introduce SDHCIClass in its own commit. Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- I plan to remove the union later. --- include/hw/sd/sdhci.h | 17 +++++++++++++---- hw/sd/sdhci-pci.c | 1 + hw/sd/sdhci.c | 3 +++ 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/include/hw/sd/sdhci.h b/include/hw/sd/sdhci.h index 2e6e719df7b..c42aeab6848 100644 --- a/include/hw/sd/sdhci.h +++ b/include/hw/sd/sdhci.h @@ -30,6 +30,8 @@ #include "hw/sd/sd.h" #include "qom/object.h" =20 +typedef struct SDHCIClass SDHCIClass; + /* * SD/MMC host controller state * @@ -41,13 +43,12 @@ * card to be protected). */ struct SDHCIState { - /*< private >*/ union { PCIDevice pcidev; SysBusDevice busdev; }; =20 - /*< public >*/ + SDHCIClass *sc; SDBus sdbus; MemoryRegion iomem; AddressSpace sysbus_dma_as; @@ -110,6 +111,13 @@ struct SDHCIState { }; typedef struct SDHCIState SDHCIState; =20 +struct SDHCIClass { + union { + PCIDeviceClass pci_parent_class; + SysBusDeviceClass sbd_parent_class; + }; +}; + /* * NOTE: This definition is taken out of Linux kernel and so the * original bit number is preserved @@ -126,10 +134,11 @@ enum { #define TYPE_PCI_SDHCI "sdhci-pci" DECLARE_INSTANCE_CHECKER(SDHCIState, PCI_SDHCI, TYPE_PCI_SDHCI) +DECLARE_CLASS_CHECKERS(SDHCIClass, PCI_SDHCI, + TYPE_PCI_SDHCI) =20 #define TYPE_SYSBUS_SDHCI "generic-sdhci" -DECLARE_INSTANCE_CHECKER(SDHCIState, SYSBUS_SDHCI, - TYPE_SYSBUS_SDHCI) +OBJECT_DECLARE_TYPE(SDHCIState, SDHCIClass, SYSBUS_SDHCI) =20 #define TYPE_IMX_USDHC "imx-usdhc" =20 diff --git a/hw/sd/sdhci-pci.c b/hw/sd/sdhci-pci.c index 5268c0dee50..fe62582de90 100644 --- a/hw/sd/sdhci-pci.c +++ b/hw/sd/sdhci-pci.c @@ -73,6 +73,7 @@ static const TypeInfo sdhci_pci_types[] =3D { .parent =3D TYPE_PCI_DEVICE, .instance_size =3D sizeof(SDHCIState), .class_init =3D sdhci_pci_class_init, + .class_size =3D sizeof(SDHCIClass), .interfaces =3D (InterfaceInfo[]) { { INTERFACE_CONVENTIONAL_PCI_DEVICE }, { }, diff --git a/hw/sd/sdhci.c b/hw/sd/sdhci.c index d1b1b187874..176bee6b8f5 100644 --- a/hw/sd/sdhci.c +++ b/hw/sd/sdhci.c @@ -1419,6 +1419,8 @@ static void sdhci_init_readonly_registers(SDHCIState = *s, Error **errp) =20 void sdhci_initfn(SDHCIState *s) { + s->sc =3D (SDHCIClass *)object_get_class(OBJECT(s)); /* Cache QOM pare= nt */ + qbus_init(&s->sdbus, sizeof(s->sdbus), TYPE_SDHCI_BUS, DEVICE(s), "sd-= bus"); =20 s->insert_timer =3D timer_new_ns(QEMU_CLOCK_VIRTUAL, @@ -1960,6 +1962,7 @@ static const TypeInfo sdhci_types[] =3D { .instance_size =3D sizeof(SDHCIState), .instance_init =3D sdhci_sysbus_init, .instance_finalize =3D sdhci_sysbus_finalize, + .class_size =3D sizeof(SDHCIClass), .class_init =3D sdhci_sysbus_class_init, }, { --=20 2.47.1