From nobody Fri Nov 7 19:46:24 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.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 154869915171354.59666485704065; Mon, 28 Jan 2019 10:12:31 -0800 (PST) Received: from localhost ([127.0.0.1]:36360 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1goBOY-0003Xv-Kz for importer@patchew.org; Mon, 28 Jan 2019 13:12:30 -0500 Received: from eggs.gnu.org ([209.51.188.92]:37045) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1goBED-0003Db-HM for qemu-devel@nongnu.org; Mon, 28 Jan 2019 13:01:51 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1goB8V-0005ta-06 for qemu-devel@nongnu.org; Mon, 28 Jan 2019 12:56:03 -0500 Received: from mail-pf1-x442.google.com ([2607:f8b0:4864:20::442]:34205) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1goB8U-0005cJ-PN for qemu-devel@nongnu.org; Mon, 28 Jan 2019 12:55:54 -0500 Received: by mail-pf1-x442.google.com with SMTP id h3so8353036pfg.1 for ; Mon, 28 Jan 2019 09:55:23 -0800 (PST) Received: from serve.minyard.net (serve.minyard.net. [2001:470:b8f6:1b::1]) by smtp.gmail.com with ESMTPSA id l70sm62441308pgd.20.2019.01.28.09.55.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 28 Jan 2019 09:55:16 -0800 (PST) Received: from t430.minyard.net (unknown [IPv6:2001:470:b8f6:1b:c8f8:7971:e432:a838]) by serve.minyard.net (Postfix) with ESMTPA id 68F9C106D; Mon, 28 Jan 2019 11:55:13 -0600 (CST) Received: by t430.minyard.net (Postfix, from userid 1000) id 86AF1301162; Mon, 28 Jan 2019 11:55:10 -0600 (CST) 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=XH0JtuomOh1872pyaHH51ab2ohSNk7NtbAOrPXjiPwE=; b=ronz2TwGoiGqFeF/fTokk5g7TxeFIUOjQSlrW+u8zGZW91PGBQARMDiCtBp5pBBk9W qkUqOf/YJKU8lIAjuJB7usZbnkAC86FiZoMNYOtwTnJq7Vjo0WbJGhqobn+1mOE0vcUD PY43h6WwlMHGowtBvagi8rB4KrgFm1swzgWbEqmiIWGs5QHlLMJmEiQWZD2TcouD65bt tPXMx7lNW6oInay/Te5rNdefTG8pNQkEOg/OdkoFBBopUpSdx8g5t8a5t5KgI0iLPrhe 515ipCsuE0qe3ry3qjh0kdMx5vrFevmRw5SUTFVEWj+7RUx/Yz0IccBY8+IyhdyXthSU pYtA== 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=XH0JtuomOh1872pyaHH51ab2ohSNk7NtbAOrPXjiPwE=; b=XAHTugXXP6iSPsr6WHK1bRa8Lsj4p8gMngQ6J9m6k1LM01mAXu5j8Pyx7oBwMFFFYf 8QWN3bWnnsy7p11zw/rP6/TNJlk1USS+n5QU5ZGK0e1pfIsdyo8ztO6j5pZt+mojLrDA uWzHml2hm3hBk1h4i4tCP5KzhQbr0gtNDHTt1YABbHQi/Rrrmv7N95s7bs7FKaFa373a HgHK2Fhl3XCvJI1I9nDtzthmUbHjurFEEaHz+bqE7g2pWQOSafZmubtlQZLEJh8wFBh4 aOnTb6+QgKB+yACeHVXiCJjafLzMM01SyRBC3J+6R/NWWJouXvB1u00acgziGELvPk7i ymAg== X-Gm-Message-State: AJcUukfRJZj2tF7/2Kpsk+uA+oyTTDl1RDZwHczfRgKt2Wjjqx2CEYiO Nno8WxJ0SOFTAKVhR8qBLg== X-Google-Smtp-Source: ALg8bN5eH4Tkl9W0zA6RcXzAAZVQel5vnvS/8dMFR1X46xIM8GiwMASLL536/xugzWW69DO/jxpqAg== X-Received: by 2002:a63:61c8:: with SMTP id v191mr20881248pgb.242.1548698122152; Mon, 28 Jan 2019 09:55:22 -0800 (PST) From: minyard@acm.org To: qemu-devel@nongnu.org, "Dr . David Alan Gilbert" Date: Mon, 28 Jan 2019 11:54:54 -0600 Message-Id: <20190128175458.27255-16-minyard@acm.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190128175458.27255-1-minyard@acm.org> References: <20190128175458.27255-1-minyard@acm.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::442 Subject: [Qemu-devel] [PATCH v4 15/19] i2c:smbus_eeprom: Add normal type name and cast to smbus_eeprom.c X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Paolo Bonzini , Corey Minyard , Corey Minyard , "Michael S . Tsirkin" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Corey Minyard Create a type name and a cast macro and use those through the code. Signed-off-by: Corey Minyard Reviewed-by: Peter Maydell Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- hw/i2c/smbus_eeprom.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/hw/i2c/smbus_eeprom.c b/hw/i2c/smbus_eeprom.c index 62e634c745..91d68ff588 100644 --- a/hw/i2c/smbus_eeprom.c +++ b/hw/i2c/smbus_eeprom.c @@ -30,6 +30,11 @@ =20 //#define DEBUG =20 +#define TYPE_SMBUS_EEPROM "smbus-eeprom" + +#define SMBUS_EEPROM(obj) \ + OBJECT_CHECK(SMBusEEPROMDevice, (obj), TYPE_SMBUS_EEPROM) + typedef struct SMBusEEPROMDevice { SMBusDevice smbusdev; void *data; @@ -38,7 +43,7 @@ typedef struct SMBusEEPROMDevice { =20 static uint8_t eeprom_receive_byte(SMBusDevice *dev) { - SMBusEEPROMDevice *eeprom =3D (SMBusEEPROMDevice *) dev; + SMBusEEPROMDevice *eeprom =3D SMBUS_EEPROM(dev); uint8_t *data =3D eeprom->data; uint8_t val =3D data[eeprom->offset++]; =20 @@ -51,7 +56,7 @@ static uint8_t eeprom_receive_byte(SMBusDevice *dev) =20 static int eeprom_write_data(SMBusDevice *dev, uint8_t *buf, uint8_t len) { - SMBusEEPROMDevice *eeprom =3D (SMBusEEPROMDevice *) dev; + SMBusEEPROMDevice *eeprom =3D SMBUS_EEPROM(dev); uint8_t *data =3D eeprom->data; =20 #ifdef DEBUG @@ -73,7 +78,7 @@ static int eeprom_write_data(SMBusDevice *dev, uint8_t *b= uf, uint8_t len) =20 static void smbus_eeprom_realize(DeviceState *dev, Error **errp) { - SMBusEEPROMDevice *eeprom =3D (SMBusEEPROMDevice *)dev; + SMBusEEPROMDevice *eeprom =3D SMBUS_EEPROM(dev); =20 eeprom->offset =3D 0; } @@ -97,7 +102,7 @@ static void smbus_eeprom_class_initfn(ObjectClass *klass= , void *data) } =20 static const TypeInfo smbus_eeprom_info =3D { - .name =3D "smbus-eeprom", + .name =3D TYPE_SMBUS_EEPROM, .parent =3D TYPE_SMBUS_DEVICE, .instance_size =3D sizeof(SMBusEEPROMDevice), .class_init =3D smbus_eeprom_class_initfn, @@ -114,7 +119,7 @@ void smbus_eeprom_init_one(I2CBus *smbus, uint8_t addre= ss, uint8_t *eeprom_buf) { DeviceState *dev; =20 - dev =3D qdev_create((BusState *) smbus, "smbus-eeprom"); + dev =3D qdev_create((BusState *) smbus, TYPE_SMBUS_EEPROM); qdev_prop_set_uint8(dev, "address", address); qdev_prop_set_ptr(dev, "data", eeprom_buf); qdev_init_nofail(dev); --=20 2.17.1