From nobody Fri Apr 26 11:28:01 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=1593452419; cv=none; d=zohomail.com; s=zohoarc; b=LbQzJdbs5co2GNzWeFwVjF7OFeI2rAlcD4sqUH1fC03MZ6rX1OrnnRlbRjljLKS8SC0u6vOFVxFMRZb9ZN/P+RXOrmHN3H86YxGdDQYHxNOUiFLTMJiKz5Ss3mwrUIJu9CfFwGwnluG0Ac+EfLOdDa6TK5xBAJqq+XCmfH5DfL0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1593452419; 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=vln2Kfj4w7antPWhsHXpewUAGbLCzfNZUk7aB5CR750=; b=RxFKnGesrfaBEK5W4ETLvy8yzaUJJZ9prqhNgrt4l97TOo0OzpkRQJi5uF6aBBzIqX2yBrAUZj3YcjNH6MFang7ua4ELS+ZHAVp+r6z7juGKDcSpQh7uO21NEvnNznpMZ3dxdOI2Iz0b6OL+GilGyKzZ+8p8y5UyffTghgG+/4k= 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 1593452419827466.23283722278245; Mon, 29 Jun 2020 10:40:19 -0700 (PDT) Received: from localhost ([::1]:48034 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jpxlS-0007UM-Bw for importer@patchew.org; Mon, 29 Jun 2020 13:40:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43664) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jpxjh-0005kH-Vz; Mon, 29 Jun 2020 13:38:30 -0400 Received: from mail-ej1-x643.google.com ([2a00:1450:4864:20::643]:45529) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jpxjg-0000IC-34; Mon, 29 Jun 2020 13:38:29 -0400 Received: by mail-ej1-x643.google.com with SMTP id a1so17435140ejg.12; Mon, 29 Jun 2020 10:38:27 -0700 (PDT) Received: from x1w.redhat.com (1.red-83-51-162.dynamicip.rima-tde.net. [83.51.162.1]) by smtp.gmail.com with ESMTPSA id ce19sm216029ejb.24.2020.06.29.10.38.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jun 2020 10:38:25 -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=vln2Kfj4w7antPWhsHXpewUAGbLCzfNZUk7aB5CR750=; b=MeUno5TY/yJ25IOp9vIghwHAYXRdVC/L5TxvKUPRMfx8cIWW0+q5usP1K2cWXH/Vh1 du/aNiNcRKw7UE71I7wpb7fZXarS5LXfEcTdsK8Gu7MvSRmUkU5bupvw8Y6vpsZ2RSWJ 4JoUl0syGIspjvLxxoo8isPwuRB2kWRmXvE22AD8IiOREB0koGyMcadKgogM+4mKSeNj w5oquHzTZVokVsih5v9qhG98WYRLY5Zr3tSGhR0lxDNW/AsoVnemic7jCE1fUtHbq4CC KY9LbGW4Jr2VxGMZcgSaD1gsyBcJkGUI4v1DoP3NYPO1dBqUj7Zg0C71RLWRpTwz6br5 csEg== 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=vln2Kfj4w7antPWhsHXpewUAGbLCzfNZUk7aB5CR750=; b=OTtKVL1NUzwyAi8HDoHmsjNjF2k8McceuuQQZ5rca3fEAzXXr6mxNmSuo5B2OKCHvx 0qRchH+7yiWsPI5rXzMA3ep71c8c4jPr30vZrrHPnC39v96H0DPQbjLgezJR0QkTEB2X o98Yr3XRuVEhCCqOFnDKYmAa8X6pb7j+h6Lm6M6yRGvPCz8qkPwKn0hc4jy4eqLZzCM4 2iankc2n2d0VvBKaK/khpUk3ZB2WmFrXpfm8PuZ6WJmgEQ8JLPpuTh9WVyYcTYbmdUc8 Xospxev7MIYH9w23hsR7d6kpi4aRc37wReoKt52I6OLu44AN73kUcGlMNrzcZw/6C4E9 5LnA== X-Gm-Message-State: AOAM530GSu0M8DljfuhhbRVnyLAY/TXFgQ0iAjoKBkYW0eKJ94bmQtET BsqkDwIlAwxoGRSObuvviSQhKWZZrwQ= X-Google-Smtp-Source: ABdhPJym/s7CRhux1OvEc9gyCu5YZM57EGqySePw2Qc8iTT1NJ0BscrxtEgj+NOtZbpGvTwkb9XRBA== X-Received: by 2002:a17:906:6a4f:: with SMTP id n15mr14630874ejs.378.1593452305860; Mon, 29 Jun 2020 10:38:25 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH 1/5] hw/i2c/aspeed_i2c: Simplify aspeed_i2c_get_bus() Date: Mon, 29 Jun 2020 19:38:17 +0200 Message-Id: <20200629173821.22037-2-f4bug@amsat.org> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20200629173821.22037-1-f4bug@amsat.org> References: <20200629173821.22037-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::643; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-ej1-x643.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: Peter Maydell , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Corey Minyard , Andrew Jeffery , Markus Armbruster , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , qemu-arm@nongnu.org, qemu-ppc@nongnu.org, Joel Stanley , Jan Kiszka , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Simplify aspeed_i2c_get_bus() by using a AspeedI2CState argument. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: C=C3=A9dric Le Goater Reviewed-by: Markus Armbruster --- 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 Fri Apr 26 11:28:01 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=1593452561; cv=none; d=zohomail.com; s=zohoarc; b=Yxrb0fSQYL9KLj7H5fsncGtq2uhOnLt0O04dNpAK4lrDDYMqb64yEflCGZ/EAQBsIQcO2ecn+jTRrLCyAGEKqfD0KcXIOKE3eUUpy5EfJYbLDTwRPDw60X1W/pDLAR9UP5qn3idhGm9vA48f7pV+44fExiFk1GdypglKdsYR4p8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1593452561; 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=6cSGomOE4QTMbqeX26Zlg/Tz0PsmS6jvlXcVlbBS5jk=; b=RyGZekA6Ag4YuOTWlATrsVgn7BJLWQ2aJioNpnm6FIHCbtVBNjtaCJzy6M+5CVN5jncJqMBhRkjyCiY8xVoDUFZIRXyuZIvYGPfVerdZ4cJmJdyoUOsjPX7dtqB5ynf+JPPPAy1E5IKiSBNbYm1aZj+9LoJPJ3clyv1F9MtHt2Q= 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 1593452561938440.91041345421445; Mon, 29 Jun 2020 10:42:41 -0700 (PDT) Received: from localhost ([::1]:55742 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jpxnk-0002QJ-Nn for importer@patchew.org; Mon, 29 Jun 2020 13:42:40 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43682) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jpxjj-0005nQ-GI; Mon, 29 Jun 2020 13:38:31 -0400 Received: from mail-ej1-x641.google.com ([2a00:1450:4864:20::641]:39441) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jpxjh-0000IV-RR; Mon, 29 Jun 2020 13:38:31 -0400 Received: by mail-ej1-x641.google.com with SMTP id w6so17475668ejq.6; Mon, 29 Jun 2020 10:38:28 -0700 (PDT) Received: from x1w.redhat.com (1.red-83-51-162.dynamicip.rima-tde.net. [83.51.162.1]) by smtp.gmail.com with ESMTPSA id ce19sm216029ejb.24.2020.06.29.10.38.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jun 2020 10:38:26 -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=6cSGomOE4QTMbqeX26Zlg/Tz0PsmS6jvlXcVlbBS5jk=; b=MYoTbZy3tSOJy+RBaNTr/s68o6unK5Jg9w+yfwdUdOHKYQ0A8JCTOr3aAbfNhviUhY qUH87BKYUFQrnPrML2GzdkE1jex0nRM63rZExKsDC0WxoO3QVk6ZZ8qB+CiRI39mRjlQ 7bGUJJ+9ojSNmj1kF0FA4tbiQHiuoOq/jx1wZO92+JfHf5ZsRQ1nNIVVYbmObdN2E621 qMhnXWoppLKGueLs9fndoU2EiA5rk0zj63zukK5fY5zULlk6PbrJy/A+Njf7S6duzxEI wSbqn8TX0tJTEvUKInvELvgZ40K4s9h8g1+7G7i2KL5C2PVISXI5wBkddv6A86CKUA+/ BaNw== 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=6cSGomOE4QTMbqeX26Zlg/Tz0PsmS6jvlXcVlbBS5jk=; b=dliRD9B2EIZfMdUEFWrXhA1aAeUvIvT/sFj2o+HHCULm7sbKowxpcWHTdjtR2To64v yP+od4daSkm/tnMlkZoXucyTgptO18lCjBJ/d46lVqoPyF/Rnp3tgwTgyQDtYaPqWhoF 0LHp3mmMDTJp8pFG6J4QMaUJRWjvRmf0V4gwfJeNOQh1GHhmmsePM25A60AgCigTAbrY 6YYNlCi+pX/AuYVqJOHkKn/BIA4xwSY+qi4v3RP5SKGyZroActvhbAij/wUHMv+YcjUk iILHec5X+hLsbistzUat0a4cuWBrOUSRwlIXqUUcIZuNmQNXlQ79fRoHMNuUqHkTwgcp QV2Q== X-Gm-Message-State: AOAM532isotknkQkmrBvZwMjjtMd/MRsKAGgzdzxe/j60KGGqAFK+mF4 vlDR+i8XkBx0eaGU+IzrdqMt5wAVxpo= X-Google-Smtp-Source: ABdhPJxpCvKXibp1/JiVxLX2RNV5rM15dNzb1UWuuOCmsy+mejhyx7LPpj2NHtJHBCSO61EMgBskfA== X-Received: by 2002:a17:906:17d5:: with SMTP id u21mr15597071eje.413.1593452307332; Mon, 29 Jun 2020 10:38:27 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH 2/5] hw/i2c: Rename i2c_try_create_slave() as i2c_slave_new() Date: Mon, 29 Jun 2020 19:38:18 +0200 Message-Id: <20200629173821.22037-3-f4bug@amsat.org> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20200629173821.22037-1-f4bug@amsat.org> References: <20200629173821.22037-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::641; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-ej1-x641.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: Peter Maydell , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Corey Minyard , Andrew Jeffery , Markus Armbruster , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , qemu-arm@nongnu.org, qemu-ppc@nongnu.org, Joel Stanley , Jan Kiszka , David Gibson 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 Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Corey Minyard Reviewed-by: Markus Armbruster --- include/hw/i2c/i2c.h | 2 +- hw/arm/aspeed.c | 4 ++-- hw/i2c/core.c | 9 ++++----- 3 files changed, 7 insertions(+), 8 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..6eacb4a463 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,10 +283,9 @@ bool i2c_realize_and_unref(DeviceState *dev, I2CBus *b= us, Error **errp) =20 DeviceState *i2c_create_slave(I2CBus *bus, const char *name, uint8_t addr) { - DeviceState *dev; + DeviceState *dev =3D DEVICE(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(I2C_SLAVE(dev), bus, &error_fatal); =20 return dev; } --=20 2.21.3 From nobody Fri Apr 26 11:28:01 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=1593452550; cv=none; d=zohomail.com; s=zohoarc; b=jsMVI/XfI69hIU3e+nFNytngKsC4GZudYED28C+BqtoGb0vs/9txFrYojKZI+ojlCf9AN7mwjL+8RtojNKG8g6uYOLx4slWTQCR6s4Tzq9Z7U+AY3h9IFcg4fMcdR7FOsWfZf8vWhYtLYdrDqXDpPEvTHo9H5L6JBLwTCObpcj8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1593452550; 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=oo257JjDoIhwiqBvGiPI8EB4cn7Ei4fDeJ2qCeP5TaA=; b=VnzW1yQGV5HEHZCZwMeyRqo4joiA+WJ8VjdYjvBFcTQywOFpzuxwvJg48BLUknqU7W6f8B6utWDLamz7r+R/urlRZLbROLAX4PNkWwfXBW96ZZQPEu1/N+FQr5Aqv+sMd104Crayoq7uyq9ugzlZATwE/GQVhWKenDC2t/F1jHM= 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 1593452550942302.8945486486158; Mon, 29 Jun 2020 10:42:30 -0700 (PDT) Received: from localhost ([::1]:54524 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jpxnZ-0001sm-KC for importer@patchew.org; Mon, 29 Jun 2020 13:42:29 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43702) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jpxjk-0005qw-R8; Mon, 29 Jun 2020 13:38:32 -0400 Received: from mail-ej1-x644.google.com ([2a00:1450:4864:20::644]:33254) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jpxjj-0000Iz-2m; Mon, 29 Jun 2020 13:38:32 -0400 Received: by mail-ej1-x644.google.com with SMTP id n26so3520828ejx.0; Mon, 29 Jun 2020 10:38:30 -0700 (PDT) Received: from x1w.redhat.com (1.red-83-51-162.dynamicip.rima-tde.net. [83.51.162.1]) by smtp.gmail.com with ESMTPSA id ce19sm216029ejb.24.2020.06.29.10.38.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jun 2020 10:38:28 -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=oo257JjDoIhwiqBvGiPI8EB4cn7Ei4fDeJ2qCeP5TaA=; b=lP8vdaStVSuz39ejHkPGsHXCqdWUn/CMUHYK62NVHar1l4AGNMWtUS/P0/eXfQTmTE uYGxgL5+66JepelWDyD/fYsCfnHmDRcec1tVZE10FTQI/Xe4wTaxsaVd/RWHnBc4YnZG GtCZ1ZjymHvDlCkjP+4AdRKgWfWIVpGIk4g5AVy1k9KqmRRU9Pn3RmgG0Ltix8/+cQ8l CTyLHTxpfVvPzLUnqXMXNx8lxFUmk74cDCWWLKGukMUjl01wACxHXV0PObAGLd0ThyEC hKwqpA9GKCclezYRfZtA9Nx8QbD4z2rii4AkrdVVgTgyeLa7s9FxH/HcaEg2GFh5DZFC d/ZQ== 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=oo257JjDoIhwiqBvGiPI8EB4cn7Ei4fDeJ2qCeP5TaA=; b=N1N7zCs7Kjtx9TTfKjookx/bjk4WdoJVirCnC7a5FD/NpJnCXI9DgRPXld4Qd5dJvw YRwWmpb0i0BU+D+X7R5Hzl67yFklEMooc1GwKtL6GhXJJ8vqUhPOOiNVtl2JsPIxL2Ut +I4VvFRbqfF5ZYpUPqWf/R26xQLJBc2tuUj9kxQi7M0CqxtokV7RUM/rbXtSwa8Zk0TU 2d4QAlClt+8/29D+nZrs5+fbRB2TsweTu72dRzpLIaOXDt4WpH9LF8XlcdnPh4euFkoy zdj+/hXJU0VRb9e69fpsdJzK9s3/6wOTN6DwKlJLHGSm8jB1b2R+Ha7duODYzissgnj+ cjXg== X-Gm-Message-State: AOAM530FfHZZWcfluhhIkv+0BIyKH0Yb9da3h0o0/ziVc/SG3ctK/KDk KFNF7v3JfZhbu7hLITSjvaOVxjyPOvY= X-Google-Smtp-Source: ABdhPJxyiW7o/oxayhLh1afY4F4ZMV7KTtCzVZJVO2K0hzwkrRGP9OlE1T2pcuysBwnZMkCqu+XXQg== X-Received: by 2002:a17:906:4a87:: with SMTP id x7mr14944733eju.44.1593452308817; Mon, 29 Jun 2020 10:38:28 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH 3/5] hw/i2c: Rename i2c_realize_and_unref() as i2c_slave_realize_and_unref() Date: Mon, 29 Jun 2020 19:38:19 +0200 Message-Id: <20200629173821.22037-4-f4bug@amsat.org> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20200629173821.22037-1-f4bug@amsat.org> References: <20200629173821.22037-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::644; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-ej1-x644.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: Peter Maydell , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Corey Minyard , Andrew Jeffery , Markus Armbruster , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , qemu-arm@nongnu.org, qemu-ppc@nongnu.org, Joel Stanley , Jan Kiszka , David Gibson 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 Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Corey Minyard --- 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 6eacb4a463..135ea56036 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) { DeviceState *dev =3D DEVICE(i2c_slave_new(name, addr)); =20 - i2c_realize_and_unref(I2C_SLAVE(dev), bus, &error_fatal); + i2c_slave_realize_and_unref(I2C_SLAVE(dev), bus, &error_fatal); =20 return dev; } --=20 2.21.3 From nobody Fri Apr 26 11:28:01 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=1593452450; cv=none; d=zohomail.com; s=zohoarc; b=H7HuSEcrTRB7diEGfLsYjm8UTwaucJd1Ob+LDtLrPW0GUXD0cv1zUV48BOtzVtklqfEgpOhUOPKYLxoZ6igonHx1zBf8j9rjgxyBnrhdSk9wfmkG8iuZ646SCDZ8N4+4nSP8B2lbO8C+Ia2ii+w1mm9XR/Ik5PdsFL6vIhOZsAc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1593452450; 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=KiqAtoEZxN9iujAVoojggA/nsoA7gi2cNnzLKEYZw80=; b=gBAz5yTkoFP1dPcqrhDXnVhKz1aeRMC2tCYeGbA28rza1V0rFy3NR1f+C4NO9EU1L2HjW33N/hHvbhCHZ/GGAr2YPinekwFzKyKCJPtmX1ZlDmUN5MEfGsM4CL84jmgaO8+DmIF9N9eNBHQEKOylrz4RAxliO5G8SZYqUNr4wbA= 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 1593452450381412.041100501223; Mon, 29 Jun 2020 10:40:50 -0700 (PDT) Received: from localhost ([::1]:50144 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jpxlx-0008R5-2T for importer@patchew.org; Mon, 29 Jun 2020 13:40:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43772) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jpxjn-0005y8-Me; Mon, 29 Jun 2020 13:38:35 -0400 Received: from mail-ed1-x544.google.com ([2a00:1450:4864:20::544]:41158) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jpxjl-0000JM-7r; Mon, 29 Jun 2020 13:38:35 -0400 Received: by mail-ed1-x544.google.com with SMTP id e22so13556581edq.8; Mon, 29 Jun 2020 10:38:32 -0700 (PDT) Received: from x1w.redhat.com (1.red-83-51-162.dynamicip.rima-tde.net. [83.51.162.1]) by smtp.gmail.com with ESMTPSA id ce19sm216029ejb.24.2020.06.29.10.38.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jun 2020 10:38:29 -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=KiqAtoEZxN9iujAVoojggA/nsoA7gi2cNnzLKEYZw80=; b=sUaCqhenZXl5cBaL0fs/hO05iEoYj171cdkMU5uhKNAdnjTWiAdIdDBe9WCNkb/4RV NutM1ig3wKTq+0Pgo/s4G9OFMU9/xQJ6W1jZief5A6w3YH7e1GZo1MrYi32pxrvU0Ja8 Vp11cq0BqJVefh+dXuzPa3n6Jrii3KwV5+DrK9soLc+SFExX8AXpQCXhAFbIYQP+7PeI /MMYKHEcMRXbcA3veOt8H//rlincLM/qoNbRh4szDNwqbD08/EnFYxWUJoynj6gXyfhi KVU8xR9XoevcTG/qn7zKc7y0jv98TdHATKScoyFkU9Qlz84eqv2MH3H9DGdAgGtqd1ec tbjQ== 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=KiqAtoEZxN9iujAVoojggA/nsoA7gi2cNnzLKEYZw80=; b=mMdRqshsbSEdo/2MMZCWcHrDnIROUHGmpAKedxfKsRSoNo/TnYG90zNxHZuSeyLrh4 qv6ZCPmbPCp2inU0TQDbmSy27s34s9/H5nTLl7wrIRAqNZH4Tjr72Ieu/VC+uKaggb+W ET7ffjQ0Q5MUSjsM/hlH7EJbr/1aKGZhhmXXM1VPknt06UQcNsX6Et4+4JMQg/2/5idz DuXJtpu24yMTf9ylAMNBwXkbVsGCrwot9AmNoCSHD4Bd1Y7ptHp+HGWcGA1ONfazbWk/ I2VYwRiN9qVcGJFU4a0iYdq2u4ZsmvLlenkf5bQK56jFAYTDUdoIKFL5fC2IJ4tTWLzE MpgA== X-Gm-Message-State: AOAM533L+K3o/2h7ibAH/9fYy/XB4JoLTwa70yMJzGnyEXuV2+YUvVdN OUn28yGtX28mjKPzmVDg5WMe5pYP8Ik= X-Google-Smtp-Source: ABdhPJytyWvvDl0licA0AaDlkx0joOAB98vT6xeLoqRJEe0dkwekSzIrubjMwiFLDV/oSxaBJ1tDNw== X-Received: by 2002:a50:9b5d:: with SMTP id a29mr16408955edj.68.1593452310525; Mon, 29 Jun 2020 10:38:30 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH 4/5] hw/i2c: Rename i2c_create_slave() as i2c_slave_create_simple() Date: Mon, 29 Jun 2020 19:38:20 +0200 Message-Id: <20200629173821.22037-5-f4bug@amsat.org> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20200629173821.22037-1-f4bug@amsat.org> References: <20200629173821.22037-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::544; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-ed1-x544.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: Peter Maydell , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Corey Minyard , Andrew Jeffery , Markus Armbruster , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , qemu-arm@nongnu.org, qemu-ppc@nongnu.org, Joel Stanley , Jan Kiszka , David Gibson 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 Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Corey Minyard Reviewed-by: Markus Armbruster --- 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 fc18212e68..716ca3c7b6 100644 --- a/hw/arm/spitz.c +++ b/hw/arm/spitz.c @@ -758,7 +758,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, @@ -773,7 +773,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 a0f4095990..8cf8189f6f 100644 --- a/hw/arm/z2.c +++ b/hw/arm/z2.c @@ -327,8 +327,8 @@ static void z2_init(MachineState *machine) type_register_static(&aer915_info); z2_lcd =3D ssi_create_slave(mpu->ssp[1], "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 135ea56036..21ec52ac5a 100644 --- a/hw/i2c/core.c +++ b/hw/i2c/core.c @@ -281,11 +281,11 @@ 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) { - DeviceState *dev =3D DEVICE(i2c_slave_new(name, addr)); + I2CSlave *dev =3D i2c_slave_new(name, addr); =20 - i2c_slave_realize_and_unref(I2C_SLAVE(dev), bus, &error_fatal); + i2c_slave_realize_and_unref(dev, bus, &error_abort); =20 return dev; } 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 Fri Apr 26 11:28:01 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=1593452700; cv=none; d=zohomail.com; s=zohoarc; b=FpGyZguQd3S/pa6Q/+2c5wYXUcPFPKazvkjbU6TgROcoqyb2F4bIUu4F5+J5C8aa0QleemhRp0jV9v+zGs8JGVxToog2ss+H057ra/1QClMZdHKyRpvIBi9gr//74n8pKM4TSH8pD9VtjgsMnzWcQPJU2M8dmXFUcr71V+RVblo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1593452700; 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=mUMQBpWA8/buAmRWchgLW3e3qoVa4wLDDSi2yUI7jTM=; b=ZNNYGra+uNr0uENymt5JCSk34Q1sbwElOuD3MMczWxVjfUXq5thrM/70kvs00ztsIMUXCNHV7aG1WAO2YmrC1IlRotBxvrEPBki29/IoMK62frA8PgzvmJgOgvLeljNPj78mtU5a+g6qsvv1nlU0AvwzYxPVgHn79I+fgWVNHto= 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 1593452700046225.14384890587462; Mon, 29 Jun 2020 10:45:00 -0700 (PDT) Received: from localhost ([::1]:59866 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jpxpy-0004ED-Sv for importer@patchew.org; Mon, 29 Jun 2020 13:44:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43780) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jpxjo-0005zF-5K; Mon, 29 Jun 2020 13:38:36 -0400 Received: from mail-ed1-x544.google.com ([2a00:1450:4864:20::544]:33100) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jpxjm-0000Je-5l; Mon, 29 Jun 2020 13:38:35 -0400 Received: by mail-ed1-x544.google.com with SMTP id h28so13590538edz.0; Mon, 29 Jun 2020 10:38:33 -0700 (PDT) Received: from x1w.redhat.com (1.red-83-51-162.dynamicip.rima-tde.net. [83.51.162.1]) by smtp.gmail.com with ESMTPSA id ce19sm216029ejb.24.2020.06.29.10.38.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jun 2020 10:38:31 -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=mUMQBpWA8/buAmRWchgLW3e3qoVa4wLDDSi2yUI7jTM=; b=V3n15UdO3kNxinKrmh7Y9xCMJjWnGd/yLFyrQDorlGhu2O1eejtuSUUIXErVfqEXSp AKafuI9/2/sa+ESSILMP7cQuaLZtFaTOlFh9R4pSfYchruDOM5alI1QgDXK8HboCo/T8 wZgC05lm1e090wU5g4Ozz1usZh6KPV1YlNOA/Gonae1/vSPeKgrT5FyU/c4UrIxpThya ZJ3izs5SZNx2eiB3aTNZKconLuLQuchTwNDi+RNR/RhkpbUbyAbcZ4ZMrvjMg8vEvUw6 sahpdTiEGiehjAdi+lIPhYpf5rU3JyI0tBEhmTwC4OMEXVrCFEP2+tYLHwC3vcfSKMH6 UHiQ== 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=mUMQBpWA8/buAmRWchgLW3e3qoVa4wLDDSi2yUI7jTM=; b=AQRJ89f69YXyppK/2VDB1+ZIgqzj2bHUx+w0h6n9SfZ8mFNv4vvYPcIfHTgbvvepV+ aOWasiB+32PrqUS9LQXeGAeB3PEa8EK6sh+cTqs9JJdUSTRFVhiCp6IXxRJGsPCH/asG RQod8O+7VpDeSpNLHI5cOcKDehkJn8i1CcW8v010MkwqvOmi2OeY0o6HU26shtEDpKYA AioLHKzaW5H9wuYlOa9VkOrHh2PTg5tk4eECAODQBzzQF6x2fp9LSBa/3aGs/XdcbIKf 1WFnpu4EV5nNqKKXPdfzeZj5UUJwzEFC5MvuWFTjqtp14d9zgiTokxYt/DC3zm7Q/Eu5 flow== X-Gm-Message-State: AOAM532DaN8024q144KknbBCxI552+pf9MR4gblE6RRy8fRR8lg2MaZd r2udVUgZSmGaqk91MCojdOQfvE1mud4= X-Google-Smtp-Source: ABdhPJyAc+CXAjQpcB+pqE/+rZIHsG9DhYWFlMH40fl5Uy1zpWvxxjeLqae9mW7cNdmapfHggexVqg== X-Received: by 2002:a05:6402:cb3:: with SMTP id cn19mr15019383edb.368.1593452312045; Mon, 29 Jun 2020 10:38:32 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH 5/5] hw/i2c: Document the I2C qdev helpers Date: Mon, 29 Jun 2020 19:38:21 +0200 Message-Id: <20200629173821.22037-6-f4bug@amsat.org> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20200629173821.22037-1-f4bug@amsat.org> References: <20200629173821.22037-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::544; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-ed1-x544.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: Peter Maydell , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Corey Minyard , Andrew Jeffery , Markus Armbruster , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , qemu-arm@nongnu.org, qemu-ppc@nongnu.org, Joel Stanley , Jan Kiszka , David Gibson 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 Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Corey Minyard --- 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..fcc61e509b 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 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). + * Any error aborts the process. + */ I2CSlave *i2c_slave_create_simple(I2CBus *bus, const char *name, uint8_t a= ddr); + +/** + * i2c_slave_realize_and_unref: realize and unref 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: error pointer + * + * Call 'realize' on @dev, put it on the specified @bus, and drop the + * reference to it. Errors are reported via @errp and by returning + * false. + * + * 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