From patchwork Mon Jan 28 17:54:54 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Corey Minyard X-Patchwork-Id: 156840 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp3728176jaa; Mon, 28 Jan 2019 10:13:18 -0800 (PST) X-Google-Smtp-Source: ALg8bN7gN3c6xlNrtroNn5UY8tj6cqfzwtgHM+wkEhqurl3RfljCPySZjEv2ckGwkNL6I9wac2cE X-Received: by 2002:adf:90e5:: with SMTP id i92mr21811974wri.210.1548699198572; Mon, 28 Jan 2019 10:13:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548699198; cv=none; d=google.com; s=arc-20160816; b=AjK+XlLsQ/Cyh1doSRztYzGHD9/cSIaV56l8EL8QSj2IUbdweVlRoYwHFvcTR3rrVC Jj1Ih3OB4ySAy0Oc+BgskAqrXczQtcej6k7aKZrbDrZvZ4SUAsE8bCoArIqfGstsKjLX 3SpiAqfeNsFOfzDx7TsktS1ucC0Pc0z76D/10e1EC57RvUTqPCniFvKp87/ZKf1Bfetp FNzoXpQWA2zWchzo+hMK9XHmlTrDb3hTm10MTF3O7h6Lvo+mOKzDrZQBusW0gaCwj0MR 1Cb3Hk1RvV+VisSOdfuQIymdeVP8bZW9x/imU6f6k1SHVl2GvSQu3koXAcheGxmcTamU rQVA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=XH0JtuomOh1872pyaHH51ab2ohSNk7NtbAOrPXjiPwE=; b=lmeQuhWgaghKGSK3+t9YyW3JlVIOaZUf1vTdSb1G3e/rZNwE4F2g5V7jTav4w+19pp U42tjnYETeRARUsxqy+pL50eJUFGmnHW8UTCsS1z8ZYrxVkSI1Lt15wsJGYAfBeYR5R8 0sJ5tfsX1aQosoP646LcCzBnigThAMq3JlWCdoX40FXUiOcs3NzRZ+APcdSa+cIHUQM3 yYkD3ZF/6rSZwRJ0D/grUZKppxorC17nbYK+R6Fs/Gz3joBHNDg2s3cwLAq9hOrCGneC PWqR4qXkA3tasl4njSkNThjuoszBAX1u27GnNOYUvZY6HMTbYmkgDYdmW1xYlImJo7Y5 W00Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=ronz2TwG; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org" Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id x186si100381wmb.66.2019.01.28.10.13.18 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 28 Jan 2019 10:13:18 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=ronz2TwG; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org" Received: from localhost ([127.0.0.1]:36360 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1goBPJ-0003Xv-6R for patch@linaro.org; Mon, 28 Jan 2019 13:13:17 -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) 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-Received: by 2002:a63:61c8:: with SMTP id v191mr20881248pgb.242.1548698122152; Mon, 28 Jan 2019 09:55:22 -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) 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 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+patch=linaro.org@nongnu.org Sender: "Qemu-devel" 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é --- hw/i2c/smbus_eeprom.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) -- 2.17.1 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 @@ //#define DEBUG +#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 { static uint8_t eeprom_receive_byte(SMBusDevice *dev) { - SMBusEEPROMDevice *eeprom = (SMBusEEPROMDevice *) dev; + SMBusEEPROMDevice *eeprom = SMBUS_EEPROM(dev); uint8_t *data = eeprom->data; uint8_t val = data[eeprom->offset++]; @@ -51,7 +56,7 @@ static uint8_t eeprom_receive_byte(SMBusDevice *dev) static int eeprom_write_data(SMBusDevice *dev, uint8_t *buf, uint8_t len) { - SMBusEEPROMDevice *eeprom = (SMBusEEPROMDevice *) dev; + SMBusEEPROMDevice *eeprom = SMBUS_EEPROM(dev); uint8_t *data = eeprom->data; #ifdef DEBUG @@ -73,7 +78,7 @@ static int eeprom_write_data(SMBusDevice *dev, uint8_t *buf, uint8_t len) static void smbus_eeprom_realize(DeviceState *dev, Error **errp) { - SMBusEEPROMDevice *eeprom = (SMBusEEPROMDevice *)dev; + SMBusEEPROMDevice *eeprom = SMBUS_EEPROM(dev); eeprom->offset = 0; } @@ -97,7 +102,7 @@ static void smbus_eeprom_class_initfn(ObjectClass *klass, void *data) } static const TypeInfo smbus_eeprom_info = { - .name = "smbus-eeprom", + .name = TYPE_SMBUS_EEPROM, .parent = TYPE_SMBUS_DEVICE, .instance_size = sizeof(SMBusEEPROMDevice), .class_init = smbus_eeprom_class_initfn, @@ -114,7 +119,7 @@ void smbus_eeprom_init_one(I2CBus *smbus, uint8_t address, uint8_t *eeprom_buf) { DeviceState *dev; - dev = qdev_create((BusState *) smbus, "smbus-eeprom"); + dev = 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);