From patchwork Thu Nov 15 19:24:43 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Corey Minyard X-Patchwork-Id: 151250 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp7407722ljp; Thu, 15 Nov 2018 11:35:23 -0800 (PST) X-Google-Smtp-Source: AJdET5dhRn+rBsL78SpNGK34U7+nSRzdTLE1xlahD6CW+Q75Q2hLqZsvUVl/remK8DAFrpkLdwMq X-Received: by 2002:a37:c994:: with SMTP id m20mr7442519qkl.268.1542310523700; Thu, 15 Nov 2018 11:35:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542310523; cv=none; d=google.com; s=arc-20160816; b=MTzHFQ/49Xxd+fFtEdq1vTWxPcuPRJEGuoaop++x+Td0ipPj/vmS9+fXZ7Ti4AgOAA 95+1858EYmQvUnfeg9TEcq70KT/cKvd6OOEWdMPeflu/MRSqrALdHbAGNhgTPy4JpHWU QsHHrmKTcnw/Y2hjruwXX1QDr7mqGxZyuRd9vJJEeKwGEeI/JckG8sJyDA/xng0TM1Gw a75py3/Xx83YId2NnSzRr+zL2n9dINeTE6wYSmGUHuc9S9iNXh1l/CCHFyVBKnSegmDp OcCt1PryqcFfkaW4zZxh//vCUomcBGntpO6ogdj5u01iV0F+Z8EXt58cRS7w28W2odFI nfXQ== 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:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=1ZOBSvKVieP9LJDRldwy3FsgDvauKU5gTBBdjyj+xu4=; b=YfdX8Rf1p0cvmGFOu5XIaTfQnGdCP38abY0/9CIP+Z3saogS5cMEyUobgBH+IvVoEM CSyh6VkFzgIzUKN0CT2LwqeotFRQXFWg3gVcxanHdD/PMeFgrh5zBq9IvnX9MXKVBMcC oIqF3aIRE8EE6BO0nuTbx6fYT4h6nuViY9+sjRZvVGouYhu8hvDzk1rKEDoBTNj/Yrj1 BKfEqEn3y0qfgtYdvxbPVlHnjpm8aXbofOPNEZ3jra1+mgLW8nJHmU6rmbamrjEkiRXF hb8MAMk3eU4eutOQdpyZFG2IHeWBb2845jZTNYHE6n7H6GszsdOX9RfoGBZo4IfvkkjO YvyA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=E3WDitJ3; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org" Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id f5si8503364qtd.85.2018.11.15.11.35.23 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 15 Nov 2018 11:35:23 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=E3WDitJ3; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org" Received: from localhost ([::1]:40472 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gNNQB-0002OV-5H for patch@linaro.org; Thu, 15 Nov 2018 14:35:23 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56271) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gNNGL-0003YY-M8 for qemu-devel@nongnu.org; Thu, 15 Nov 2018 14:25:25 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gNNGB-00082p-L6 for qemu-devel@nongnu.org; Thu, 15 Nov 2018 14:25:13 -0500 Received: from mail-oi1-x243.google.com ([2607:f8b0:4864:20::243]:34285) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gNNG9-00081b-RQ for qemu-devel@nongnu.org; Thu, 15 Nov 2018 14:25:03 -0500 Received: by mail-oi1-x243.google.com with SMTP id a202-v6so9591528oib.1 for ; Thu, 15 Nov 2018 11:25:00 -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; bh=1ZOBSvKVieP9LJDRldwy3FsgDvauKU5gTBBdjyj+xu4=; b=E3WDitJ3zDTXhnr3Fg6MXpg2qCcALT79BRJVxVGbF/XQh+GWU6g+RKowC2+3rilnrz ablw0fXhM58aqlgLJMYq4RYkNJagOHY79kHvvPEjLoSfR4tXToiFeT+FMmWJ3CrsCsTt NdLmRv2BUu3bIVc6vM7LUdPVvmzKNQw66MLUDqN486mX6AeU88DSi6IT5/1XSibdJDRo 1jupqX1Ngcg5i1tZigwF77GLm/oZjk3fVd/q5Vlb9S3gYFRX4MvFvErWaBu+rRNJj37U Hv6GQ13Ca/uiRGdnZW0AK3kMRqIjiOTiUtfDYrZyjnc1Sf7fvsf/q/3LK8vGdOKGykPg ZRyQ== 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; bh=1ZOBSvKVieP9LJDRldwy3FsgDvauKU5gTBBdjyj+xu4=; b=SEObKHIbjc3shvdSWf5+ZjHEL2jxJBiybaVw9dABXnOR32X4hvZT/e5J1/NFzys3Q+ 14P1Jyt8ZfffHDK7ySdxbGg6qNas8zQJoGVIAxiht0S1+GCea9X5qw+wHW7Bv1dXKuL6 Dqcu84YYfNwu/8VV0u7N5jmuCWTMLd8bt0KEuisoiBMjNOb7MzysENyRO1akosiqjSzV /SM6kLQZfESzqmqW3OOcTG3ILrbv1Q5q39E4T0QAGi2FCSeI40AUb4MAbOgToDDax+2R BpOdof96xAtuJQ9Ue6q3/ZUU/Ya9xkwMKdP3OIdBR256vK87SOjs80jvXx1OpJTOVCO5 KEMA== X-Gm-Message-State: AGRZ1gLnOx+VRyIsnW1Uw/j4xOhxw5x4/TAGfBNanXYPfWRbPehCgowr DDcUOhJUFHO+rSgweRF0SA== X-Received: by 2002:aca:781:: with SMTP id 123-v6mr4487996oih.4.1542309899826; Thu, 15 Nov 2018 11:24:59 -0800 (PST) Received: from serve.minyard.net ([47.184.128.64]) by smtp.gmail.com with ESMTPSA id e195-v6sm11108646oic.26.2018.11.15.11.24.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 15 Nov 2018 11:24:57 -0800 (PST) Received: from t430.minyard.net (t430m.minyard.net [192.168.27.3]) by serve.minyard.net (Postfix) with ESMTPA id 5F0E51E1C; Thu, 15 Nov 2018 13:24:51 -0600 (CST) Received: by t430.minyard.net (Postfix, from userid 1000) id 03BB830146B; Thu, 15 Nov 2018 13:24:48 -0600 (CST) From: minyard@acm.org To: qemu-devel@nongnu.org Date: Thu, 15 Nov 2018 13:24:43 -0600 Message-Id: <20181115192446.17187-10-minyard@acm.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181115192446.17187-1-minyard@acm.org> References: <20181115192446.17187-1-minyard@acm.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::243 Subject: [Qemu-devel] [PATCH v2 09/12] i2c: 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: Paolo Bonzini , Corey Minyard , "Dr . David Alan Gilbert" , minyard@acm.org, "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 --- hw/i2c/smbus_eeprom.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) -- 2.17.1 Reviewed-by: Peter Maydell diff --git a/hw/i2c/smbus_eeprom.c b/hw/i2c/smbus_eeprom.c index 4d25222e23..8d4eed129f 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);