From patchwork Tue Jan 17 20:16:39 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: 643413 Delivered-To: patch@linaro.org Received: by 2002:a17:522:b9de:b0:4b9:b062:db3b with SMTP id fj30csp1372479pvb; Tue, 17 Jan 2023 12:18:01 -0800 (PST) X-Google-Smtp-Source: AMrXdXtKRi26HKTecXuGTzQ98F2stCiMMTA0E/7oO4VY7Hu/PtE1KjRqe6u3IDKE8RE0aZSxUMQ9 X-Received: by 2002:a1f:3857:0:b0:3bc:3356:d850 with SMTP id f84-20020a1f3857000000b003bc3356d850mr2163887vka.10.1673986680826; Tue, 17 Jan 2023 12:18:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673986680; cv=none; d=google.com; s=arc-20160816; b=LXQgFtphiGtZarfMR2XxJHHfcwGzDOy4vfvkaOhMc6/cYGnWreLJXovlJn1A85rXNy tcmapoQgkT9mUFP7qAEZzQZhXRE+BG0STNybH74fmoyfNg5a+qvb/xP4n/V2lOdgGVf3 RR03V2rneVXazI+1hTTy7PsKQcbKhTbRY8asJNE0fNFalurdF2m5X6NYvlNltMzI2Qxs nIKnDroV7x1SvWU0cFtSh9QO1VidXns256+BRpSeZyB36XbvkM9P0JydTyI1BqeZ6rvQ Cj5D1YCylUGsyGOD5OikdfbJJftWOquiMqTu140rh6mTAiMYQDcgsdPl5nyiOHoEHkAu ikKA== 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=ydeX9QFFdks9xGDUB7zYGvimiTN6pGP8Ia7mPwpsiT8=; b=v21Vc4OaC5LCGxhd16Jw6FrDAuNb92oe7E6ljyGE0OnTNFCubRRaHmvh6w1hwxF8MC b4nffY67nc//9hhwmewX9pSw/MDw/RbvjHHCRRjnRP6xohEhoAHocJ+ZpYHxzY0mplC1 eLGlySaMIdBjoNh9o8SHIpdfM+HkFRTVsIJDr8VZSeWWxAK0SKNakhumo0KWnhN3RXXJ aOv1VIjHoleXFwV78DhQp5a29ef+9W1Tr4IakYi2Qnvq5upRiC0ExcbQfnC0Kg7K2AEU ejoWDgdm/sVPGyTw8HiR0Dv4vC9bSckCCM9mef/rlE/8LUlAX0/Jof3fNYDO89UXZQmQ vtZA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="M4a/OMcr"; 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 bp30-20020a05620a459e00b006fa9c0c5ae1si20418186qkb.24.2023.01.17.12.18.00 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 17 Jan 2023 12:18:00 -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="M4a/OMcr"; 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 1pHsO4-0002tl-Db; Tue, 17 Jan 2023 15:16:52 -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 1pHsO3-0002tY-3D for qemu-devel@nongnu.org; Tue, 17 Jan 2023 15:16:51 -0500 Received: from mail-ed1-x536.google.com ([2a00:1450:4864:20::536]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pHsO1-0006Rg-Ly for qemu-devel@nongnu.org; Tue, 17 Jan 2023 15:16:50 -0500 Received: by mail-ed1-x536.google.com with SMTP id s21so2509298edi.12 for ; Tue, 17 Jan 2023 12:16:49 -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=ydeX9QFFdks9xGDUB7zYGvimiTN6pGP8Ia7mPwpsiT8=; b=M4a/OMcrw38n2lxsGg5Comb/Gw3G1TsBIhXkP7lju0H8oKPgaDw/zQl6fN3jqarBQO 4DiFz9wFKFmAcPshH9+AYp+xpSwFgZQyC8tDGRnYvuoTwY4TavgWA3JA4I1hFUyN3YP0 jFGymLMsrTpSlQuwWTR3smKdM+u7EDZzutHCtfSdLtpmCq9om8lnzaJDtrHJkRfoKqMk HDEzsvB7Qt6RZfpJt36HKB6DxZsLtYrgVwHt5dEd+7i2TiIaMfNLVB3lU4otUlYNrKDc irq+fcQYLxDIkUVmozwtsGzFdpad/u41gZMS+RcYiFUONXhhose8AU5qwnVjNFccblBm 59AQ== 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=ydeX9QFFdks9xGDUB7zYGvimiTN6pGP8Ia7mPwpsiT8=; b=xYzZlfNemyUQdz+CagFeIeFIRc6ZG//ojhSyVjE0pyYSz8TwYnPEKeW6Ve5Zr+/f0t vCYxEf3ai1F3zhAz/ixGuKYFR+VVfj5pggwHfBm7GxHsB/AFWuiLVbVsI+5NKs32klBw TgvYis5LWYJdPAno1d9Nlw5G8DLCyeFFxxEa69gWk5tM/iq4tILoHu+ngpmHP6KftLtI LJDmDxuxEaNcDhvaYZfXjnCx0kmvL6KpfDDoRNHlQCS5KyHWCe+Qnv1nAngZOvxV1E28 TSWQ7dj9IYr3IXm2ZbdtIVZdmVb6Q4ccE93oVOjcXN7cJg1T4pBzBLfKASc8CYD6BAkm IYvA== X-Gm-Message-State: AFqh2krUx8mNHWetQUxi/1UFmXD5D9h1fPOUpK+xANt/VI3RHajSSgDx to9gn7TgY7End6FOCwrmSVh7MUT8fmP2U9Vs X-Received: by 2002:aa7:cfd3:0:b0:48e:bb08:c96 with SMTP id r19-20020aa7cfd3000000b0048ebb080c96mr4005986edy.28.1673986608204; Tue, 17 Jan 2023 12:16:48 -0800 (PST) Received: from localhost.localdomain ([185.126.107.38]) by smtp.gmail.com with ESMTPSA id w21-20020a05640234d500b0049c2b02bad4sm5746257edc.88.2023.01.17.12.16.47 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 17 Jan 2023 12:16:47 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-ppc@nongnu.org, BALATON Zoltan , =?utf-8?q?Phil?= =?utf-8?q?ippe_Mathieu-Daud=C3=A9?= Subject: [PATCH 1/2] hw/ppc/pegasos2: Extract via_i2c_bus() helper Date: Tue, 17 Jan 2023 21:16:39 +0100 Message-Id: <20230117201640.88365-2-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230117201640.88365-1-philmd@linaro.org> References: <20230117201640.88365-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::536; envelope-from=philmd@linaro.org; helo=mail-ed1-x536.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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Simplify a bit pegasos2_init() by extracting via_i2c_bus(). Signed-off-by: Philippe Mathieu-Daudé --- hw/ppc/pegasos2.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/hw/ppc/pegasos2.c b/hw/ppc/pegasos2.c index f46d4bf51d..ac69aee099 100644 --- a/hw/ppc/pegasos2.c +++ b/hw/ppc/pegasos2.c @@ -96,6 +96,14 @@ static void pegasos2_cpu_reset(void *opaque) } } +static I2CBus *via_i2c_bus(PCIDevice *via) +{ + PCIDevice *dev; + + dev = PCI_DEVICE(object_resolve_path_component(OBJECT(via), "pm")); + return I2C_BUS(qdev_get_child_bus(DEVICE(dev), "i2c")); +} + static void pegasos2_init(MachineState *machine) { Pegasos2MachineState *pm = PEGASOS2_MACHINE(machine); @@ -103,7 +111,6 @@ static void pegasos2_init(MachineState *machine) MemoryRegion *rom = g_new(MemoryRegion, 1); PCIBus *pci_bus; PCIDevice *dev, *via; - I2CBus *i2c_bus; const char *fwname = machine->firmware ?: PROM_FILENAME; char *filename; int sz; @@ -171,10 +178,8 @@ static void pegasos2_init(MachineState *machine) dev = PCI_DEVICE(object_resolve_path_component(OBJECT(via), "ide")); pci_ide_create_devs(dev); - dev = PCI_DEVICE(object_resolve_path_component(OBJECT(via), "pm")); - i2c_bus = I2C_BUS(qdev_get_child_bus(DEVICE(dev), "i2c")); spd_data = spd_data_generate(DDR, machine->ram_size); - smbus_eeprom_init_one(i2c_bus, 0x57, spd_data); + smbus_eeprom_init_one(via_i2c_bus(via), 0x57, spd_data); /* other PC hardware */ pci_vga_init(pci_bus);