From patchwork Mon Feb 13 10:10:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 653191 Delivered-To: patch@linaro.org Received: by 2002:adf:f90f:0:0:0:0:0 with SMTP id b15csp2325636wrr; Mon, 13 Feb 2023 02:11:39 -0800 (PST) X-Google-Smtp-Source: AK7set9z7KT1YdsS/qUFctdkZeS59YTlPI3lnGwtcbmg+cvZVgoVaDI1vaDX7DfZkD1jm96dfohl X-Received: by 2002:a05:6214:27e1:b0:56e:a9d4:428a with SMTP id jt1-20020a05621427e100b0056ea9d4428amr6561319qvb.1.1676283099719; Mon, 13 Feb 2023 02:11:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676283099; cv=none; d=google.com; s=arc-20160816; b=MFCrgXJtOaiFsH9Ot+II+w/1yiEa+J6qGPEnALcMsVN2Zcti2/bo8HiUkBd4imhqBe v8w6OG25DdixQ/8B9HoJa6nP2o8Is3pBOhtyiDbm4LegHMhOZNqqi+Rkgv71XXjRKQWl aiTOec0U+ykIazTgo9hfPPhhQLyVRMbNXLz/15leX8raJX9s2vOjlAc01yrpc8Divgxj dARjRSG3keQKszXlG0pTfaVkn+wb2lBu5xLFJjkjaE1r8rupdeC7W4Pi7OcJ50r5bk9V gyBCoNJzqRGWECI3FnbQvMpJHt2aFboiv0bBy5tgt1O+3UapDTwptOZ6hexr9WDBc5VW s8aQ== 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=s4DvDo0UQW2wHHaZyEw/ZO2I4PAch3e8r1jmccdccY0=; b=0vf46u3mN6+nvSz/hLw5OV7tU5X4R0AiWnO7DoqP+jKHND7rKOnJvuVdxHHdimmcuu WAveht4b8dOroTj28P8ARcYFjOjjndbKDk4Q7Cd/lxm30+InpY3hRPyMuUtKyE303Rh+ PCfSfeXLrIc/1FEZHw0gnxW7sMotZpBj/9b9RLbLwQBqIqArJv1q4qL0qV9VWSXALwmV q3sL9ztWFafC+fkRZMmW3BagOAbTOV4jx78WPklKAwYE+K5kltBmIGYBP3Is2TUf5DBi jBZSEKSsrmlPq/0Cxd8pBJC6gUzQDJF+4xu4yiuNsMArHBqnnGLdUuYDB6yrh4/p1wAg 1htA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Vetiidoy; 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 d4-20020a0cf0c4000000b0056e93b6d99asi2569585qvl.77.2023.02.13.02.11.39 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 13 Feb 2023 02:11:39 -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=Vetiidoy; 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 1pRVnX-0005Df-TO; Mon, 13 Feb 2023 05:10:59 -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 1pRVnW-0005DW-VZ for qemu-devel@nongnu.org; Mon, 13 Feb 2023 05:10:59 -0500 Received: from mail-wm1-x336.google.com ([2a00:1450:4864:20::336]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pRVnV-0003OT-Bo for qemu-devel@nongnu.org; Mon, 13 Feb 2023 05:10:58 -0500 Received: by mail-wm1-x336.google.com with SMTP id c4-20020a1c3504000000b003d9e2f72093so10868042wma.1 for ; Mon, 13 Feb 2023 02:10:56 -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=s4DvDo0UQW2wHHaZyEw/ZO2I4PAch3e8r1jmccdccY0=; b=Vetiidoy994cgLQd8Tg0t/nVbIAPuAnoxmD5wLDLCSNAIhULpFJTVf6VNm+QCBg4VO yVjhNPBqqqxD2Uy+9/CtFExcLTOoRT1bw6ib3cThuRto4Tvx1cRKjJgpNzO4tWrgH+VC L6IpwRSEVIpdkeMzjOjf6R7fZ2YNp9Kw6mp1TtXIror4vNAiWfFJ1TVhhd8lUPvzAM4+ oDYMYti+tSLLFrV3aKBoIyo8Q44q5PDvT0WrgiVvq/bnIt1jkZ5PYrwbdGKR8/dh8MH3 W3RRw1ctXM095PmUIC2xsOAPSsNtxVMUNsPL997ZTG85fG3HuXPtILNu5ElakMSchJbs zFkQ== 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=s4DvDo0UQW2wHHaZyEw/ZO2I4PAch3e8r1jmccdccY0=; b=T9gr+Dzz1A7D6WCn7vg8ri93yUBPsPX5BsZeA+NDQIuXzZA8c/cluNVO1oY5sqGIRn iI+xkIi20zeoG+m3kPF6ts4WelMOrOqJmBwHfr/Ch0itbQUl90yK3WUua3AvJq47W7rI eDAzR+oMR6o//BSjTUz1pyHyH6lr9DplvnWjT+1Vx5Lbfbp9qOMKBormAL4cr7mv/5Dl Hy0Ey5oyl3ARbirDEWno8B6b3y0vqjHIMbVCoiMSjTVzmi9iJ8MdZARoVG+9hcJOBbXE BBg2Dpt1xQ1WkbfY76wHBJsReOEfz1fpQDKH6G9gLUR1uOEQytJIzXCd5PTEyXpRDgKg PGAg== X-Gm-Message-State: AO0yUKV38DeivAOgNVgrF3SlJ1QpSVn9uYPP5CFC2gcO0YguoLwph8KR ps6K2fqGDowtFexFvVBahkZcYNpuWst/+9vg X-Received: by 2002:a05:600c:329d:b0:3dd:97d6:8f2e with SMTP id t29-20020a05600c329d00b003dd97d68f2emr17865001wmp.17.1676283055385; Mon, 13 Feb 2023 02:10:55 -0800 (PST) Received: from localhost.localdomain ([81.0.6.76]) by smtp.gmail.com with ESMTPSA id j20-20020a05600c191400b003dd8feea827sm18304989wmq.4.2023.02.13.02.10.54 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 13 Feb 2023 02:10:55 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, Eduardo Habkost Cc: Jason Wang , Thomas Huth , Igor Mammedov , Stefan Weil , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH v2 1/7] hw/net/eepro100: Abort if pci_add_capability() ever fail Date: Mon, 13 Feb 2023 11:10:42 +0100 Message-Id: <20230213101048.94519-2-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230213101048.94519-1-philmd@linaro.org> References: <20230213101048.94519-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::336; envelope-from=philmd@linaro.org; helo=mail-wm1-x336.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 If pci_add_capability() ever fail, the EEPRO100 device is broken, which is a bug. No need to report that to the user, abort instead. Signed-off-by: Philippe Mathieu-Daudé --- hw/net/eepro100.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/hw/net/eepro100.c b/hw/net/eepro100.c index dc07984ae9..dce75039ec 100644 --- a/hw/net/eepro100.c +++ b/hw/net/eepro100.c @@ -549,13 +549,8 @@ static void e100_pci_reset(EEPRO100State *s, Error **errp) if (info->power_management) { /* Power Management Capabilities */ int cfg_offset = 0xdc; - int r = pci_add_capability(&s->dev, PCI_CAP_ID_PM, - cfg_offset, PCI_PM_SIZEOF, - errp); - if (r < 0) { - return; - } - + pci_add_capability(&s->dev, PCI_CAP_ID_PM, cfg_offset, PCI_PM_SIZEOF, + &error_abort); pci_set_word(pci_conf + cfg_offset + PCI_PM_PMC, 0x7e21); #if 0 /* TODO: replace dummy code for power management emulation. */ /* TODO: Power Management Control / Status. */ From patchwork Mon Feb 13 10:10:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 653189 Delivered-To: patch@linaro.org Received: by 2002:adf:f90f:0:0:0:0:0 with SMTP id b15csp2325548wrr; Mon, 13 Feb 2023 02:11:27 -0800 (PST) X-Google-Smtp-Source: AK7set/voZuUE436+j/R1r8PypJA6Gx7aStxLnHX2ccUxZ9oYKKM4/g36aeUU0Uh+OnLJIemU6kV X-Received: by 2002:ac8:5bd5:0:b0:3b8:6990:b35b with SMTP id b21-20020ac85bd5000000b003b86990b35bmr44164785qtb.31.1676283087591; Mon, 13 Feb 2023 02:11:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676283087; cv=none; d=google.com; s=arc-20160816; b=jzdEE0PN6NTh9haIlot6PST3Ayicv28Krsmu5wq0A+pGtLgG+4ORjy1S3nNHLMT/Gd Krh2M+TfkTifEffSRZnMACH+EKLwI+0Pz1dFLm86IfGvmWWfrSuZ+HCE1ggT7ZDQUwFB qvjGcdg0E7bwJc7z76oltnHBPMKg9Bwo3z5cjKJmkFD5+cAUssnlUJknSlOiRieIs0hK SJ/Gn3IcEiZv4sJbCDqdBCRCG/+J9wfyXNPdJf6Kb1ZIdgz9UuMEr0d9oW6VXuwnJwzk jdn6dHCrC8pkx/Kc/QNYyFhQqiYqTiAu+HoPOQFbhaynOPSxykeYLd1Q7nZNGWFaqv73 FqoA== 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=e8yrXFW0jUJr8712z9qQtwR4EVFVh/k+PCDGhmBSEkw=; b=olCEYeYpUyAwkvH86GakAV67X66JQseydeVBPTLhzJGfdB1Au+wdBotAOT44V5I971 B2eHX89a8UEsQVqx6PHAr14/GCPgigUfk7P+2O7U8SHqQVvMaSO8zjyAh68p2b8V0Hv4 IgsIeUjtRVh/o7mA4lytnC4Eth14DRGSO7J1qdERymsFk4RVWv75hP4XebbEhEEXoEpI X/EkLN9jhyUD6OB/2vWdX7Iz/RcRcLoN5RXyYEl5gzA4hoKBzs0Z7SZVuhdMSPpWVpRS emXqPugvZjTvo/ZiN7bJgbNja1FwQLWnNTh7X/NCRs/hG95zhZEfB2TGafgZxcOXmmMY pPRA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=QeXmOlWn; 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 v11-20020a05622a014b00b003b316a94122si9504539qtw.6.2023.02.13.02.11.27 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 13 Feb 2023 02:11:27 -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=QeXmOlWn; 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 1pRVnf-0005EY-4V; Mon, 13 Feb 2023 05:11:07 -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 1pRVnd-0005EC-4F for qemu-devel@nongnu.org; Mon, 13 Feb 2023 05:11:05 -0500 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 1pRVna-0003QK-FC for qemu-devel@nongnu.org; Mon, 13 Feb 2023 05:11:04 -0500 Received: by mail-wr1-x42a.google.com with SMTP id a2so11543949wrd.6 for ; Mon, 13 Feb 2023 02:11:02 -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=e8yrXFW0jUJr8712z9qQtwR4EVFVh/k+PCDGhmBSEkw=; b=QeXmOlWnU9ZUpVHBUDR4/rZc6gLh6q5amrTn6UblZxGIhwkmeeIvUVYrB4EFoA2sbl 4UJ1jx2heQeHhZkDsALE9ljG6yqdxiU9E1skjEvTDFGPn/OuSiPMYT6IL/DbfT9KKwU0 QpYfUEKdzQTcDydwofjR2f8dOGvpUqhc9Aib7ZNdQv4h54813+vXrIK6IJ5cxHUBZvTo 1ATLeY+0iWzvEB6/AHQarvAY4PZjaz544zxw97JZXFHi8tL9KDcCxb/CzTIyhaYQl+YY OoCBZZr8HdOiKRHzukAwYlr2DxCkUZlIEwO9QThPVHVNttMsaNb/JJfT2kNi60ltB6Ma DC7g== 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=e8yrXFW0jUJr8712z9qQtwR4EVFVh/k+PCDGhmBSEkw=; b=HK8PAQdpK2XqSLblPvsuLK7zi08nvOY9REIq2CnG+CoppLtV6FkMheaMGVrbCcziVv QD8Nqaoso3vlXuC2LYvLpCLkC7OGbNfIu/tL0VrqR4kPV6Sxuo5IsiHZk/04VKF1uC32 BBOiCslNxusmFl7TRWqHkcNzY1m5Sw1Eytp+/T1x+b1CJJIX2Qgw37/38uO3+qwb6moj D2pYSLN3fZpVwUGN+pvcjcJOmmvR76zY5lKjy8lSauodMR4LrBaPCn0rH0GKeiTmvy2v RgW0kVGEKtCEXIi+dAh1o9SUMoHQsPNBityRj7/98XdHWcHn1F11+p0C6yw1E8/XAKJZ G6EQ== X-Gm-Message-State: AO0yUKUX706qEq6G/wf22TTvcl17F1MQ2Mx9Y9+saYcmcmSEjt7G15eg jFQTHb+5NMmKc4M7wYdJVxWinuBPF9e571OB X-Received: by 2002:a5d:55cf:0:b0:2c5:557b:f837 with SMTP id i15-20020a5d55cf000000b002c5557bf837mr2869021wrw.14.1676283060322; Mon, 13 Feb 2023 02:11:00 -0800 (PST) Received: from localhost.localdomain ([81.0.6.76]) by smtp.gmail.com with ESMTPSA id y1-20020a5d6201000000b002c3ea5ebc73sm10030121wru.101.2023.02.13.02.10.59 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 13 Feb 2023 02:11:00 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, Eduardo Habkost Cc: Jason Wang , Thomas Huth , Igor Mammedov , Stefan Weil , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH v2 2/7] hw/net/eepro100: Introduce TYPE_EEPRO100 QOM abstract parent Date: Mon, 13 Feb 2023 11:10:43 +0100 Message-Id: <20230213101048.94519-3-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230213101048.94519-1-philmd@linaro.org> References: <20230213101048.94519-1-philmd@linaro.org> MIME-Version: 1.0 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=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 Have all the EEPRO100-based devices share a common (abstract) QOM parent. Signed-off-by: Philippe Mathieu-Daudé --- hw/net/eepro100.c | 58 +++++++++++++++++++++++++++++++++-------------- 1 file changed, 41 insertions(+), 17 deletions(-) diff --git a/hw/net/eepro100.c b/hw/net/eepro100.c index dce75039ec..4b5d45576b 100644 --- a/hw/net/eepro100.c +++ b/hw/net/eepro100.c @@ -235,8 +235,20 @@ typedef enum { ru_ready = 4 } ru_state_t; -typedef struct { +#define TYPE_EEPRO100 "eepro100" +OBJECT_DECLARE_TYPE(EEPRO100State, EEPRO100Class, EEPRO100) + +struct EEPRO100Class { + /*< private >*/ + PCIDeviceClass parent_class; + /*< public >*/ +}; + +struct EEPRO100State { + /*< private >*/ PCIDevice dev; + /*< public >*/ + /* Hash register (multicast mask array, multiple individual addresses). */ uint8_t mult[8]; MemoryRegion mmio_bar; @@ -279,7 +291,7 @@ typedef struct { /* Quasi static device properties (no need to save them). */ uint16_t stats_size; bool has_extended_tcb_support; -} EEPRO100State; +}; /* Word indices in EEPROM. */ typedef enum { @@ -2055,43 +2067,55 @@ static Property e100_properties[] = { DEFINE_PROP_END_OF_LIST(), }; -static void eepro100_class_init(ObjectClass *klass, void *data) +static void eepro100_base_class_init(ObjectClass *klass, void *data) { DeviceClass *dc = DEVICE_CLASS(klass); PCIDeviceClass *k = PCI_DEVICE_CLASS(klass); E100PCIDeviceInfo *info; - info = eepro100_get_class_by_name(object_class_get_name(klass)); set_bit(DEVICE_CATEGORY_NETWORK, dc->categories); device_class_set_props(dc, e100_properties); - dc->desc = info->desc; k->vendor_id = PCI_VENDOR_ID_INTEL; k->class_id = PCI_CLASS_NETWORK_ETHERNET; k->romfile = "pxe-eepro100.rom"; k->realize = e100_nic_realize; k->exit = pci_nic_uninit; + + info = eepro100_get_class_by_name(object_class_get_name(klass)); + if (!info) { + /* base class */ + return; + } + dc->desc = info->desc; k->device_id = info->device_id; k->revision = info->revision; k->subsystem_vendor_id = info->subsystem_vendor_id; k->subsystem_id = info->subsystem_id; } +static const TypeInfo eepro100_base_info = { + .name = TYPE_EEPRO100, + .parent = TYPE_PCI_DEVICE, + .abstract = true, + .class_init = eepro100_base_class_init, + .class_size = sizeof(EEPRO100Class), + .instance_size = sizeof(EEPRO100State), + .instance_init = eepro100_instance_init, + .interfaces = (InterfaceInfo[]) { + { INTERFACE_CONVENTIONAL_PCI_DEVICE }, + { }, + }, +}; + static void eepro100_register_types(void) { - size_t i; - for (i = 0; i < ARRAY_SIZE(e100_devices); i++) { - TypeInfo type_info = {}; - E100PCIDeviceInfo *info = &e100_devices[i]; + type_register_static(&eepro100_base_info); - type_info.name = info->name; - type_info.parent = TYPE_PCI_DEVICE; - type_info.class_init = eepro100_class_init; - type_info.instance_size = sizeof(EEPRO100State); - type_info.instance_init = eepro100_instance_init; - type_info.interfaces = (InterfaceInfo[]) { - { INTERFACE_CONVENTIONAL_PCI_DEVICE }, - { }, + for (size_t i = 0; i < ARRAY_SIZE(e100_devices); i++) { + TypeInfo type_info = { + .name = e100_devices[i].name, + .parent = TYPE_EEPRO100, }; type_register(&type_info); From patchwork Mon Feb 13 10:10:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 653190 Delivered-To: patch@linaro.org Received: by 2002:adf:f90f:0:0:0:0:0 with SMTP id b15csp2325628wrr; Mon, 13 Feb 2023 02:11:38 -0800 (PST) X-Google-Smtp-Source: AK7set9XDuT+3QepWTxmLbAPtwdPR9Tn2zWD7A68S4PdTivFet4ilwOeg1vg/jASz0u42gub/lHI X-Received: by 2002:a0c:c78c:0:b0:56e:ae3c:129d with SMTP id k12-20020a0cc78c000000b0056eae3c129dmr5501395qvj.0.1676283098805; Mon, 13 Feb 2023 02:11:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676283098; cv=none; d=google.com; s=arc-20160816; b=PnETtm6l5x3PDYVvN9p9cpnvsrR5b3MXw1Mmd2F6YZcKUC4E4929ISNOPJTtS92pDQ R4W81rEhMjd98NWluDsMsr1a/b1Yliq+1PQpNiQ7Sh7Zr3XO4GsJqIghAqBPkURhwVMV wWZqOwU4+D+JD5pzT/tMMo3KrxCQU4LOF3FiCjvXyGrz9I1m3YkBNMsP8VhwnSw5Z6JZ gQerZQkecZvZROSL8A2sTmNbNS/AWYN1cTGr0efYP7ZmfJp07tX1T6MWtv8yY4XA1WLq noEECjkIOtoizATTokOws8OwVLebfV7fJBKzZox7YFOAAT2T4YwDh+hiWOxPrWb6S08A 3dbQ== 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=Tu5dVA6dI9cI2EiBQY93c/MUAVRJTVadUXPrnS7cBWs=; b=NRHyGsrvJuUazoZaWxd0Sebsg1vjSAK1v+9oqLm4Aqxuv86zpB5rT8ztpI8Vz+rey5 K3tP++XXa0PEXiNhI8VoQ0i9Gu3FLYfXb2f30H1O2uCuxpFIHSA50kxLxn0/TUTXykq3 qzG+KfjDMdrufNXzxP5o2qoNY5uRD937AXgNyyjcU3J8fue3rqBwHJ3X6yj+PHBLlKjY GDiU70ApKPGfmmxQNKhIqD/wId4cQr1F1iXa2lyz4X+ejW4Awd1QvMSnYp3uoh0qrf8r t3qthxGJiCZ7zqRpjUO8nfL73h+3VO/14zTrWAIgWLEjoEDamHbSarPjD4ue6gEPZvN9 wLIA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=kd7JFUEr; 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 m10-20020a0cac4a000000b005353068a8acsi8532977qvb.387.2023.02.13.02.11.38 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 13 Feb 2023 02:11:38 -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=kd7JFUEr; 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 1pRVnk-0005VK-RN; Mon, 13 Feb 2023 05:11:12 -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 1pRVnh-0005MH-85 for qemu-devel@nongnu.org; Mon, 13 Feb 2023 05:11:09 -0500 Received: from mail-wm1-x334.google.com ([2a00:1450:4864:20::334]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pRVne-0003SW-Te for qemu-devel@nongnu.org; Mon, 13 Feb 2023 05:11:08 -0500 Received: by mail-wm1-x334.google.com with SMTP id r18so8294402wmq.5 for ; Mon, 13 Feb 2023 02:11:06 -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=Tu5dVA6dI9cI2EiBQY93c/MUAVRJTVadUXPrnS7cBWs=; b=kd7JFUErabWj3jbv4l9FoJPEb7TNJf1BnTvreb61q8oEoF2iFKRm2sJfo2HgMhEQbB ig3HCa5JseNl759osJlGKNIRi5TgTJI87o30rpLdOaalDyOg5yRB+spAePMaAytuFyKB jlhcqFu8uoU6BQ1tdIo/vn0IyknvWdRZy4rtJHFG5cVPrHTQYjVq7tAxLvbkrjwmuDR5 sd8y+Moj3d/2HJiDBYqI7BgBhpWDlMn+ygbNxKhPbDkpbdWMEsL1hQ79e8UABvQQtoXV V5Zwu4lue42hUAUGq0/S7azR11XaUMMk/xjUYrHIyoxxCcrdk5qSwbjEn5cok5tt2wKx gKOA== 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=Tu5dVA6dI9cI2EiBQY93c/MUAVRJTVadUXPrnS7cBWs=; b=aHZYToE8J2oD+BuBUbHedjDTJ5sfjxtM4AmjLUwSAoC4fAoCznysLii59GGmKdE1A3 vvomFJ1iYTXE/x3vVfesLdzq2XWI2HKzySkT+H3/ARxuk4MWauC3txzxnwoXyR3x8h2i YQ8N0v3/Y1cBNQP8djwWZ8xFodwpNNgKefd/HHpxPiQh+dLyH1VY3xWlW8otqRRQ2NqY EaSkZ5JZxUvHHAWva4he2dz/eKyYHIUqDF2bazXZ+R6u856egJRBu3zT5JTbVMxGmsg2 9DuQTyPzny7/iDCFnYt+a0aoJ9+FraY8L9Dj/kUOTHgSOccamJjGUaEnD6eveptKjna3 MyAQ== X-Gm-Message-State: AO0yUKWF3in5tNtkXgEvBGfe5J7MkRgNwHTnZ6fa06eQu7vq8fqgjbH/ ofkiIYFYTMBHrHOlvatttNrOA2UxC5Ef/bgU X-Received: by 2002:a05:600c:331b:b0:3dc:4356:533c with SMTP id q27-20020a05600c331b00b003dc4356533cmr18409573wmp.5.1676283065206; Mon, 13 Feb 2023 02:11:05 -0800 (PST) Received: from localhost.localdomain ([81.0.6.76]) by smtp.gmail.com with ESMTPSA id iv12-20020a05600c548c00b003dc521f336esm14628652wmb.14.2023.02.13.02.11.04 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 13 Feb 2023 02:11:04 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, Eduardo Habkost Cc: Jason Wang , Thomas Huth , Igor Mammedov , Stefan Weil , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH v2 3/7] hw/net/eepro100: Convert reset handler to DeviceReset Date: Mon, 13 Feb 2023 11:10:44 +0100 Message-Id: <20230213101048.94519-4-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230213101048.94519-1-philmd@linaro.org> References: <20230213101048.94519-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::334; envelope-from=philmd@linaro.org; helo=mail-wm1-x334.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 Signed-off-by: Philippe Mathieu-Daudé --- hw/net/eepro100.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/hw/net/eepro100.c b/hw/net/eepro100.c index 4b5d45576b..722fb55e4a 100644 --- a/hw/net/eepro100.c +++ b/hw/net/eepro100.c @@ -486,8 +486,9 @@ static void eepro100_fcp_interrupt(EEPRO100State * s) } #endif -static void e100_pci_reset(EEPRO100State *s, Error **errp) +static void e100_pci_reset(DeviceState *dev) { + EEPRO100State *s = EEPRO100(dev); E100PCIDeviceInfo *info = eepro100_get_class(s); uint32_t device = s->device; uint8_t *pci_conf = s->dev.config; @@ -1847,18 +1848,11 @@ static void e100_nic_realize(PCIDevice *pci_dev, Error **errp) { EEPRO100State *s = DO_UPCAST(EEPRO100State, dev, pci_dev); E100PCIDeviceInfo *info = eepro100_get_class(s); - Error *local_err = NULL; TRACE(OTHER, logout("\n")); s->device = info->device; - e100_pci_reset(s, &local_err); - if (local_err) { - error_propagate(errp, local_err); - return; - } - /* Add 64 * 2 EEPROM. i82557 and i82558 support a 64 word EEPROM, * i82559 and later support 64 or 256 word EEPROM. */ s->eeprom = eeprom93xx_new(&pci_dev->qdev, EEPROM_SIZE); @@ -2076,6 +2070,7 @@ static void eepro100_base_class_init(ObjectClass *klass, void *data) set_bit(DEVICE_CATEGORY_NETWORK, dc->categories); device_class_set_props(dc, e100_properties); + dc->reset = e100_pci_reset; k->vendor_id = PCI_VENDOR_ID_INTEL; k->class_id = PCI_CLASS_NETWORK_ETHERNET; k->romfile = "pxe-eepro100.rom"; From patchwork Mon Feb 13 10:10:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 653194 Delivered-To: patch@linaro.org Received: by 2002:adf:f90f:0:0:0:0:0 with SMTP id b15csp2325872wrr; Mon, 13 Feb 2023 02:12:13 -0800 (PST) X-Google-Smtp-Source: AK7set9WGFxHMakIDP/Jh6PypSFZ9SN/ScASxsM9Re8sioC3/rKOuJy3JIzVGHzu0kMzEfiwnvkI X-Received: by 2002:ac8:5856:0:b0:3b8:5199:f84a with SMTP id h22-20020ac85856000000b003b85199f84amr41921608qth.3.1676283133694; Mon, 13 Feb 2023 02:12:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676283133; cv=none; d=google.com; s=arc-20160816; b=h7DDo0YtUcVGRJ2eBQ0Hub3+CpA6rpTZB7/+0D+JQTJQ9zUZNV5ZW2FOCu7YxdLtJC 1YjuSCcXkkze1nkswQWzUvI73e7PV9mlfqOEM//K1iyZEuvdaquwosZIzxoN69XsPohP tLKcGea81245dArWODVYahFN7/ihZAkK16CF6VxeOUrVjDEpAYJB5NZOimW3ShHMyYef 6j6adQYNNAsSs5n0PjW4U/esFyb1/h0LW+3UNaFlfX/wWTcfHWmN8UULcukmFvXFr8O1 I09aYHoveWMx+Oi+fn8lD5uXA9ZL/HcjfcwR9oeKID4r67k+uA9Kms1HkpCE+7TaT/64 8X3g== 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=BZL+Bp8uavCHtbQrBbmxFnoeXirx45v+Dj9xYJzTDeg=; b=jQPkFHxuHRoxNqPl6Y8Pr9Rlmy84PoCSCuYTyYFU9o2J+CpFhD+Iio1pCYrxJDVuuS zxZoB97elKwDPJurEUx+PnVSR/uj2x9zdneuBv5c7chHDAashLQVZxUPnIMpw4TzuAzz XD83X7iQ2bA/VrEcnNAvign5ddyJPcY134Vpg08RE1v4tpBDMGutCntxQQJQiIr8bARs 6N2xvHvqZvKaMZ/uFkRvOAh/t5pLMrijz7JlBTSSDKHCE1QAvQ61Gr0Bssv2qMMAhqod odPc4975Bw0OkyD9x025UJQScoV3QeCEvF+WrNBzwmK9c3ZMtn2yiFgK5d0ANSkcl/hu 2Y4w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=mexQoVgw; 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 x20-20020a05622a001400b003ba35fdb9b4si9317560qtw.280.2023.02.13.02.12.13 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 13 Feb 2023 02:12:13 -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=mexQoVgw; 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 1pRVnp-0005cW-K9; Mon, 13 Feb 2023 05:11:17 -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 1pRVnn-0005af-5g for qemu-devel@nongnu.org; Mon, 13 Feb 2023 05:11:16 -0500 Received: from mail-wm1-x32e.google.com ([2a00:1450:4864:20::32e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pRVnk-0003Uc-Ru for qemu-devel@nongnu.org; Mon, 13 Feb 2023 05:11:14 -0500 Received: by mail-wm1-x32e.google.com with SMTP id j29-20020a05600c1c1d00b003dc52fed235so8566769wms.1 for ; Mon, 13 Feb 2023 02:11:11 -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=BZL+Bp8uavCHtbQrBbmxFnoeXirx45v+Dj9xYJzTDeg=; b=mexQoVgwoSQuueyuYWZ4fjYZWsc91Qg1sjG5uSvGkq3+KUR12HiwOvKduID2Oe8lA7 okDW24Ysa2a06DouOdKw23Xmwi6LG8/LeYZKnjb/P0dkQjIQwyMCRt8UD3A8I6OCV9NB XUgkML/Qra3KpeuHfxHNxFW5MVI2s99hHVPWWDofyAVkxZuc5t28HykSPEIkSCeBiROQ 6ni6sW3D/amcNW49Fdzo8T1jiX1EdgECfXPbrNRp85jDtR42qE6p5Clm+9jWY9nUUsBq vGCMZOPRHe1Jr9pq3GiyHE9I63+zu3bezCeBTVgK+0N0bzTO19vYzBGq0jdQNgUyWRCM 5QQw== 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=BZL+Bp8uavCHtbQrBbmxFnoeXirx45v+Dj9xYJzTDeg=; b=KII/UyX9/ceI6mOCsEzjVrtDxLnYMsjMTdRsUPgCyw9SEwRWE0Gx/+ytydDvkn1Nuu eSx+r47Xt71d/N1iYQty95cvweU24qpcFTWp52MJVQuYpnXK0/Axe8dbsr9fQP4Puh4U w4SHRhsCMNBMgE05xtm49cdyylcoX75tvTFkPN45l/5T37JsgNjFvDS7MkfnWygWq+3K 6lWeELSGE0yZhjoTsDC+EU75jOqU6WBHRkznrY3zRRCsZaLM8mevZGpzbMjSyWzTjiFW TGdu51jeWeMCx1EvGHIULu7f65yqxpI514juv6h7aEE0kPUXwDJBAJ+iFEdx7EfKFoN/ gsTw== X-Gm-Message-State: AO0yUKWNnERQzxRUNNxYtXa/nxN2SFVb/iuFA3ZChSB2z9Z+372shQls pV5w5BFY40bykvWrkeCHfr4Yuo3FNsOYluuJ X-Received: by 2002:a05:600c:43d3:b0:3da:1357:4ca2 with SMTP id f19-20020a05600c43d300b003da13574ca2mr20544534wmn.11.1676283070236; Mon, 13 Feb 2023 02:11:10 -0800 (PST) Received: from localhost.localdomain ([81.0.6.76]) by smtp.gmail.com with ESMTPSA id m18-20020a5d6252000000b002c3dc4131f5sm10248084wrv.18.2023.02.13.02.11.09 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 13 Feb 2023 02:11:09 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, Eduardo Habkost Cc: Jason Wang , Thomas Huth , Igor Mammedov , Stefan Weil , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH v2 4/7] hw/net/eepro100: Pass E100PCIDeviceInfo as class init data Date: Mon, 13 Feb 2023 11:10:45 +0100 Message-Id: <20230213101048.94519-5-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230213101048.94519-1-philmd@linaro.org> References: <20230213101048.94519-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32e; envelope-from=philmd@linaro.org; helo=mail-wm1-x32e.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 QOM already provides the TypeInfo::class_data to set class-specific data. Use it instead of reinventing the wheel with eepro100_get_class_by_name(). This finishes the QDev conversion started 12 years ago in commit 40021f0888 ("pci: convert to QEMU Object Model"). Signed-off-by: Philippe Mathieu-Daudé --- hw/net/eepro100.c | 63 +++++++++++++++-------------------------------- 1 file changed, 20 insertions(+), 43 deletions(-) diff --git a/hw/net/eepro100.c b/hw/net/eepro100.c index 722fb55e4a..ab20558a18 100644 --- a/hw/net/eepro100.c +++ b/hw/net/eepro100.c @@ -242,6 +242,8 @@ struct EEPRO100Class { /*< private >*/ PCIDeviceClass parent_class; /*< public >*/ + + const E100PCIDeviceInfo *info; }; struct EEPRO100State { @@ -338,8 +340,6 @@ static const uint16_t eepro100_mdi_mask[] = { 0xffff, 0xffff, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, }; -static E100PCIDeviceInfo *eepro100_get_class(EEPRO100State *s); - /* Read a 16 bit control/status (CSR) register. */ static uint16_t e100_read_reg2(EEPRO100State *s, E100RegisterOffset addr) { @@ -489,8 +489,9 @@ static void eepro100_fcp_interrupt(EEPRO100State * s) static void e100_pci_reset(DeviceState *dev) { EEPRO100State *s = EEPRO100(dev); - E100PCIDeviceInfo *info = eepro100_get_class(s); - uint32_t device = s->device; + EEPRO100Class *ek = EEPRO100_GET_CLASS(s); + const E100PCIDeviceInfo *info = ek->info; + uint32_t device = info->device; uint8_t *pci_conf = s->dev.config; TRACE(OTHER, logout("%p\n", s)); @@ -1847,11 +1848,11 @@ static NetClientInfo net_eepro100_info = { static void e100_nic_realize(PCIDevice *pci_dev, Error **errp) { EEPRO100State *s = DO_UPCAST(EEPRO100State, dev, pci_dev); - E100PCIDeviceInfo *info = eepro100_get_class(s); + EEPRO100Class *ek = EEPRO100_GET_CLASS(s); TRACE(OTHER, logout("\n")); - s->device = info->device; + s->device = ek->info->device; /* Add 64 * 2 EEPROM. i82557 and i82558 support a 64 word EEPROM, * i82559 and later support 64 or 256 word EEPROM. */ @@ -2028,32 +2029,19 @@ static E100PCIDeviceInfo e100_devices[] = { } }; -static E100PCIDeviceInfo *eepro100_get_class_by_name(const char *typename) +static void eepro100_class_init(ObjectClass *klass, void *data) { - E100PCIDeviceInfo *info = NULL; - int i; + DeviceClass *dc = DEVICE_CLASS(klass); + PCIDeviceClass *k = PCI_DEVICE_CLASS(klass); + EEPRO100Class *ek = EEPRO100_CLASS(klass); + const E100PCIDeviceInfo *info = data; - /* This is admittedly awkward but also temporary. QOM allows for - * parameterized typing and for subclassing both of which would suitable - * handle what's going on here. But class_data is already being used as - * a stop-gap hack to allow incremental qdev conversion so we cannot use it - * right now. Once we merge the final QOM series, we can come back here and - * do this in a much more elegant fashion. - */ - for (i = 0; i < ARRAY_SIZE(e100_devices); i++) { - if (strcmp(e100_devices[i].name, typename) == 0) { - info = &e100_devices[i]; - break; - } - } - assert(info != NULL); - - return info; -} - -static E100PCIDeviceInfo *eepro100_get_class(EEPRO100State *s) -{ - return eepro100_get_class_by_name(object_get_typename(OBJECT(s))); + dc->desc = info->desc; + k->device_id = info->device_id; + k->revision = info->revision; + k->subsystem_vendor_id = info->subsystem_vendor_id; + k->subsystem_id = info->subsystem_id; + ek->info = info; } static Property e100_properties[] = { @@ -2065,8 +2053,6 @@ static void eepro100_base_class_init(ObjectClass *klass, void *data) { DeviceClass *dc = DEVICE_CLASS(klass); PCIDeviceClass *k = PCI_DEVICE_CLASS(klass); - E100PCIDeviceInfo *info; - set_bit(DEVICE_CATEGORY_NETWORK, dc->categories); device_class_set_props(dc, e100_properties); @@ -2076,17 +2062,6 @@ static void eepro100_base_class_init(ObjectClass *klass, void *data) k->romfile = "pxe-eepro100.rom"; k->realize = e100_nic_realize; k->exit = pci_nic_uninit; - - info = eepro100_get_class_by_name(object_class_get_name(klass)); - if (!info) { - /* base class */ - return; - } - dc->desc = info->desc; - k->device_id = info->device_id; - k->revision = info->revision; - k->subsystem_vendor_id = info->subsystem_vendor_id; - k->subsystem_id = info->subsystem_id; } static const TypeInfo eepro100_base_info = { @@ -2111,6 +2086,8 @@ static void eepro100_register_types(void) TypeInfo type_info = { .name = e100_devices[i].name, .parent = TYPE_EEPRO100, + .class_init = eepro100_class_init, + .class_data = (void *)&e100_devices[i], }; type_register(&type_info); From patchwork Mon Feb 13 10:10:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 653195 Delivered-To: patch@linaro.org Received: by 2002:adf:f90f:0:0:0:0:0 with SMTP id b15csp2326077wrr; Mon, 13 Feb 2023 02:12:41 -0800 (PST) X-Google-Smtp-Source: AK7set9RHNa82UygmLdDLU2roCVQ7HMOKYs+aFW7HZIJHXaYsQNSoRnrZLq8/EWJQpZKHUzY29zQ X-Received: by 2002:a05:6214:c8a:b0:537:632d:11d1 with SMTP id r10-20020a0562140c8a00b00537632d11d1mr26695694qvr.25.1676283161729; Mon, 13 Feb 2023 02:12:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676283161; cv=none; d=google.com; s=arc-20160816; b=bqZV2bOGzqgJ7rLXO4ZRtAgRrqepTO7fv9wYIK1Ku4gjrM/rwKIQDimQPsZoAp3jOx TQ2ebRD76Vj3DpD+lJlTa4rZl/tyS+UAIWmCy/b1v9RHfpobWO69asKcXf4GAFo2EPwi YRjiAS6uIynG9TzH8SVOyVT7Hc8D+UdcU11jtD/PdMyI3f7xG7xMEq6AxoiB3aPy5h4E i7224onz/mH2hpp1CoUYafwBbAEg62yNjN4JWDmxtPFXBhYb+MgOsOxCa3eB6f3m+N5w QLSDQDX8GSoVTq2EfIPFoXjlGmHFfcp7o8iJ9GcrSYfvV58aeEgaWv9FhnGHkB3w8gpj HmHw== 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=OEDmvV7dprZjnBDzVsTadk4Q695IfZynhRqx282ioKQ=; b=PxNcpFLcpsJMTcf9rz++kaSfLJi7xx32Hr0anhJofk4Vj9TJZN6sQmhZAwB6kb1h4Z HHpeNJKNgPkjpOhEl8iN+5A5q8nhDCt4LYJptR7TM4PXq0a9SLPmSt5iAXUl9qZ7Z0uI V7+Gff74EPL7Kp9aMvaRdp0vEMlfj2uOC9PZYt6Z3K7CIXL/ckguhiiIwXloRNbHMoNA lg/xgoQMlVsK4zN/a/i/sZHhuqouE6UGUJhpLCw3KqjwpgCkyW5XlzDTRpATFegUBI8d HlTBRMuMyAlQdzktSi/XqNvjrVvo449Ap6V+XZz/GeiEVP2TAEYD65Euibqn7lOILlIG b+bw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=bA1SEdkA; 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 b3-20020a0cf043000000b0056ea2d1633csi3736324qvl.513.2023.02.13.02.12.41 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 13 Feb 2023 02:12:41 -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=bA1SEdkA; 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 1pRVnx-0005er-DJ; Mon, 13 Feb 2023 05:11:25 -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 1pRVnu-0005dP-K8 for qemu-devel@nongnu.org; Mon, 13 Feb 2023 05:11:22 -0500 Received: from mail-wm1-x334.google.com ([2a00:1450:4864:20::334]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pRVnq-0003W3-IL for qemu-devel@nongnu.org; Mon, 13 Feb 2023 05:11:20 -0500 Received: by mail-wm1-x334.google.com with SMTP id n33so2296609wms.0 for ; Mon, 13 Feb 2023 02:11:16 -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=OEDmvV7dprZjnBDzVsTadk4Q695IfZynhRqx282ioKQ=; b=bA1SEdkAHr2a/FzF5KBg9EU55JU492UcPPUxDTOWBjnDa/fwmXQPy7eLNmOrDx93Tl XHHZnv3dUNkTgjEDXU2wfI/KzOif6Bb4A1BQgKI1kfAYQqgDfJLbLn2tGeorG192W4sE aUGUN/RAfDWfgGfAIqScoE8nNpq/HkVLwCE7exqnIhX3ZlgPPOJCvQAYkCZWKsApWGWk s51xxOSIxEWQyWN2VCf6Z0y7HUHgh2v5i3l2V1EPK7Sm5RbKGQuDyAX3OBUE59DDreND dctDupndlXzxcGPq9nEOETpU8fbhRWetNxxMbqvhEwMCVmxeXqOVgO0tV43USRF2xrY3 xS1g== 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=OEDmvV7dprZjnBDzVsTadk4Q695IfZynhRqx282ioKQ=; b=vqat6jxHKf2JdTnpNdaN3Rkc7DC/dEWR3Gw0dwO3oDpzU7DXky6UTC8tqebYPaOAZb 6cRZafAEEmdi4CPUfXF1GehGnjPpkBYeCx9xmPCDHbxULKAgly98T4cIOv+ZKJXCLcFS 7NeqlTPOnpl8qSTlLHYqOhHeLeRqfjKHaah3O0CCUnmf20uY0g4GQrB95htv0TF2c0tU YW7qWB5Iew4JZh4za28M53INW+ASAU9aDG2B3H2FvYq5IUyLLaJtLWVlFQM5NVlzt4CS D9MvFJBvoERBuMtMyrs8ME0AtrK5nVnBHZ+yMXQTxnhoH1cLGzBTPe/FocUcQVz325rR Gnow== X-Gm-Message-State: AO0yUKVodChu0qHLPWldYpDjvMQXYcskkuS12UGbPQHTjegF0ciMRt1b 1gphp7O72CrGpjAJaaFp3YRLH+WsILa5mxAr X-Received: by 2002:a05:600c:181d:b0:3e0:c0d:75d8 with SMTP id n29-20020a05600c181d00b003e00c0d75d8mr20716066wmp.23.1676283075044; Mon, 13 Feb 2023 02:11:15 -0800 (PST) Received: from localhost.localdomain ([81.0.6.76]) by smtp.gmail.com with ESMTPSA id p14-20020a1c544e000000b003db06493ee7sm17381648wmi.47.2023.02.13.02.11.14 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 13 Feb 2023 02:11:14 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, Eduardo Habkost Cc: Jason Wang , Thomas Huth , Igor Mammedov , Stefan Weil , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH v2 5/7] hw/net/eepro100: Remove instance EEPRO100State::has_extended_tcb_support Date: Mon, 13 Feb 2023 11:10:46 +0100 Message-Id: <20230213101048.94519-6-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230213101048.94519-1-philmd@linaro.org> References: <20230213101048.94519-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::334; envelope-from=philmd@linaro.org; helo=mail-wm1-x334.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 'has_extended_tcb_support' is accessed read-only and is present in the class definition. No need to duplicate it in the instance state. Directly access the class field. Signed-off-by: Philippe Mathieu-Daudé --- hw/net/eepro100.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/hw/net/eepro100.c b/hw/net/eepro100.c index ab20558a18..d7757907c3 100644 --- a/hw/net/eepro100.c +++ b/hw/net/eepro100.c @@ -292,7 +292,6 @@ struct EEPRO100State { /* Quasi static device properties (no need to save them). */ uint16_t stats_size; - bool has_extended_tcb_support; }; /* Word indices in EEPROM. */ @@ -511,7 +510,6 @@ static void e100_pci_reset(DeviceState *dev) pci_set_byte(pci_conf + PCI_MAX_LAT, 0x18); s->stats_size = info->stats_size; - s->has_extended_tcb_support = info->has_extended_tcb_support; switch (device) { case i82550: @@ -746,6 +744,8 @@ static void read_cb(EEPRO100State *s) static void tx_command(EEPRO100State *s) { + EEPRO100Class *ek = EEPRO100_GET_CLASS(s); + const E100PCIDeviceInfo *info = ek->info; const MemTxAttrs attrs = MEMTXATTRS_UNSPECIFIED; uint32_t tbd_array = s->tx.tbd_array_addr; uint16_t tcb_bytes = s->tx.tcb_bytes & 0x3fff; @@ -782,7 +782,7 @@ static void tx_command(EEPRO100State *s) uint16_t tx_buffer_size; uint16_t tx_buffer_el; - if (s->has_extended_tcb_support && !(s->configuration[6] & BIT(4))) { + if (info->has_extended_tcb_support && !(s->configuration[6] & BIT(4))) { /* Extended Flexible TCB. */ for (; tbd_count < 2; tbd_count++) { ldl_le_pci_dma(&s->dev, tbd_address, &tx_buffer_address, attrs); From patchwork Mon Feb 13 10:10:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 653192 Delivered-To: patch@linaro.org Received: by 2002:adf:f90f:0:0:0:0:0 with SMTP id b15csp2325691wrr; Mon, 13 Feb 2023 02:11:45 -0800 (PST) X-Google-Smtp-Source: AK7set+/p8H3TcTexgclyiBczlcYpaL1j3w4MDrj0PFm5wt6UpnDD3/Z+y6qcwbW6gBBykQabpvW X-Received: by 2002:ac8:7e86:0:b0:3b8:6d3b:b083 with SMTP id w6-20020ac87e86000000b003b86d3bb083mr40173968qtj.10.1676283105355; Mon, 13 Feb 2023 02:11:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676283105; cv=none; d=google.com; s=arc-20160816; b=TITcabc9QgpAlJjGA6Xhmpqnzw0Ka3Ni/UiC/MaqJ3sPw+dv9pAV5gD0Q13+jBUQDO wMKfGcE3GBVC8J8sQWjkIUtQ6/Q5ivB+RqbWGSxmkwTAOtIMVvDtCLwaFLDiPL1NWnNb /8gc92t3ilGsPjmYgSjrcyPPOYbYtkxJTIn1JY9EZN3eFrdqhDckSvpflDXysoKMhSjk vREjsv4cT/S/2y//5HAwYDdXjaG/9TEL6VC0jrgaGM9IaHrvoZiEmWhmvyAS28CYH06J QOm8rEFsyw0lLw6drqOMKeeKW5AyspLMomNCCwexb0XxOsm1QaIcTBpKTjKy6jGQAe+1 f5EA== 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=xLHQgcdLxt1p5En4sn+xmWI1OSi7FkAFpHuHk9yrVdo=; b=Vb2mmpE7/8iH5qUFbcKKSEIsYxM7L6a4Aqtg/T7Lcb5e8adX0MyeWc0vmEdLw+NGTi gDMC+GKKAE24tBYbCPsC8OOrH10BSrPH5eL1/q5/VWwLTvzKnAlwtBdaYDl4ncYeWWY8 wE/S0NwnTjOOEB33NEwUJFLKmBCwq6xS9+wHKga3Zgx8GmWwbei6IFqJy47V78XaPoWr FFgxyeeIAwDMY9urHOnjIUW6XSTV4zE9YgWHNmS4i5UiiH/Y9CiXCOrdNyI0oQDI5DNJ vxao1GeSjJf74riGbik38jM8O/RGlBlESUeBk8+UOD2VE20SqGrFT15rSt3l/w3q6eD8 2ZDg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=EIklTWus; 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 c7-20020a05620a268700b0070922ae66a8si9360018qkp.309.2023.02.13.02.11.45 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 13 Feb 2023 02:11:45 -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=EIklTWus; 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 1pRVny-0005f9-8D; Mon, 13 Feb 2023 05:11:26 -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 1pRVnw-0005eF-Nd for qemu-devel@nongnu.org; Mon, 13 Feb 2023 05:11:24 -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 1pRVnt-0003X0-NT for qemu-devel@nongnu.org; Mon, 13 Feb 2023 05:11:23 -0500 Received: by mail-wm1-x32f.google.com with SMTP id m16-20020a05600c3b1000b003dc4050c94aso8558114wms.4 for ; Mon, 13 Feb 2023 02:11:21 -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=xLHQgcdLxt1p5En4sn+xmWI1OSi7FkAFpHuHk9yrVdo=; b=EIklTWusualkftsgWJosmMrIsT3ku5RnbaviYb4OLb+inVC+SQWZ1C+e7EIuVDI3a1 C1Cg1Q8ah6h2ENlehqbqnXRvqeYSl0dCU8H6cZA6bxh+gM749DoriyJBkJRzt/1hkrDb HDR/2AZN/CLbtseL87s9V3mq0hCpu7vjb775kd+YpwO8cVgYqi8FW9urN2O37e3XeSFP UoyDa8DfGAhVy1W7kUpJOvQ7Db4Zy2VEmQGrlHAz+RR6lrRLb/Co7d7zrgM4dqyg0Nxn lVCW3xbWuNuEkTXOkUDF6nTRwL5NcNYkQI3EZ2dnc2nGpdihQs1sBeaOa7G7UxgJ+GHf nk7A== 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=xLHQgcdLxt1p5En4sn+xmWI1OSi7FkAFpHuHk9yrVdo=; b=IbCXrteXG7eoi2JVNOxK/9eOofkZRRUYkmW/0aAx9PzN7SCFc9+/Jucf3wlvNHwS99 BTCsw3l6MEXaW4V/rR7EVuFxvh4yYVynw1gsyZLv86w0q/XbydOLIM36uZT5kcH/0fzn F3q9fgBU+22gLhwUH1vXJWbiyE9Dm+/9CuDS1/srbpIqCpIFzuIK+qsLCIFQYT4TAjl9 Z6T6PWku1MiGxOYhPGLlhFOhHvzrfkDrnIchx67Q8clygjbxACq1q8kFYKHbbWMQZUwN oKufwRx+AAW8ZUOQvsMuXXkFhz5OI2YxJqIAd+HMtgA7UtVmEducQnUS2BLNMwdUg2mb a+tg== X-Gm-Message-State: AO0yUKXaa3zt9Co3AdwXQQBMq6z9CTfjVDBf4dCcx7syNPcnBMKdz0TS WrV6a4ZKyGPljjI5cnBrQJyDBXtV/QMhgwaa X-Received: by 2002:a05:600c:3416:b0:3df:85d2:c768 with SMTP id y22-20020a05600c341600b003df85d2c768mr18625647wmp.26.1676283079889; Mon, 13 Feb 2023 02:11:19 -0800 (PST) Received: from localhost.localdomain ([81.0.6.76]) by smtp.gmail.com with ESMTPSA id o19-20020a05600c4fd300b003dc59d6f2f8sm13851110wmq.17.2023.02.13.02.11.19 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 13 Feb 2023 02:11:19 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, Eduardo Habkost Cc: Jason Wang , Thomas Huth , Igor Mammedov , Stefan Weil , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH v2 6/7] hw/net/eepro100: Remove instance's EEPRO100State::device Date: Mon, 13 Feb 2023 11:10:47 +0100 Message-Id: <20230213101048.94519-7-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230213101048.94519-1-philmd@linaro.org> References: <20230213101048.94519-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32f; envelope-from=philmd@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 'device' is accessed read-only and is present in the class definition. No need to duplicate it in the instance state. Directly access the class field. Signed-off-by: Philippe Mathieu-Daudé --- hw/net/eepro100.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/hw/net/eepro100.c b/hw/net/eepro100.c index d7757907c3..bce377688e 100644 --- a/hw/net/eepro100.c +++ b/hw/net/eepro100.c @@ -263,7 +263,6 @@ struct EEPRO100State { /* region must not be saved by nic_save. */ uint16_t mdimem[32]; eeprom_t *eeprom; - uint32_t device; /* device variant */ /* (cu_base + cu_offset) address the next command block in the command block list. */ uint32_t cu_base; /* CU base address */ uint32_t cu_offset; /* CU address offset */ @@ -591,6 +590,9 @@ static void e100_pci_reset(DeviceState *dev) static void nic_selective_reset(EEPRO100State * s) { + EEPRO100Class *ek = EEPRO100_GET_CLASS(s); + const E100PCIDeviceInfo *info = ek->info; + size_t i; uint16_t *eeprom_contents = eeprom93xx_data(s->eeprom); #if 0 @@ -598,8 +600,9 @@ static void nic_selective_reset(EEPRO100State * s) #endif memcpy(eeprom_contents, s->conf.macaddr.a, 6); eeprom_contents[EEPROM_ID] = EEPROM_ID_VALID; - if (s->device == i82557B || s->device == i82557C) + if (info->device == i82557B || info->device == i82557C) { eeprom_contents[5] = 0x0100; + } eeprom_contents[EEPROM_PHY_ID] = 1; uint16_t sum = 0; for (i = 0; i < EEPROM_SIZE - 1; i++) { @@ -1794,7 +1797,7 @@ static const VMStateDescription vmstate_eepro100 = { VMSTATE_UNUSED(19*4), VMSTATE_UINT16_ARRAY(mdimem, EEPRO100State, 32), /* The eeprom should be saved and restored by its own routines. */ - VMSTATE_UINT32(device, EEPRO100State), + VMSTATE_UNUSED(sizeof(uint32_t)), /* was device variant */ /* TODO check device. */ VMSTATE_UINT32(cu_base, EEPRO100State), VMSTATE_UINT32(cu_offset, EEPRO100State), @@ -1848,12 +1851,9 @@ static NetClientInfo net_eepro100_info = { static void e100_nic_realize(PCIDevice *pci_dev, Error **errp) { EEPRO100State *s = DO_UPCAST(EEPRO100State, dev, pci_dev); - EEPRO100Class *ek = EEPRO100_GET_CLASS(s); TRACE(OTHER, logout("\n")); - s->device = ek->info->device; - /* Add 64 * 2 EEPROM. i82557 and i82558 support a 64 word EEPROM, * i82559 and later support 64 or 256 word EEPROM. */ s->eeprom = eeprom93xx_new(&pci_dev->qdev, EEPROM_SIZE); From patchwork Mon Feb 13 10:10:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 653193 Delivered-To: patch@linaro.org Received: by 2002:adf:f90f:0:0:0:0:0 with SMTP id b15csp2325779wrr; Mon, 13 Feb 2023 02:11:58 -0800 (PST) X-Google-Smtp-Source: AK7set9MLGvNXLZflFHqzmT5Xa3g9fkFWEPMxaX0X/cjW0gL4oSiPV/BWjlmwCB8kdp10gbtPl7y X-Received: by 2002:ac8:7d88:0:b0:3b4:2b61:da32 with SMTP id c8-20020ac87d88000000b003b42b61da32mr45766274qtd.59.1676283117985; Mon, 13 Feb 2023 02:11:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676283117; cv=none; d=google.com; s=arc-20160816; b=K7pHsktkPxUtZgWk7EsAsatdW0xo3214wkqtCvncKgTKmjspI7861fIMy3FOkw5S6n Cj8dm6an27UO3Q2zUiJXR1epy81EWBRQjpBlcKWGmADf7CYqOh1lF2k+nctzjCzvke49 I0DkT2hp1mx4v/AEfcCwAqgVDH0wt39KF/E5H1q//b6CGlO83/dQI+9f9EuskuMAfQ7L /CjVztg0cWaWdsnyOM+NiicV3zdouY7zvzE0YjQbg7hhdAYdx+DNZ65DajOfDyxYqRrp b/WnaJ3X4oQR4qg4p0E7cAAyzXZsZLjS5ylWXgzAXnZFEkTHkgGlwQsGpWEJtpQm9TM2 PMMA== 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=iAgmNlVIUOinPrwzOOaOjTPgQ/bZC+ofNOItCPLhOkw=; b=VFk67SfM/gmrTg27jrjAQBGuKPOimpbrAIYQAx39pjSyJ1I7jX5BNioRShR8FdJm/v GjgfgcvWZGOBM2QBQt/+Oc0cawUUdyiq+kJo+V95VBAyWGbnOg3nl+tX2/rvK1wG08zz uXXU4wQnri+sQPQzM9e63mYFBSJIEAZEA0P1Ss7uzIINKUt5sD+FPUQiDTl+T/c06qrg 3MI4DI7+OXyuNqVXnzAIh8FMkJUWJb6xY3At+xP0VaD1YHMER+FomqgVx9cbA16Q9eo1 GLJg/COXGtWNEAZ5fjuawrIylkojcQx5Wj9HE6nstRRDvt7VuYSoBte0/UMaSxktUiEA iDHg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=DADTOwmU; 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 u9-20020ac858c9000000b003a5270c7790si9269568qta.90.2023.02.13.02.11.57 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 13 Feb 2023 02:11:57 -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=DADTOwmU; 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 1pRVo5-0006HT-ER; Mon, 13 Feb 2023 05:11:33 -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 1pRVo4-0006C7-0i for qemu-devel@nongnu.org; Mon, 13 Feb 2023 05:11:32 -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 1pRVo2-0003YK-60 for qemu-devel@nongnu.org; Mon, 13 Feb 2023 05:11:31 -0500 Received: by mail-wm1-x32f.google.com with SMTP id he5so491170wmb.3 for ; Mon, 13 Feb 2023 02:11:25 -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=iAgmNlVIUOinPrwzOOaOjTPgQ/bZC+ofNOItCPLhOkw=; b=DADTOwmUY0Yx2wnpt7nyQKOI53EaTW5a4izqv/r3uRO6sm1J1SRuWZ+yKAuxeUGMHw SEy/pl630oz7JiqgPn0lf7H6FjDqEv1NfFzyRktsrPJJHfRZPf1UmwN92nrwzDNdz/xn Jl7GTVqzzEyaBMnJmatRQrAI+PT1keR1HHYHSosN2TXiPx8S1AmNpCahJz1eCLawxWiZ GQTsDZz80/XL+VOyymOmK5GqOEmdzfivdDA/xG1Y/tMREjxRDtZcdcD7RhfIVOjNzEIh ZtF5MIp/fvBCvxeke7LarCavukhy9ugwlKUDg3EvR0dLFpy/AF0KZYHfvDfqTCJifAqP BZdg== 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=iAgmNlVIUOinPrwzOOaOjTPgQ/bZC+ofNOItCPLhOkw=; b=POMSakKao/Zj2hu9GF2yhvcXkyZtPQN9gsSbq6g0B6xPg6CpmnMNg8VKzZyK6oqSMh w8QdiDPJDA49xL95hvcyWSM0SwxsoGDMDDP6CLHpD1nOkEl568ywldc28VM8WmvYpuaS hLZ/6CTaUtOG/PHihBRYOSB5DNTh+dL6bVgRVnPIdNlYixOl81bvm3pw4XYnXxYeND25 UEPH0h/WNon5OP3iY2ehkPHZbgY357z1ZZuUwIqDsnt3oUrIqVHmq3E1CDc0qIjvLhX3 ogo/q9Pl5HKDKg00I/rqXFngXfomwov0qqpJAw3Rlo3dTUEcqPEqKRH/iNeF7QwWO903 DJTA== X-Gm-Message-State: AO0yUKUB5hidpNtlLsWTwki12Wv2RJ0Jjg7CNeSH8OzDBJPWxzXRaVhn wwVHUsFc9cFieEckrQj4O3YD/CHjmyeTvVAW X-Received: by 2002:a05:600c:1694:b0:3de:27c3:ef13 with SMTP id k20-20020a05600c169400b003de27c3ef13mr18354060wmn.9.1676283084674; Mon, 13 Feb 2023 02:11:24 -0800 (PST) Received: from localhost.localdomain ([81.0.6.76]) by smtp.gmail.com with ESMTPSA id o19-20020a05600c4fd300b003dc59d6f2f8sm13851336wmq.17.2023.02.13.02.11.23 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 13 Feb 2023 02:11:24 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, Eduardo Habkost Cc: Jason Wang , Thomas Huth , Igor Mammedov , Stefan Weil , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH v2 7/7] hw/net/eepro100: Replace DO_UPCAST(EEPRO100State) by EEPRO100() Date: Mon, 13 Feb 2023 11:10:48 +0100 Message-Id: <20230213101048.94519-8-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230213101048.94519-1-philmd@linaro.org> References: <20230213101048.94519-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32f; envelope-from=philmd@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 Use the EEPRO100() QOM type-checking macro to avoid DO_UPCAST(). Signed-off-by: Philippe Mathieu-Daudé --- hw/net/eepro100.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/hw/net/eepro100.c b/hw/net/eepro100.c index bce377688e..6db15f1ba2 100644 --- a/hw/net/eepro100.c +++ b/hw/net/eepro100.c @@ -1834,7 +1834,7 @@ static const VMStateDescription vmstate_eepro100 = { static void pci_nic_uninit(PCIDevice *pci_dev) { - EEPRO100State *s = DO_UPCAST(EEPRO100State, dev, pci_dev); + EEPRO100State *s = EEPRO100(pci_dev); vmstate_unregister(VMSTATE_IF(&pci_dev->qdev), s->vmstate, s); g_free(s->vmstate); @@ -1850,7 +1850,7 @@ static NetClientInfo net_eepro100_info = { static void e100_nic_realize(PCIDevice *pci_dev, Error **errp) { - EEPRO100State *s = DO_UPCAST(EEPRO100State, dev, pci_dev); + EEPRO100State *s = EEPRO100(pci_dev); TRACE(OTHER, logout("\n")); @@ -1891,7 +1891,7 @@ static void e100_nic_realize(PCIDevice *pci_dev, Error **errp) static void eepro100_instance_init(Object *obj) { - EEPRO100State *s = DO_UPCAST(EEPRO100State, dev, PCI_DEVICE(obj)); + EEPRO100State *s = EEPRO100(obj); device_add_bootindex_property(obj, &s->conf.bootindex, "bootindex", "/ethernet-phy@0", DEVICE(s));