From nobody Tue May 7 04:30:10 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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 ARC-Seal: i=1; a=rsa-sha256; t=1593989001; cv=none; d=zohomail.com; s=zohoarc; b=ltN2x0xt5tzycScfxxQJLJGBk21LxDMRSRbElkbTJV2y2QEBw8OsgsYuVCdBt5srdpZhNVMepLsPeJ6cEusC9Lv0q1geh5QfbyK1T94xPH0ekUQ2GGAo77d/EqhghyR4Wcae/Y7aTpbn1DpmijtZCzQs4dJvGSeim69FVb8buFQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1593989001; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=KJXVJ20Xc29x5zy30LKvYKgkRIGdu79sUZj2iAxIfIU=; b=LcMMCfdXqiy5yTSwWKrKWJ+f/OKOsyHyLPwPBpTDFFdYTVeEnUA7tvTNkSHdw0tJt5hyUKsNX0QwVrM8lPWu2Mlns79a1tTRpv8J0ZvIw/c7KGGH88jH9hzyPNSOXmFEaJBjBW/6UVYtSZEKNHvmasWcAVUeyf/QJreypCKIZL4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1593989001492401.7866162663013; Sun, 5 Jul 2020 15:43:21 -0700 (PDT) Received: from localhost ([::1]:44274 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jsDLz-0006Iq-DL for importer@patchew.org; Sun, 05 Jul 2020 18:43:19 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42464) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jsDKl-0004Gl-6F; Sun, 05 Jul 2020 18:42:03 -0400 Received: from mail-wr1-x444.google.com ([2a00:1450:4864:20::444]:46041) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jsDKj-0002hk-B0; Sun, 05 Jul 2020 18:42:02 -0400 Received: by mail-wr1-x444.google.com with SMTP id s10so38888669wrw.12; Sun, 05 Jul 2020 15:42:00 -0700 (PDT) Received: from localhost.localdomain (1.red-83-51-162.dynamicip.rima-tde.net. [83.51.162.1]) by smtp.gmail.com with ESMTPSA id v6sm9151467wrr.85.2020.07.05.15.41.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Jul 2020 15:41:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=KJXVJ20Xc29x5zy30LKvYKgkRIGdu79sUZj2iAxIfIU=; b=axACWr0xg9raBoHcuXDdr2p8cPavojEtKh3jVCUuylaEtnFauxGfpKn3FPjdbtGUe9 /rNdvs8Kq2zDZkuLvxrF1KxPuooMsiuBQGdOUBHwqzNWVH5mlxE2w1X84tTcGCMWPX0Q obVX1Jf7aEqrH6fqW11bcqmOVWgtL4ZhcmHAPJvgPIXMP//zi7ErwXRa1PZzUYgSyAv7 Z13keyu7ti/L8BisgeMift0ebkp1cwGnKdxW9qQb4erijE68DaCuLmAc+jvcMh2zYJ2D 6JBRNrMgdBF+6/TgodBh309ehHy6DkwGPTXbzHQsbhKZGkJ8s2jiU+WaQDl2/36qSsTE WRyQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=KJXVJ20Xc29x5zy30LKvYKgkRIGdu79sUZj2iAxIfIU=; b=gdAYTxlNhB/TI/Rz5FDQWUeyWtHJRWR9SGNzSyT+W78Zvhk+u7EKuP9eAj6k+2NEq9 SR43K0sG7UI1Gv3kubVhYvP/LBu4A96zi/wWflaXUf+SXmjI7UUbjULsN+e8hhTmhcVI 4bfMkfNzfvN5uX9gNFOASY7WjZznsB6Poc6ABZGgInPC0ewSgASp9q88xUdC6aNimTvl 1RUAXsKTgDedXojy0wQualfdaIx1lSCBVFRi5VDiuL8RV7sjzF//n0QXtiitTgEozMmo GjRRyETpydPyTkKb0R8ExJi4QtigrbAND/Ci0+U9Nd0FL85YHdJfd/wd8nAjGXLvzkKy efBQ== X-Gm-Message-State: AOAM530zet0UYvTsc2gMstuJCCULkLMrN/2/UbR9gEUXDAI+B7vvP1no tkp/DZHJLb/ET0s49KH8WMq5ZtJ941Y= X-Google-Smtp-Source: ABdhPJyxQfi3gWAf+rfc8Aws+xAeKW1KGRhNPbT22vx96D7ZgcV2d9I5htni3D2pbvPDMn/egiUWAg== X-Received: by 2002:a5d:6a04:: with SMTP id m4mr44957503wru.418.1593988919095; Sun, 05 Jul 2020 15:41:59 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v2 1/5] hw/i2c/aspeed_i2c: Simplify aspeed_i2c_get_bus() Date: Mon, 6 Jul 2020 00:41:50 +0200 Message-Id: <20200705224154.16917-2-f4bug@amsat.org> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20200705224154.16917-1-f4bug@amsat.org> References: <20200705224154.16917-1-f4bug@amsat.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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::444; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-wr1-x444.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: 0 X-Spam_score: 0.0 X-Spam_bar: / X-Spam_report: (0.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=1, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Corey Minyard , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Peter Maydell , Andrew Jeffery , Markus Armbruster , qemu-arm@nongnu.org, qemu-ppc@nongnu.org, Joel Stanley , Jan Kiszka , David Gibson , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) All the callers of aspeed_i2c_get_bus() have a AspeedI2CState and cast it to a DeviceState with DEVICE(), then aspeed_i2c_get_bus() cast the DeviceState to an AspeedI2CState with ASPEED_I2C()... Simplify aspeed_i2c_get_bus() callers by using AspeedI2CState argument. Reviewed-by: Markus Armbruster Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Andrew Jeffery --- include/hw/i2c/aspeed_i2c.h | 2 +- hw/arm/aspeed.c | 70 ++++++++++++++++++------------------- hw/i2c/aspeed_i2c.c | 3 +- 3 files changed, 37 insertions(+), 38 deletions(-) diff --git a/include/hw/i2c/aspeed_i2c.h b/include/hw/i2c/aspeed_i2c.h index f1b9e5bf91..243789ae5d 100644 --- a/include/hw/i2c/aspeed_i2c.h +++ b/include/hw/i2c/aspeed_i2c.h @@ -93,6 +93,6 @@ typedef struct AspeedI2CClass { =20 } AspeedI2CClass; =20 -I2CBus *aspeed_i2c_get_bus(DeviceState *dev, int busnr); +I2CBus *aspeed_i2c_get_bus(AspeedI2CState *s, int busnr); =20 #endif /* ASPEED_I2C_H */ diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c index 379f9672a5..1285bf82c0 100644 --- a/hw/arm/aspeed.c +++ b/hw/arm/aspeed.c @@ -385,13 +385,13 @@ static void palmetto_bmc_i2c_init(AspeedMachineState = *bmc) =20 /* The palmetto platform expects a ds3231 RTC but a ds1338 is * enough to provide basic RTC features. Alarms will be missing */ - i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 0), "ds1338", 0= x68); + i2c_create_slave(aspeed_i2c_get_bus(&soc->i2c, 0), "ds1338", 0x68); =20 - smbus_eeprom_init_one(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 0), 0x50, + smbus_eeprom_init_one(aspeed_i2c_get_bus(&soc->i2c, 0), 0x50, eeprom_buf); =20 /* add a TMP423 temperature sensor */ - dev =3D i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 2), + dev =3D i2c_create_slave(aspeed_i2c_get_bus(&soc->i2c, 2), "tmp423", 0x4c); object_property_set_int(OBJECT(dev), 31000, "temperature0", &error_abo= rt); object_property_set_int(OBJECT(dev), 28000, "temperature1", &error_abo= rt); @@ -404,16 +404,16 @@ static void ast2500_evb_i2c_init(AspeedMachineState *= bmc) AspeedSoCState *soc =3D &bmc->soc; uint8_t *eeprom_buf =3D g_malloc0(8 * 1024); =20 - smbus_eeprom_init_one(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 3), 0x50, + smbus_eeprom_init_one(aspeed_i2c_get_bus(&soc->i2c, 3), 0x50, eeprom_buf); =20 /* The AST2500 EVB expects a LM75 but a TMP105 is compatible */ - i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 7), + i2c_create_slave(aspeed_i2c_get_bus(&soc->i2c, 7), TYPE_TMP105, 0x4d); =20 /* The AST2500 EVB does not have an RTC. Let's pretend that one is * plugged on the I2C bus header */ - i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 11), "ds1338", = 0x32); + i2c_create_slave(aspeed_i2c_get_bus(&soc->i2c, 11), "ds1338", 0x32); } =20 static void ast2600_evb_i2c_init(AspeedMachineState *bmc) @@ -428,36 +428,36 @@ static void romulus_bmc_i2c_init(AspeedMachineState *= bmc) =20 /* The romulus board expects Epson RX8900 I2C RTC but a ds1338 is * good enough */ - i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 11), "ds1338", = 0x32); + i2c_create_slave(aspeed_i2c_get_bus(&soc->i2c, 11), "ds1338", 0x32); } =20 static void swift_bmc_i2c_init(AspeedMachineState *bmc) { AspeedSoCState *soc =3D &bmc->soc; =20 - i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 3), "pca9552", = 0x60); + i2c_create_slave(aspeed_i2c_get_bus(&soc->i2c, 3), "pca9552", 0x60); =20 /* The swift board expects a TMP275 but a TMP105 is compatible */ - i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 7), "tmp105", 0= x48); + i2c_create_slave(aspeed_i2c_get_bus(&soc->i2c, 7), "tmp105", 0x48); /* The swift board expects a pca9551 but a pca9552 is compatible */ - i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 7), "pca9552", = 0x60); + i2c_create_slave(aspeed_i2c_get_bus(&soc->i2c, 7), "pca9552", 0x60); =20 /* The swift board expects an Epson RX8900 RTC but a ds1338 is compati= ble */ - i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 8), "ds1338", 0= x32); - i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 8), "pca9552", = 0x60); + i2c_create_slave(aspeed_i2c_get_bus(&soc->i2c, 8), "ds1338", 0x32); + i2c_create_slave(aspeed_i2c_get_bus(&soc->i2c, 8), "pca9552", 0x60); =20 - i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 9), "tmp423", 0= x4c); + i2c_create_slave(aspeed_i2c_get_bus(&soc->i2c, 9), "tmp423", 0x4c); /* The swift board expects a pca9539 but a pca9552 is compatible */ - i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 9), "pca9552", = 0x74); + i2c_create_slave(aspeed_i2c_get_bus(&soc->i2c, 9), "pca9552", 0x74); =20 - i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 10), "tmp423", = 0x4c); + i2c_create_slave(aspeed_i2c_get_bus(&soc->i2c, 10), "tmp423", 0x4c); /* The swift board expects a pca9539 but a pca9552 is compatible */ - i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 10), "pca9552", + i2c_create_slave(aspeed_i2c_get_bus(&soc->i2c, 10), "pca9552", 0x74); =20 /* The swift board expects a TMP275 but a TMP105 is compatible */ - i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 12), "tmp105", = 0x48); - i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 12), "tmp105", = 0x4a); + i2c_create_slave(aspeed_i2c_get_bus(&soc->i2c, 12), "tmp105", 0x48); + i2c_create_slave(aspeed_i2c_get_bus(&soc->i2c, 12), "tmp105", 0x4a); } =20 static void sonorapass_bmc_i2c_init(AspeedMachineState *bmc) @@ -465,32 +465,32 @@ static void sonorapass_bmc_i2c_init(AspeedMachineStat= e *bmc) AspeedSoCState *soc =3D &bmc->soc; =20 /* bus 2 : */ - i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 2), "tmp105", 0= x48); - i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 2), "tmp105", 0= x49); + i2c_create_slave(aspeed_i2c_get_bus(&soc->i2c, 2), "tmp105", 0x48); + i2c_create_slave(aspeed_i2c_get_bus(&soc->i2c, 2), "tmp105", 0x49); /* bus 2 : pca9546 @ 0x73 */ =20 /* bus 3 : pca9548 @ 0x70 */ =20 /* bus 4 : */ uint8_t *eeprom4_54 =3D g_malloc0(8 * 1024); - smbus_eeprom_init_one(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 4), 0x54, + smbus_eeprom_init_one(aspeed_i2c_get_bus(&soc->i2c, 4), 0x54, eeprom4_54); /* PCA9539 @ 0x76, but PCA9552 is compatible */ - i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 4), "pca9552", = 0x76); + i2c_create_slave(aspeed_i2c_get_bus(&soc->i2c, 4), "pca9552", 0x76); /* PCA9539 @ 0x77, but PCA9552 is compatible */ - i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 4), "pca9552", = 0x77); + i2c_create_slave(aspeed_i2c_get_bus(&soc->i2c, 4), "pca9552", 0x77); =20 /* bus 6 : */ - i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 6), "tmp105", 0= x48); - i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 6), "tmp105", 0= x49); + i2c_create_slave(aspeed_i2c_get_bus(&soc->i2c, 6), "tmp105", 0x48); + i2c_create_slave(aspeed_i2c_get_bus(&soc->i2c, 6), "tmp105", 0x49); /* bus 6 : pca9546 @ 0x73 */ =20 /* bus 8 : */ uint8_t *eeprom8_56 =3D g_malloc0(8 * 1024); - smbus_eeprom_init_one(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 8), 0x56, + smbus_eeprom_init_one(aspeed_i2c_get_bus(&soc->i2c, 8), 0x56, eeprom8_56); - i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 8), "pca9552", = 0x60); - i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 8), "pca9552", = 0x61); + i2c_create_slave(aspeed_i2c_get_bus(&soc->i2c, 8), "pca9552", 0x60); + i2c_create_slave(aspeed_i2c_get_bus(&soc->i2c, 8), "pca9552", 0x61); /* bus 8 : adc128d818 @ 0x1d */ /* bus 8 : adc128d818 @ 0x1f */ =20 @@ -515,25 +515,25 @@ static void witherspoon_bmc_i2c_init(AspeedMachineSta= te *bmc) /* Bus 3: TODO dps310@76 */ dev =3D i2c_try_create_slave(TYPE_PCA9552, 0x60); qdev_prop_set_string(dev, "description", "pca1"); - i2c_realize_and_unref(dev, aspeed_i2c_get_bus(DEVICE(&soc->i2c), 3), + i2c_realize_and_unref(dev, aspeed_i2c_get_bus(&soc->i2c, 3), &error_fatal); =20 - i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 4), "tmp423", 0= x4c); - i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 5), "tmp423", 0= x4c); + i2c_create_slave(aspeed_i2c_get_bus(&soc->i2c, 4), "tmp423", 0x4c); + i2c_create_slave(aspeed_i2c_get_bus(&soc->i2c, 5), "tmp423", 0x4c); =20 /* The Witherspoon expects a TMP275 but a TMP105 is compatible */ - i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 9), TYPE_TMP105, + i2c_create_slave(aspeed_i2c_get_bus(&soc->i2c, 9), TYPE_TMP105, 0x4a); =20 /* The witherspoon board expects Epson RX8900 I2C RTC but a ds1338 is * good enough */ - i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 11), "ds1338", = 0x32); + i2c_create_slave(aspeed_i2c_get_bus(&soc->i2c, 11), "ds1338", 0x32); =20 - smbus_eeprom_init_one(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 11), 0x51, + smbus_eeprom_init_one(aspeed_i2c_get_bus(&soc->i2c, 11), 0x51, eeprom_buf); dev =3D i2c_try_create_slave(TYPE_PCA9552, 0x60); qdev_prop_set_string(dev, "description", "pca0"); - i2c_realize_and_unref(dev, aspeed_i2c_get_bus(DEVICE(&soc->i2c), 11), + i2c_realize_and_unref(dev, aspeed_i2c_get_bus(&soc->i2c, 11), &error_fatal); /* Bus 11: TODO ucd90160@64 */ } diff --git a/hw/i2c/aspeed_i2c.c b/hw/i2c/aspeed_i2c.c index fb973a983d..518a3f5c6f 100644 --- a/hw/i2c/aspeed_i2c.c +++ b/hw/i2c/aspeed_i2c.c @@ -959,9 +959,8 @@ static void aspeed_i2c_register_types(void) type_init(aspeed_i2c_register_types) =20 =20 -I2CBus *aspeed_i2c_get_bus(DeviceState *dev, int busnr) +I2CBus *aspeed_i2c_get_bus(AspeedI2CState *s, int busnr) { - AspeedI2CState *s =3D ASPEED_I2C(dev); AspeedI2CClass *aic =3D ASPEED_I2C_GET_CLASS(s); I2CBus *bus =3D NULL; =20 --=20 2.21.3 From nobody Tue May 7 04:30:10 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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 ARC-Seal: i=1; a=rsa-sha256; t=1593989036; cv=none; d=zohomail.com; s=zohoarc; b=kK7Yw/bnl+3kEsi4mfvnq1RTkoJbJ8UMI+AklPvk8/Ttsp6T2wDBDoxRHpk47dj0f65qDEFUCkRp61sXxy1etTECbiegJSl0k4c11qhLXFu8RZ46jbF/XGScqjywAnIaGAyWOaUB7umPkgMGbw9U5a7ILu9oQpZE5Y0FEs9pAws= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1593989036; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=RJorkYK71XuxeJn/MmaQaqEtLEUwVuOASL3pI8dX4DM=; b=Lu/1Hd+H0bPBnmuQ2LhrAEtmJUzmjaBndwnY1l5yI06eq5ZxVrjCse+lRMP9gfElE/auXrMEiMSMC08NWIk+3Dx8AfAsnu/qj3Kd/ZWAoQAJzfXs7zxOvqKgjLNzpVu9hZDigqa5Z9TvBqhQvQBT/w0ZVj5vl7J6uoSy5Oy6qKc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1593989036743380.09532605597246; Sun, 5 Jul 2020 15:43:56 -0700 (PDT) Received: from localhost ([::1]:47268 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jsDMZ-0007wj-II for importer@patchew.org; Sun, 05 Jul 2020 18:43:55 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42474) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jsDKm-0004Hy-CZ; Sun, 05 Jul 2020 18:42:04 -0400 Received: from mail-wr1-x42d.google.com ([2a00:1450:4864:20::42d]:44116) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jsDKk-0002hv-Q8; Sun, 05 Jul 2020 18:42:04 -0400 Received: by mail-wr1-x42d.google.com with SMTP id b6so38915949wrs.11; Sun, 05 Jul 2020 15:42:01 -0700 (PDT) Received: from localhost.localdomain (1.red-83-51-162.dynamicip.rima-tde.net. [83.51.162.1]) by smtp.gmail.com with ESMTPSA id v6sm9151467wrr.85.2020.07.05.15.41.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Jul 2020 15:42:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=RJorkYK71XuxeJn/MmaQaqEtLEUwVuOASL3pI8dX4DM=; b=tkrHuxjAVfaJchGbSaeE5rbW8n2tB/xcKjLYaHFqPVcoR6gPUum+c7QX8zvWOhDTqS JHoFY+LKmo9Oei4kNKGFVJtVtiskzfwL7H6tmim+IhVv2GyhnaU3iRgeq22npWU9GM3j VYWbUgj0vzhzpo3K38f/1/T4rzmwxK1v/HunH3H58J6If91tVq6Svs0zO0Pb4sURGzc7 HT833FRXH+RrkPSN9ng6SPbVPJb9sT9tOeQ88JFLBU5b2cTKk6JY5keGxi/cN08fRbB5 FT3CWwn5z/9tEdLiHDQ/ZnfYA96tEBCsFzTPM/FAk21xtS7CshK1hFuxtOtTAWNrrvgB zRQQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=RJorkYK71XuxeJn/MmaQaqEtLEUwVuOASL3pI8dX4DM=; b=IEmy2m20uAsm1uJXJrC1fHALhjmGoK96qnLZD1wDt98IrnV4lVnzaGRyo49PlkjCFu 60Lfzi3jRLJahDEK4fROfEnCS+zIM3KgxUrHRChAunHLSUSYI5YGo3WSjsH6k+6dxCin Qjbi0wwF3TagZjeR01DyUch0k7erUQlZlT5LZo0R8wS1MQ3CMgHgHI+q1fULm5IAkVGC lI02P5ehOZWU+4iabhwa9iX5yrxOhN/WQh3H5P0nVa1frqxtTQfa1PGuPL7I2C56yNHQ kxuEpNRGNWaZNlqUHcEtCjUYx0ECOjwF10aBxP94scM8VnLzzChOBijDkf1jBIERX2b0 DKuQ== X-Gm-Message-State: AOAM530mM/hVut+GTuSpJ8jqJzZnrjzftTHYl8+V/xiw6bqZEQdLCGUC zw6aFuZgClWfxU6HKvJ8SCXPFBiyIYA= X-Google-Smtp-Source: ABdhPJyynVJotrId2R/nneiiyxoSSjqSejsDVq9KR/lJVr2WL6nTSVjLo7A9hCtbW4P7GWKcYkxMSA== X-Received: by 2002:adf:b608:: with SMTP id f8mr49757881wre.363.1593988920564; Sun, 05 Jul 2020 15:42:00 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v2 2/5] hw/i2c: Rename i2c_try_create_slave() as i2c_slave_new() Date: Mon, 6 Jul 2020 00:41:51 +0200 Message-Id: <20200705224154.16917-3-f4bug@amsat.org> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20200705224154.16917-1-f4bug@amsat.org> References: <20200705224154.16917-1-f4bug@amsat.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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::42d; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-wr1-x42d.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: 0 X-Spam_score: 0.0 X-Spam_bar: / X-Spam_report: (0.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=1, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Corey Minyard , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Peter Maydell , Andrew Jeffery , Markus Armbruster , qemu-arm@nongnu.org, qemu-ppc@nongnu.org, Joel Stanley , Jan Kiszka , David Gibson , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) We use "new" names for functions that allocate and initialize device objects: pci_new(), isa_new(), usb_new(). Let's call this one i2c_slave_new(). Since we have to update all the callers, also let it return a I2CSlave object. Suggested-by: Markus Armbruster Reviewed-by: Markus Armbruster Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- include/hw/i2c/i2c.h | 2 +- hw/arm/aspeed.c | 4 ++-- hw/i2c/core.c | 11 +++++------ 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/include/hw/i2c/i2c.h b/include/hw/i2c/i2c.h index d6e3d85faf..18efc668f1 100644 --- a/include/hw/i2c/i2c.h +++ b/include/hw/i2c/i2c.h @@ -79,8 +79,8 @@ int i2c_send_recv(I2CBus *bus, uint8_t *data, bool send); int i2c_send(I2CBus *bus, uint8_t data); uint8_t i2c_recv(I2CBus *bus); =20 +I2CSlave *i2c_slave_new(const char *name, uint8_t addr); DeviceState *i2c_create_slave(I2CBus *bus, const char *name, uint8_t addr); -DeviceState *i2c_try_create_slave(const char *name, uint8_t addr); bool i2c_realize_and_unref(DeviceState *dev, I2CBus *bus, Error **errp); =20 /* lm832x.c */ diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c index 1285bf82c0..54ca36e0b6 100644 --- a/hw/arm/aspeed.c +++ b/hw/arm/aspeed.c @@ -513,7 +513,7 @@ static void witherspoon_bmc_i2c_init(AspeedMachineState= *bmc) /* Bus 3: TODO bmp280@77 */ /* Bus 3: TODO max31785@52 */ /* Bus 3: TODO dps310@76 */ - dev =3D i2c_try_create_slave(TYPE_PCA9552, 0x60); + dev =3D DEVICE(i2c_slave_new(TYPE_PCA9552, 0x60)); qdev_prop_set_string(dev, "description", "pca1"); i2c_realize_and_unref(dev, aspeed_i2c_get_bus(&soc->i2c, 3), &error_fatal); @@ -531,7 +531,7 @@ static void witherspoon_bmc_i2c_init(AspeedMachineState= *bmc) =20 smbus_eeprom_init_one(aspeed_i2c_get_bus(&soc->i2c, 11), 0x51, eeprom_buf); - dev =3D i2c_try_create_slave(TYPE_PCA9552, 0x60); + dev =3D DEVICE(i2c_slave_new(TYPE_PCA9552, 0x60)); qdev_prop_set_string(dev, "description", "pca0"); i2c_realize_and_unref(dev, aspeed_i2c_get_bus(&soc->i2c, 11), &error_fatal); diff --git a/hw/i2c/core.c b/hw/i2c/core.c index acf34a12d6..144786f17a 100644 --- a/hw/i2c/core.c +++ b/hw/i2c/core.c @@ -267,13 +267,13 @@ const VMStateDescription vmstate_i2c_slave =3D { } }; =20 -DeviceState *i2c_try_create_slave(const char *name, uint8_t addr) +I2CSlave *i2c_slave_new(const char *name, uint8_t addr) { DeviceState *dev; =20 dev =3D qdev_new(name); qdev_prop_set_uint8(dev, "address", addr); - return dev; + return I2C_SLAVE(dev); } =20 bool i2c_realize_and_unref(DeviceState *dev, I2CBus *bus, Error **errp) @@ -283,12 +283,11 @@ bool i2c_realize_and_unref(DeviceState *dev, I2CBus *= bus, Error **errp) =20 DeviceState *i2c_create_slave(I2CBus *bus, const char *name, uint8_t addr) { - DeviceState *dev; + I2CSlave *dev =3D i2c_slave_new(name, addr); =20 - dev =3D i2c_try_create_slave(name, addr); - i2c_realize_and_unref(dev, bus, &error_fatal); + i2c_realize_and_unref(DEVICE(dev), bus, &error_fatal); =20 - return dev; + return DEVICE(dev); } =20 static void i2c_slave_class_init(ObjectClass *klass, void *data) --=20 2.21.3 From nobody Tue May 7 04:30:10 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=amsat.org ARC-Seal: i=1; a=rsa-sha256; t=1593989018; cv=none; d=zohomail.com; s=zohoarc; b=TIXOpKA8vgLDJBXMXGtwq9AQSc1UDFCzO4SYhBH+qfDXoPcp88Gd4itTNJKxHQ9VLPydj1KSMN2Pm8hjveP1UTZXygDkPOmyErB+3yE64qjtSlIIATTOBgYU+dS6IfW8T29rJUREDpOMV04KzO56Tdx/gzn4BQuHFaiq2P0d/70= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1593989018; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=jokNy7niATa/omdvHPNh1/95otnWd0IrupXVCsLQO64=; b=Ze0cJuPP56Gn2u/BRuS7NAqN/RTIaxfDqRvPaw8KnwsXiLbncunsFl6gbeAS3/0r8RYEbDnbCoai8t5avp6agdcRgUaEGQLHdP/wuX8a2jMi/r+Nmaxk640Rj0jpZS0jDIhBIAsy7KMLzitu9dLpHedptux8zlku8qSnmpD3Oic= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 15939890181311.9809218837239086; Sun, 5 Jul 2020 15:43:38 -0700 (PDT) Received: from localhost ([::1]:45412 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jsDMG-0006ux-Sq for importer@patchew.org; Sun, 05 Jul 2020 18:43:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42490) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jsDKo-0004MU-6D; Sun, 05 Jul 2020 18:42:06 -0400 Received: from mail-wm1-x342.google.com ([2a00:1450:4864:20::342]:39021) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jsDKm-0002iA-I3; Sun, 05 Jul 2020 18:42:05 -0400 Received: by mail-wm1-x342.google.com with SMTP id w3so27362395wmi.4; Sun, 05 Jul 2020 15:42:03 -0700 (PDT) Received: from localhost.localdomain (1.red-83-51-162.dynamicip.rima-tde.net. [83.51.162.1]) by smtp.gmail.com with ESMTPSA id v6sm9151467wrr.85.2020.07.05.15.42.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Jul 2020 15:42:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=jokNy7niATa/omdvHPNh1/95otnWd0IrupXVCsLQO64=; b=mDbwYSKBLDCXnp38XSaEUGGxDP01Y7AY7LfMGiVIhubB1aB2o21Jr6t096nys/BLJl gulZ0Tmk0uQtIrFVh4yTZMocWM34/8Wn8z1NSLYT9LAayxOPtKTaVjXXmMMbzpVgbA3n zcWJYeazRaXXEopLt+5WmBJhA7i9yerzHF3zLJPJw07lyEByBn+f51EQDpRwhQtEe07V xq7qGHEV6TMbDIx8ime4k3W4RtyynlTqCPMys7CJnPzmsKizHzwxjnkw6djQ4comqWj2 qtsbojpx7PzaXwdgbOm8r5nPAGbK9ua9LI27B7BQtyiUkjd7hVPfTvNLufP9pIY18wTv pa0g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=jokNy7niATa/omdvHPNh1/95otnWd0IrupXVCsLQO64=; b=dgYj5f0qYWFN2jvdi8ULBRwwzhh/odye4cJCQE+uWNn8QMO1VX/3zl5KFAlG5LPagG 8AUoUb/XbLusB4QCLqVgmdT4gTImmCNAKWKCUuWTPHiMy+d9x6RYAIBHvDkI44ZuOStD hvrSDMr3ty+QnbHRgskYClRGIBEEME6ZEptqCIs8NCAYcCWHoSICMtVKY/W3kNV6Zz/C dp0P/N7wZh9FNbfgVtj//uXRifMrTmKSmtZx4yfRP9fRtjv8uB5wdPdaxLZQ8LHW/sSZ HdOmCQ8vYD3ahXIQ68OfvVG0uxQsr+oBlSimzYBVV6JlkUPW2PMhQOLFFhALGi4nSZ3s 2tJA== X-Gm-Message-State: AOAM533sA5Erx3RNFkNnZ3Lw7nlZv4QgwSBZglWcUpUMkjjzbVNwz9FQ J2z3gNF/dZmZDX8xrsbq3Y0n1JSrwi0= X-Google-Smtp-Source: ABdhPJxj3Zgx6kBmcG46J/FBzB8K7gfM4rRlkvZCQPYM18vDZKqGIfGuAKmBH31JoGFcFH+XXNtH8w== X-Received: by 2002:a1c:9d0c:: with SMTP id g12mr40679856wme.107.1593988922217; Sun, 05 Jul 2020 15:42:02 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v2 3/5] hw/i2c: Rename i2c_realize_and_unref() as i2c_slave_realize_and_unref() Date: Mon, 6 Jul 2020 00:41:52 +0200 Message-Id: <20200705224154.16917-4-f4bug@amsat.org> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20200705224154.16917-1-f4bug@amsat.org> References: <20200705224154.16917-1-f4bug@amsat.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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::342; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-wm1-x342.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: 0 X-Spam_score: 0.0 X-Spam_bar: / X-Spam_report: (0.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=1, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Corey Minyard , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Peter Maydell , Andrew Jeffery , Markus Armbruster , qemu-arm@nongnu.org, qemu-ppc@nongnu.org, Joel Stanley , Jan Kiszka , David Gibson , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) The other i2c functions are called i2c_slave_FOO(). Rename as i2c_slave_realize_and_unref() to be consistent. Suggested-by: Markus Armbruster Reviewed-by: Corey Minyard Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- include/hw/i2c/i2c.h | 2 +- hw/arm/aspeed.c | 10 ++++++---- hw/i2c/core.c | 6 +++--- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/include/hw/i2c/i2c.h b/include/hw/i2c/i2c.h index 18efc668f1..cb7211f027 100644 --- a/include/hw/i2c/i2c.h +++ b/include/hw/i2c/i2c.h @@ -81,7 +81,7 @@ uint8_t i2c_recv(I2CBus *bus); =20 I2CSlave *i2c_slave_new(const char *name, uint8_t addr); DeviceState *i2c_create_slave(I2CBus *bus, const char *name, uint8_t addr); -bool i2c_realize_and_unref(DeviceState *dev, I2CBus *bus, Error **errp); +bool i2c_slave_realize_and_unref(I2CSlave *dev, I2CBus *bus, Error **errp); =20 /* lm832x.c */ void lm832x_key_event(DeviceState *dev, int key, int state); diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c index 54ca36e0b6..ed14e79f57 100644 --- a/hw/arm/aspeed.c +++ b/hw/arm/aspeed.c @@ -515,8 +515,9 @@ static void witherspoon_bmc_i2c_init(AspeedMachineState= *bmc) /* Bus 3: TODO dps310@76 */ dev =3D DEVICE(i2c_slave_new(TYPE_PCA9552, 0x60)); qdev_prop_set_string(dev, "description", "pca1"); - i2c_realize_and_unref(dev, aspeed_i2c_get_bus(&soc->i2c, 3), - &error_fatal); + i2c_slave_realize_and_unref(I2C_SLAVE(dev), + aspeed_i2c_get_bus(&soc->i2c, 3), + &error_fatal); =20 i2c_create_slave(aspeed_i2c_get_bus(&soc->i2c, 4), "tmp423", 0x4c); i2c_create_slave(aspeed_i2c_get_bus(&soc->i2c, 5), "tmp423", 0x4c); @@ -533,8 +534,9 @@ static void witherspoon_bmc_i2c_init(AspeedMachineState= *bmc) eeprom_buf); dev =3D DEVICE(i2c_slave_new(TYPE_PCA9552, 0x60)); qdev_prop_set_string(dev, "description", "pca0"); - i2c_realize_and_unref(dev, aspeed_i2c_get_bus(&soc->i2c, 11), - &error_fatal); + i2c_slave_realize_and_unref(I2C_SLAVE(dev), + aspeed_i2c_get_bus(&soc->i2c, 11), + &error_fatal); /* Bus 11: TODO ucd90160@64 */ } =20 diff --git a/hw/i2c/core.c b/hw/i2c/core.c index 144786f17a..f81601a5b9 100644 --- a/hw/i2c/core.c +++ b/hw/i2c/core.c @@ -276,16 +276,16 @@ I2CSlave *i2c_slave_new(const char *name, uint8_t add= r) return I2C_SLAVE(dev); } =20 -bool i2c_realize_and_unref(DeviceState *dev, I2CBus *bus, Error **errp) +bool i2c_slave_realize_and_unref(I2CSlave *dev, I2CBus *bus, Error **errp) { - return qdev_realize_and_unref(dev, &bus->qbus, errp); + return qdev_realize_and_unref(&dev->qdev, &bus->qbus, errp); } =20 DeviceState *i2c_create_slave(I2CBus *bus, const char *name, uint8_t addr) { I2CSlave *dev =3D i2c_slave_new(name, addr); =20 - i2c_realize_and_unref(DEVICE(dev), bus, &error_fatal); + i2c_slave_realize_and_unref(dev, bus, &error_fatal); =20 return DEVICE(dev); } --=20 2.21.3 From nobody Tue May 7 04:30:10 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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 ARC-Seal: i=1; a=rsa-sha256; t=1593989181; cv=none; d=zohomail.com; s=zohoarc; b=PYilpV22X5igoz1Y3/CBNGuldFb0Xn83HS+TqCCXjSe+W41yZjCqVJ7O0lCfWi0rcEtJK9GQYIf1pZKPqHQNO5LIAR72X+2qjr/U25YLOyYGOCNQNGBCX2vzYAbjcqirRYTrzGwwLXmiUyVE6djCa0tp7TN5K0hUQfGm6Oj6a4k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1593989181; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=zNOqrjVEJtR9iKe18RTGbM86vwArMWFzrQdWrPE495s=; b=CzLt9Is0S00CJsGnHt6axfkc4Bvl86W1X6uYjoPGCeWMs6JTwKqOATXG/Cg9EBUPpAsFKxPO1iD5JSl0gjwEdvTe/ccV2z6JBV/6dx78wZbbGhgZAlRk8nSIq9mbqjyNW7gceks8x6uCRwVyx1ExyFbvYlTWZckrW3IkG+tBLLo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1593989181595482.5359285675745; Sun, 5 Jul 2020 15:46:21 -0700 (PDT) Received: from localhost ([::1]:54728 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jsDOu-0002d2-A8 for importer@patchew.org; Sun, 05 Jul 2020 18:46:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42552) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jsDKr-0004X4-QJ; Sun, 05 Jul 2020 18:42:09 -0400 Received: from mail-wr1-x443.google.com ([2a00:1450:4864:20::443]:46990) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jsDKo-0002iR-Eb; Sun, 05 Jul 2020 18:42:09 -0400 Received: by mail-wr1-x443.google.com with SMTP id r12so38875196wrj.13; Sun, 05 Jul 2020 15:42:05 -0700 (PDT) Received: from localhost.localdomain (1.red-83-51-162.dynamicip.rima-tde.net. [83.51.162.1]) by smtp.gmail.com with ESMTPSA id v6sm9151467wrr.85.2020.07.05.15.42.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Jul 2020 15:42:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=zNOqrjVEJtR9iKe18RTGbM86vwArMWFzrQdWrPE495s=; b=JOQKjcS8HAMBrNOJWXeoioTRTvhIn1GFtcyXnOgRsV/gYNvTjgfU6oEexVudzIf3XD 4jEplpGSLTRCNr0+6ZWdEWXn701iw2Rh34u9SUhXR7W4djft85ZP0IacBfUVXhzEIa42 Qpt0at8bxWUmQZh5kzoTnM+aNh8RKvVQcq89+VROY7IBK2Qz5fuxFuM1LiomdzHfgcyj toB9mDLM0lQ7F/KrivBGit3bcwm/rwZx8WHs1PRvOmg0aCuVvzMxOxI9Y/UEDV6L6tG0 yZZHEcMuQ2FP9yH4vx4boOSUFa7+12Rwe/wWfcwdLl/3ZIftj1mGCEz7piNkkjwjYr9q eoyQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=zNOqrjVEJtR9iKe18RTGbM86vwArMWFzrQdWrPE495s=; b=VrphJBZ4CFAVgKEp6Uhi9NhOnuMy34vJNpKkurCyaJyt9VUCsKPqrwYrotPQv+6RKi 5R//1wusxfbNAE42Ul5x5ev8AMRDvBKUcz6KONRIQujYEmk9/QMDqrbj5bix3m5cMaZ0 +dodXB0W2Mv8NwxLKcQqx9XDpiZGc7jJ3qwhPK3fH9klM1xggHx6lQrtqI8KV/hfGwz8 JvcDaJR/Qjd/xtXLDVNqeOfE8TaEe2P9FI19vi13CoqdW1e2wDwQiuJ9EdlTKF1EcmoR DoOTRYEG2gt4AH4bYCFs/NJJQR4CkWnnWNxkhEUdYQx5M/MopKLvbXDf1N6/bzwAMCcg jDMg== X-Gm-Message-State: AOAM533xFwUv0q6tqw6UmPfVDWrqRysiUScRCE8kyX4HwX+ZF6KQpOJL Zdm+mmIkQGccRkC1bEYPuiQfBhQVQJM= X-Google-Smtp-Source: ABdhPJyyA6tL/OwCWkVgvUaEt6czdRyrxN/vERxdefcy9MkmMmVFKN/mqhjrUWUsVqn69wRo/Za3aw== X-Received: by 2002:adf:f9c8:: with SMTP id w8mr45077608wrr.354.1593988923818; Sun, 05 Jul 2020 15:42:03 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v2 4/5] hw/i2c: Rename i2c_create_slave() as i2c_slave_create_simple() Date: Mon, 6 Jul 2020 00:41:53 +0200 Message-Id: <20200705224154.16917-5-f4bug@amsat.org> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20200705224154.16917-1-f4bug@amsat.org> References: <20200705224154.16917-1-f4bug@amsat.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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::443; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-wr1-x443.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: 0 X-Spam_score: 0.0 X-Spam_bar: / X-Spam_report: (0.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=1, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Corey Minyard , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Peter Maydell , Andrew Jeffery , Markus Armbruster , qemu-arm@nongnu.org, qemu-ppc@nongnu.org, Joel Stanley , Jan Kiszka , David Gibson , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) We use "create_simple" names for functions that allocate, initialize, configure and realize device objects: pci_create_simple(), isa_create_simple(), usb_create_simple(). For consistency, rename i2c_create_slave() as i2c_slave_create_simple(). Since we have to update all the callers, also let it return a I2CSlave object. Suggested-by: Markus Armbruster Reviewed-by: Corey Minyard Reviewed-by: Markus Armbruster Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- include/hw/i2c/i2c.h | 2 +- hw/arm/aspeed.c | 58 ++++++++++++++++++++++---------------------- hw/arm/musicpal.c | 4 +-- hw/arm/nseries.c | 8 +++--- hw/arm/pxa2xx.c | 5 ++-- hw/arm/realview.c | 2 +- hw/arm/spitz.c | 4 +-- hw/arm/stellaris.c | 2 +- hw/arm/tosa.c | 2 +- hw/arm/versatilepb.c | 2 +- hw/arm/vexpress.c | 2 +- hw/arm/z2.c | 4 +-- hw/display/sii9022.c | 2 +- hw/i2c/core.c | 6 ++--- hw/ppc/e500.c | 2 +- hw/ppc/sam460ex.c | 2 +- 16 files changed, 54 insertions(+), 53 deletions(-) diff --git a/include/hw/i2c/i2c.h b/include/hw/i2c/i2c.h index cb7211f027..c533058998 100644 --- a/include/hw/i2c/i2c.h +++ b/include/hw/i2c/i2c.h @@ -80,7 +80,7 @@ int i2c_send(I2CBus *bus, uint8_t data); uint8_t i2c_recv(I2CBus *bus); =20 I2CSlave *i2c_slave_new(const char *name, uint8_t addr); -DeviceState *i2c_create_slave(I2CBus *bus, const char *name, uint8_t addr); +I2CSlave *i2c_slave_create_simple(I2CBus *bus, const char *name, uint8_t a= ddr); bool i2c_slave_realize_and_unref(I2CSlave *dev, I2CBus *bus, Error **errp); =20 /* lm832x.c */ diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c index ed14e79f57..5fa95f0f02 100644 --- a/hw/arm/aspeed.c +++ b/hw/arm/aspeed.c @@ -385,14 +385,14 @@ static void palmetto_bmc_i2c_init(AspeedMachineState = *bmc) =20 /* The palmetto platform expects a ds3231 RTC but a ds1338 is * enough to provide basic RTC features. Alarms will be missing */ - i2c_create_slave(aspeed_i2c_get_bus(&soc->i2c, 0), "ds1338", 0x68); + i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 0), "ds1338", 0x= 68); =20 smbus_eeprom_init_one(aspeed_i2c_get_bus(&soc->i2c, 0), 0x50, eeprom_buf); =20 /* add a TMP423 temperature sensor */ - dev =3D i2c_create_slave(aspeed_i2c_get_bus(&soc->i2c, 2), - "tmp423", 0x4c); + dev =3D DEVICE(i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 2= ), + "tmp423", 0x4c)); object_property_set_int(OBJECT(dev), 31000, "temperature0", &error_abo= rt); object_property_set_int(OBJECT(dev), 28000, "temperature1", &error_abo= rt); object_property_set_int(OBJECT(dev), 20000, "temperature2", &error_abo= rt); @@ -408,12 +408,12 @@ static void ast2500_evb_i2c_init(AspeedMachineState *= bmc) eeprom_buf); =20 /* The AST2500 EVB expects a LM75 but a TMP105 is compatible */ - i2c_create_slave(aspeed_i2c_get_bus(&soc->i2c, 7), + i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 7), TYPE_TMP105, 0x4d); =20 /* The AST2500 EVB does not have an RTC. Let's pretend that one is * plugged on the I2C bus header */ - i2c_create_slave(aspeed_i2c_get_bus(&soc->i2c, 11), "ds1338", 0x32); + i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 11), "ds1338", 0= x32); } =20 static void ast2600_evb_i2c_init(AspeedMachineState *bmc) @@ -428,36 +428,36 @@ static void romulus_bmc_i2c_init(AspeedMachineState *= bmc) =20 /* The romulus board expects Epson RX8900 I2C RTC but a ds1338 is * good enough */ - i2c_create_slave(aspeed_i2c_get_bus(&soc->i2c, 11), "ds1338", 0x32); + i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 11), "ds1338", 0= x32); } =20 static void swift_bmc_i2c_init(AspeedMachineState *bmc) { AspeedSoCState *soc =3D &bmc->soc; =20 - i2c_create_slave(aspeed_i2c_get_bus(&soc->i2c, 3), "pca9552", 0x60); + i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 3), "pca9552", 0= x60); =20 /* The swift board expects a TMP275 but a TMP105 is compatible */ - i2c_create_slave(aspeed_i2c_get_bus(&soc->i2c, 7), "tmp105", 0x48); + i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 7), "tmp105", 0x= 48); /* The swift board expects a pca9551 but a pca9552 is compatible */ - i2c_create_slave(aspeed_i2c_get_bus(&soc->i2c, 7), "pca9552", 0x60); + i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 7), "pca9552", 0= x60); =20 /* The swift board expects an Epson RX8900 RTC but a ds1338 is compati= ble */ - i2c_create_slave(aspeed_i2c_get_bus(&soc->i2c, 8), "ds1338", 0x32); - i2c_create_slave(aspeed_i2c_get_bus(&soc->i2c, 8), "pca9552", 0x60); + i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 8), "ds1338", 0x= 32); + i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 8), "pca9552", 0= x60); =20 - i2c_create_slave(aspeed_i2c_get_bus(&soc->i2c, 9), "tmp423", 0x4c); + i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 9), "tmp423", 0x= 4c); /* The swift board expects a pca9539 but a pca9552 is compatible */ - i2c_create_slave(aspeed_i2c_get_bus(&soc->i2c, 9), "pca9552", 0x74); + i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 9), "pca9552", 0= x74); =20 - i2c_create_slave(aspeed_i2c_get_bus(&soc->i2c, 10), "tmp423", 0x4c); + i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 10), "tmp423", 0= x4c); /* The swift board expects a pca9539 but a pca9552 is compatible */ - i2c_create_slave(aspeed_i2c_get_bus(&soc->i2c, 10), "pca9552", + i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 10), "pca9552", 0x74); =20 /* The swift board expects a TMP275 but a TMP105 is compatible */ - i2c_create_slave(aspeed_i2c_get_bus(&soc->i2c, 12), "tmp105", 0x48); - i2c_create_slave(aspeed_i2c_get_bus(&soc->i2c, 12), "tmp105", 0x4a); + i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 12), "tmp105", 0= x48); + i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 12), "tmp105", 0= x4a); } =20 static void sonorapass_bmc_i2c_init(AspeedMachineState *bmc) @@ -465,8 +465,8 @@ static void sonorapass_bmc_i2c_init(AspeedMachineState = *bmc) AspeedSoCState *soc =3D &bmc->soc; =20 /* bus 2 : */ - i2c_create_slave(aspeed_i2c_get_bus(&soc->i2c, 2), "tmp105", 0x48); - i2c_create_slave(aspeed_i2c_get_bus(&soc->i2c, 2), "tmp105", 0x49); + i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 2), "tmp105", 0x= 48); + i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 2), "tmp105", 0x= 49); /* bus 2 : pca9546 @ 0x73 */ =20 /* bus 3 : pca9548 @ 0x70 */ @@ -476,21 +476,21 @@ static void sonorapass_bmc_i2c_init(AspeedMachineStat= e *bmc) smbus_eeprom_init_one(aspeed_i2c_get_bus(&soc->i2c, 4), 0x54, eeprom4_54); /* PCA9539 @ 0x76, but PCA9552 is compatible */ - i2c_create_slave(aspeed_i2c_get_bus(&soc->i2c, 4), "pca9552", 0x76); + i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 4), "pca9552", 0= x76); /* PCA9539 @ 0x77, but PCA9552 is compatible */ - i2c_create_slave(aspeed_i2c_get_bus(&soc->i2c, 4), "pca9552", 0x77); + i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 4), "pca9552", 0= x77); =20 /* bus 6 : */ - i2c_create_slave(aspeed_i2c_get_bus(&soc->i2c, 6), "tmp105", 0x48); - i2c_create_slave(aspeed_i2c_get_bus(&soc->i2c, 6), "tmp105", 0x49); + i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 6), "tmp105", 0x= 48); + i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 6), "tmp105", 0x= 49); /* bus 6 : pca9546 @ 0x73 */ =20 /* bus 8 : */ uint8_t *eeprom8_56 =3D g_malloc0(8 * 1024); smbus_eeprom_init_one(aspeed_i2c_get_bus(&soc->i2c, 8), 0x56, eeprom8_56); - i2c_create_slave(aspeed_i2c_get_bus(&soc->i2c, 8), "pca9552", 0x60); - i2c_create_slave(aspeed_i2c_get_bus(&soc->i2c, 8), "pca9552", 0x61); + i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 8), "pca9552", 0= x60); + i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 8), "pca9552", 0= x61); /* bus 8 : adc128d818 @ 0x1d */ /* bus 8 : adc128d818 @ 0x1f */ =20 @@ -519,16 +519,16 @@ static void witherspoon_bmc_i2c_init(AspeedMachineSta= te *bmc) aspeed_i2c_get_bus(&soc->i2c, 3), &error_fatal); =20 - i2c_create_slave(aspeed_i2c_get_bus(&soc->i2c, 4), "tmp423", 0x4c); - i2c_create_slave(aspeed_i2c_get_bus(&soc->i2c, 5), "tmp423", 0x4c); + i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 4), "tmp423", 0x= 4c); + i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 5), "tmp423", 0x= 4c); =20 /* The Witherspoon expects a TMP275 but a TMP105 is compatible */ - i2c_create_slave(aspeed_i2c_get_bus(&soc->i2c, 9), TYPE_TMP105, + i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 9), TYPE_TMP105, 0x4a); =20 /* The witherspoon board expects Epson RX8900 I2C RTC but a ds1338 is * good enough */ - i2c_create_slave(aspeed_i2c_get_bus(&soc->i2c, 11), "ds1338", 0x32); + i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 11), "ds1338", 0= x32); =20 smbus_eeprom_init_one(aspeed_i2c_get_bus(&soc->i2c, 11), 0x51, eeprom_buf); diff --git a/hw/arm/musicpal.c b/hw/arm/musicpal.c index 394a3345bd..bf7bd28b94 100644 --- a/hw/arm/musicpal.c +++ b/hw/arm/musicpal.c @@ -1584,7 +1584,7 @@ static void musicpal_init(MachineState *machine) DeviceState *i2c_dev; DeviceState *lcd_dev; DeviceState *key_dev; - DeviceState *wm8750_dev; + I2CSlave *wm8750_dev; SysBusDevice *s; I2CBus *i2c; int i; @@ -1687,7 +1687,7 @@ static void musicpal_init(MachineState *machine) qdev_connect_gpio_out(key_dev, i, qdev_get_gpio_in(dev, i + 15)); } =20 - wm8750_dev =3D i2c_create_slave(i2c, TYPE_WM8750, MP_WM_ADDR); + wm8750_dev =3D i2c_slave_create_simple(i2c, TYPE_WM8750, MP_WM_ADDR); dev =3D qdev_new(TYPE_MV88W8618_AUDIO); s =3D SYS_BUS_DEVICE(dev); object_property_set_link(OBJECT(dev), OBJECT(wm8750_dev), diff --git a/hw/arm/nseries.c b/hw/arm/nseries.c index 428a2a2c5a..e48092ca04 100644 --- a/hw/arm/nseries.c +++ b/hw/arm/nseries.c @@ -215,7 +215,7 @@ static void n8x0_i2c_setup(struct n800_s *s) I2CBus *i2c =3D omap_i2c_bus(s->mpu->i2c[0]); =20 /* Attach a menelaus PM chip */ - dev =3D i2c_create_slave(i2c, "twl92230", N8X0_MENELAUS_ADDR); + dev =3D DEVICE(i2c_slave_create_simple(i2c, "twl92230", N8X0_MENELAUS_= ADDR)); qdev_connect_gpio_out(dev, 3, qdev_get_gpio_in(s->mpu->ih[0], OMAP_INT_24XX_SYS_NIRQ)); @@ -224,7 +224,7 @@ static void n8x0_i2c_setup(struct n800_s *s) qemu_register_powerdown_notifier(&n8x0_system_powerdown_notifier); =20 /* Attach a TMP105 PM chip (A0 wired to ground) */ - dev =3D i2c_create_slave(i2c, TYPE_TMP105, N8X0_TMP105_ADDR); + dev =3D DEVICE(i2c_slave_create_simple(i2c, TYPE_TMP105, N8X0_TMP105_A= DDR)); qdev_connect_gpio_out(dev, 0, tmp_irq); } =20 @@ -416,8 +416,8 @@ static void n810_kbd_setup(struct n800_s *s) =20 /* Attach the LM8322 keyboard to the I2C bus, * should happen in n8x0_i2c_setup and s->kbd be initialised here. */ - s->kbd =3D i2c_create_slave(omap_i2c_bus(s->mpu->i2c[0]), - "lm8323", N810_LM8323_ADDR); + s->kbd =3D DEVICE(i2c_slave_create_simple(omap_i2c_bus(s->mpu->i2c[0]), + "lm8323", N810_LM8323_ADDR)); qdev_connect_gpio_out(s->kbd, 0, kbd_irq); } =20 diff --git a/hw/arm/pxa2xx.c b/hw/arm/pxa2xx.c index f104a33463..6203c4cfe0 100644 --- a/hw/arm/pxa2xx.c +++ b/hw/arm/pxa2xx.c @@ -1522,8 +1522,9 @@ PXA2xxI2CState *pxa2xx_i2c_init(hwaddr base, s =3D PXA2XX_I2C(i2c_dev); /* FIXME: Should the slave device really be on a separate bus? */ i2cbus =3D i2c_init_bus(dev, "dummy"); - dev =3D i2c_create_slave(i2cbus, TYPE_PXA2XX_I2C_SLAVE, 0); - s->slave =3D PXA2XX_I2C_SLAVE(dev); + s->slave =3D PXA2XX_I2C_SLAVE(i2c_slave_create_simple(i2cbus, + TYPE_PXA2XX_I2C_SL= AVE, + 0)); s->slave->host =3D s; =20 return s; diff --git a/hw/arm/realview.c b/hw/arm/realview.c index b6c0a1adb9..e105b6509f 100644 --- a/hw/arm/realview.c +++ b/hw/arm/realview.c @@ -285,7 +285,7 @@ static void realview_init(MachineState *machine, =20 dev =3D sysbus_create_simple(TYPE_VERSATILE_I2C, 0x10002000, NULL); i2c =3D (I2CBus *)qdev_get_child_bus(dev, "i2c"); - i2c_create_slave(i2c, "ds1338", 0x68); + i2c_slave_create_simple(i2c, "ds1338", 0x68); =20 /* Memory map for RealView Emulation Baseboard: */ /* 0x10000000 System registers. */ diff --git a/hw/arm/spitz.c b/hw/arm/spitz.c index f020aff974..7ac8254aa6 100644 --- a/hw/arm/spitz.c +++ b/hw/arm/spitz.c @@ -787,7 +787,7 @@ static void spitz_i2c_setup(PXA2xxState *cpu) DeviceState *wm; =20 /* Attach a WM8750 to the bus */ - wm =3D i2c_create_slave(bus, TYPE_WM8750, 0); + wm =3D DEVICE(i2c_slave_create_simple(bus, TYPE_WM8750, 0)); =20 spitz_wm8750_addr(wm, 0, 0); qdev_connect_gpio_out(cpu->gpio, SPITZ_GPIO_WM, @@ -802,7 +802,7 @@ static void spitz_i2c_setup(PXA2xxState *cpu) static void spitz_akita_i2c_setup(PXA2xxState *cpu) { /* Attach a Max7310 to Akita I2C bus. */ - i2c_create_slave(pxa2xx_i2c_bus(cpu->i2c[0]), "max7310", + i2c_slave_create_simple(pxa2xx_i2c_bus(cpu->i2c[0]), "max7310", AKITA_MAX_ADDR); } =20 diff --git a/hw/arm/stellaris.c b/hw/arm/stellaris.c index 97ef566c12..3f45550cf6 100644 --- a/hw/arm/stellaris.c +++ b/hw/arm/stellaris.c @@ -1380,7 +1380,7 @@ static void stellaris_init(MachineState *ms, stellari= s_board_info *board) qdev_get_gpio_in(nvic, 8)); i2c =3D (I2CBus *)qdev_get_child_bus(dev, "i2c"); if (board->peripherals & BP_OLED_I2C) { - i2c_create_slave(i2c, "ssd0303", 0x3d); + i2c_slave_create_simple(i2c, "ssd0303", 0x3d); } } =20 diff --git a/hw/arm/tosa.c b/hw/arm/tosa.c index 5dee2d76c6..8c1ee0cdd1 100644 --- a/hw/arm/tosa.c +++ b/hw/arm/tosa.c @@ -206,7 +206,7 @@ static uint8_t tosa_dac_recv(I2CSlave *s) static void tosa_tg_init(PXA2xxState *cpu) { I2CBus *bus =3D pxa2xx_i2c_bus(cpu->i2c[0]); - i2c_create_slave(bus, TYPE_TOSA_DAC, DAC_BASE); + i2c_slave_create_simple(bus, TYPE_TOSA_DAC, DAC_BASE); ssi_create_slave(cpu->ssp[1], "tosa-ssp"); } =20 diff --git a/hw/arm/versatilepb.c b/hw/arm/versatilepb.c index e596b8170f..34709afb32 100644 --- a/hw/arm/versatilepb.c +++ b/hw/arm/versatilepb.c @@ -317,7 +317,7 @@ static void versatile_init(MachineState *machine, int b= oard_id) =20 dev =3D sysbus_create_simple(TYPE_VERSATILE_I2C, 0x10002000, NULL); i2c =3D (I2CBus *)qdev_get_child_bus(dev, "i2c"); - i2c_create_slave(i2c, "ds1338", 0x68); + i2c_slave_create_simple(i2c, "ds1338", 0x68); =20 /* Add PL041 AACI Interface to the LM4549 codec */ pl041 =3D qdev_new("pl041"); diff --git a/hw/arm/vexpress.c b/hw/arm/vexpress.c index 5bf9cff8a8..4f6a2b6ddd 100644 --- a/hw/arm/vexpress.c +++ b/hw/arm/vexpress.c @@ -642,7 +642,7 @@ static void vexpress_common_init(MachineState *machine) =20 dev =3D sysbus_create_simple(TYPE_VERSATILE_I2C, map[VE_SERIALDVI], NU= LL); i2c =3D (I2CBus *)qdev_get_child_bus(dev, "i2c"); - i2c_create_slave(i2c, "sii9022", 0x39); + i2c_slave_create_simple(i2c, "sii9022", 0x39); =20 sysbus_create_simple("pl031", map[VE_RTC], pic[4]); /* RTC */ =20 diff --git a/hw/arm/z2.c b/hw/arm/z2.c index e1f22f5868..9a9bbc653b 100644 --- a/hw/arm/z2.c +++ b/hw/arm/z2.c @@ -330,8 +330,8 @@ static void z2_init(MachineState *machine) type_register_static(&aer915_info); z2_lcd =3D ssi_create_slave(mpu->ssp[1], TYPE_ZIPIT_LCD); bus =3D pxa2xx_i2c_bus(mpu->i2c[0]); - i2c_create_slave(bus, TYPE_AER915, 0x55); - wm =3D i2c_create_slave(bus, TYPE_WM8750, 0x1b); + i2c_slave_create_simple(bus, TYPE_AER915, 0x55); + wm =3D DEVICE(i2c_slave_create_simple(bus, TYPE_WM8750, 0x1b)); mpu->i2s->opaque =3D wm; mpu->i2s->codec_out =3D wm8750_dac_dat; mpu->i2s->codec_in =3D wm8750_adc_dat; diff --git a/hw/display/sii9022.c b/hw/display/sii9022.c index 0710ce9de5..3b82a8567f 100644 --- a/hw/display/sii9022.c +++ b/hw/display/sii9022.c @@ -161,7 +161,7 @@ static void sii9022_realize(DeviceState *dev, Error **e= rrp) I2CBus *bus; =20 bus =3D I2C_BUS(qdev_get_parent_bus(dev)); - i2c_create_slave(bus, TYPE_I2CDDC, 0x50); + i2c_slave_create_simple(bus, TYPE_I2CDDC, 0x50); } =20 static void sii9022_class_init(ObjectClass *klass, void *data) diff --git a/hw/i2c/core.c b/hw/i2c/core.c index f81601a5b9..21ec52ac5a 100644 --- a/hw/i2c/core.c +++ b/hw/i2c/core.c @@ -281,13 +281,13 @@ bool i2c_slave_realize_and_unref(I2CSlave *dev, I2CBu= s *bus, Error **errp) return qdev_realize_and_unref(&dev->qdev, &bus->qbus, errp); } =20 -DeviceState *i2c_create_slave(I2CBus *bus, const char *name, uint8_t addr) +I2CSlave *i2c_slave_create_simple(I2CBus *bus, const char *name, uint8_t a= ddr) { I2CSlave *dev =3D i2c_slave_new(name, addr); =20 - i2c_slave_realize_and_unref(dev, bus, &error_fatal); + i2c_slave_realize_and_unref(dev, bus, &error_abort); =20 - return DEVICE(dev); + return dev; } =20 static void i2c_slave_class_init(ObjectClass *klass, void *data) diff --git a/hw/ppc/e500.c b/hw/ppc/e500.c index 51bf95b303..67924915ae 100644 --- a/hw/ppc/e500.c +++ b/hw/ppc/e500.c @@ -944,7 +944,7 @@ void ppce500_init(MachineState *machine) memory_region_add_subregion(ccsr_addr_space, MPC8544_I2C_REGS_OFFSET, sysbus_mmio_get_region(s, 0)); i2c =3D (I2CBus *)qdev_get_child_bus(dev, "i2c"); - i2c_create_slave(i2c, "ds1338", RTC_REGS_OFFSET); + i2c_slave_create_simple(i2c, "ds1338", RTC_REGS_OFFSET); =20 =20 /* General Utility device */ diff --git a/hw/ppc/sam460ex.c b/hw/ppc/sam460ex.c index 1a106a68de..1702344c46 100644 --- a/hw/ppc/sam460ex.c +++ b/hw/ppc/sam460ex.c @@ -339,7 +339,7 @@ static void sam460ex_init(MachineState *machine) spd_data[20] =3D 4; /* SO-DIMM module */ smbus_eeprom_init_one(i2c, 0x50, spd_data); /* RTC */ - i2c_create_slave(i2c, "m41t80", 0x68); + i2c_slave_create_simple(i2c, "m41t80", 0x68); =20 dev =3D sysbus_create_simple(TYPE_PPC4xx_I2C, 0x4ef600800, uic[0][3]); =20 --=20 2.21.3 From nobody Tue May 7 04:30:10 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=amsat.org ARC-Seal: i=1; a=rsa-sha256; t=1593989111; cv=none; d=zohomail.com; s=zohoarc; b=IBAvxd1M10JsAQ0sWpDCgC3ciDK5Wi0WoPm1Zzdfrzfs2cLpIdDhifsmBVnwNwwzfaIVi93Spq0p/oj+rxuZgo/mATlR7HHbujt5cDyLiyMFKOC4+rwyeiD89mQSQ+0vbegekUy5d7Gx3hdBN4Ljj64GyyZO4E3vMc4uO52QWTc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1593989111; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=03JSJVToJcQcJSvpPMYHIqI0Rkyfucv4Bhq/3adSmHA=; b=JxmB5wbjZE/hp2hYLNITFX/ihSh/ht9iL4IqRIT31KdHhw2Q0wt5P9Abv+K97MPnRUNr43zVEu6A/bRTf2kvvcGg7CA4bH3kggNj7qpQ6PQ4u5FjqWJxGfVWofNjKB13xA60AzCgeMjylXeZb3Ncu1RoJ5C1uXyJZKuNxFFOkhc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1593989111361674.7855059703834; Sun, 5 Jul 2020 15:45:11 -0700 (PDT) Received: from localhost ([::1]:52616 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jsDNm-0001df-5N for importer@patchew.org; Sun, 05 Jul 2020 18:45:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42550) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jsDKr-0004Vf-BZ; Sun, 05 Jul 2020 18:42:09 -0400 Received: from mail-wr1-x436.google.com ([2a00:1450:4864:20::436]:43212) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jsDKp-0002id-Mp; Sun, 05 Jul 2020 18:42:09 -0400 Received: by mail-wr1-x436.google.com with SMTP id j4so36515364wrp.10; Sun, 05 Jul 2020 15:42:06 -0700 (PDT) Received: from localhost.localdomain (1.red-83-51-162.dynamicip.rima-tde.net. [83.51.162.1]) by smtp.gmail.com with ESMTPSA id v6sm9151467wrr.85.2020.07.05.15.42.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Jul 2020 15:42:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=03JSJVToJcQcJSvpPMYHIqI0Rkyfucv4Bhq/3adSmHA=; b=Pa64QCEPjloJBqohG2Ldz2+UkkDYfCROFrWvBArUohBlqeVQ/OT7esXN2fXiU01xnD oH88cL+mwwjWkta9hkav9YmNURTz7nyQLt4XJJ3uI1NdxNTj3tpEcN+xzCUSrXQY5F+f hjk1A69MxVRPvpRxFEYRoiv95M7tVHdMC6jCvaR54o3Y32Z7WjRcEzFXTJd+483yDTXr 2bgfjRX9c1++Nz7rSV5bRl2WiUt7t1ahmLYDeCIzj8vHuk/TjR4F+rP8beIZKQyb8EPw MJr7g3h8hTxy58TTfbslIiX+CkWcsIy7FyzEf69Vns4s/RrsgNbuSAxRMkz255XU4UgH fwUA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=03JSJVToJcQcJSvpPMYHIqI0Rkyfucv4Bhq/3adSmHA=; b=W5UX2FDaLe4shq3MFVCYwljSvBte4bKNzTIut2rEDTODqxgx83GJcUvO8BQ6eqbVXZ NYHNk44rWJjQ8i162aJfjyZRrY+pOeTVHWl87hbRlae07seO325kKEQ9rrkPdcIFlsHP bQQWjzsi0svvNMKc0u8bTsJIqzRVeP7Up2zAlzHMaxxcI0B5RarUNadKf8iU92ajrqkE iveUW6sX8LedSr5gM62K7eyKMsnnzOM4P+eL1jW6pj3PD3OCicdG22nbhI1NnCk4oAQ1 bkYMhPcL58AhgXCI7BjILm8Fb/2WEfT08NEUERlV9YfwrJbMPyjUG8NidsCeBhWez0Rt 7nkA== X-Gm-Message-State: AOAM530jINHMF82+WUtk1OjlDuYn8TP3eZM1qzWL+e2/YsP55dKn6hVw 4+u/gCkR6+k6PKMT5gofiIjd95V50bs= X-Google-Smtp-Source: ABdhPJwkpl10haJP9vxZaL3uCZqLj6afrDjEtqaEPkWD8uG2pYPtTIPgqvyABZQdQUYimw7pb5vF9g== X-Received: by 2002:adf:e948:: with SMTP id m8mr47097487wrn.398.1593988925207; Sun, 05 Jul 2020 15:42:05 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v2 5/5] hw/i2c: Document the I2C qdev helpers Date: Mon, 6 Jul 2020 00:41:54 +0200 Message-Id: <20200705224154.16917-6-f4bug@amsat.org> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20200705224154.16917-1-f4bug@amsat.org> References: <20200705224154.16917-1-f4bug@amsat.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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::436; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-wr1-x436.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: 0 X-Spam_score: 0.0 X-Spam_bar: / X-Spam_report: (0.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=1, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Corey Minyard , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Peter Maydell , Andrew Jeffery , Markus Armbruster , qemu-arm@nongnu.org, qemu-ppc@nongnu.org, Joel Stanley , Jan Kiszka , David Gibson , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) In commit d88c42ff2c we added new prototype but neglected to add their documentation. Fix that. Reported-by: Peter Maydell Reviewed-by: Corey Minyard Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Peter Maydell --- include/hw/i2c/i2c.h | 48 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/include/hw/i2c/i2c.h b/include/hw/i2c/i2c.h index c533058998..a9c030a512 100644 --- a/include/hw/i2c/i2c.h +++ b/include/hw/i2c/i2c.h @@ -79,8 +79,56 @@ int i2c_send_recv(I2CBus *bus, uint8_t *data, bool send); int i2c_send(I2CBus *bus, uint8_t data); uint8_t i2c_recv(I2CBus *bus); =20 +/** + * Create an I2C slave device on the heap. + * @name: a device type name + * @addr: I2C address of the slave when put on a bus + * + * This only initializes the device state structure and allows + * properties to be set. Type @name must exist. The device still + * needs to be realized. See qdev-core.h. + */ I2CSlave *i2c_slave_new(const char *name, uint8_t addr); + +/** + * Create and realize an I2C slave device on the heap. + * @bus: I2C bus to put it on + * @name: I2C slave device type name + * @addr: I2C address of the slave when put on a bus + * + * Create the device state structure, initialize it, put it on the + * specified @bus, and drop the reference to it (the device is realized). + */ I2CSlave *i2c_slave_create_simple(I2CBus *bus, const char *name, uint8_t a= ddr); + +/** + * Realize and and drop a reference an I2C slave device + * @dev: I2C slave device to realize + * @bus: I2C bus to put it on + * @addr: I2C address of the slave on the bus + * @errp: pointer to NULL initialized error object + * + * Returns: %true on success, %false on failure. + * + * Call 'realize' on @dev, put it on the specified @bus, and drop the + * reference to it. + * + * This function is useful if you have created @dev via qdev_new(), + * i2c_slave_new() or i2c_slave_try_new() (which take a reference to + * the device it returns to you), so that you can set properties on it + * before realizing it. If you don't need to set properties then + * i2c_slave_create_simple() is probably better (as it does the create, + * init and realize in one step). + * + * If you are embedding the I2C slave into another QOM device and + * initialized it via some variant on object_initialize_child() then + * do not use this function, because that family of functions arrange + * for the only reference to the child device to be held by the parent + * via the child<> property, and so the reference-count-drop done here + * would be incorrect. (Instead you would want i2c_slave_realize(), + * which doesn't currently exist but would be trivial to create if we + * had any code that wanted it.) + */ bool i2c_slave_realize_and_unref(I2CSlave *dev, I2CBus *bus, Error **errp); =20 /* lm832x.c */ --=20 2.21.3