From patchwork Mon Nov 26 20:04:31 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Corey Minyard X-Patchwork-Id: 152076 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp339912ljp; Mon, 26 Nov 2018 12:34:59 -0800 (PST) X-Google-Smtp-Source: AJdET5fGRyQIpyAouOimWUTetHByUQLhUXDErwxGiwimH5rB45hwMwlqiwuxncobsuyc496VyJ37 X-Received: by 2002:a81:28c7:: with SMTP id o190mr31117379ywo.288.1543264499806; Mon, 26 Nov 2018 12:34:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543264499; cv=none; d=google.com; s=arc-20160816; b=WElT2Mao171qWE+nNBmi6o6j8cow4IaiZgYTdStgOZPFWKc+Aj4UauOHUR3HhjwrFu dCTwUi1Vr2h4ZXUGpvxCMDqSTwFBNxylh0fWyE2f47dByNH6VYToddkUXNoCPd1z1vlG TbcxqAiD7kOY9o9v0/aho6gZ9fyml+2cubFX4UAtcwPEWleYLE6M6IOrui1xxH0eh6n5 z3Z/t3SrhXvWAVAQRP0gUj+EegdaaRT+sVhrYJ5XSRQbynm7P1nsCd+u4OBXtkJwDWh5 ShZZxnTzBTvcheMBBY+GwAbakbhlGCOsx3/SnbuU2anWFPvtlp1ANZO7PWA51npLI0ll C+Ww== 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=a9SFFzWbVmV4wiFtLAG/ZGimMa+HdsxX+nv8R2lrHko=; b=ok6jtkahCOXmc6QmCgaaVidoxAjcJq1EUx5G3rONisuAXNkdiTKsSjdYNHq13eWyGX HUID1E4txYhJE8jPTQTNKRBNEqf5MA5ZKXpWinL4ikMU8xz52SKrM4+2YIuVkAQcJDmA rM4dTO4kSKZ5xZkJCKOlcybES/b7+Q2y0GvBSSsd2W2zcLRp/uVDBhCfREAbWi5XxIZ+ k9CjIeBmLLS5mQFGhJnuJyTlTaJKH7wCEiKBeoSnJZ6ImNq8mZCLQXxhlN50nc1h1Aln W2dOxJDUIo4oV7EfN8mxWyhSWZUurC8QLWvdLkK++CWp6hIlgMKs2kRtCLdJDs0uXBiV J4lg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=GbU9Kx8G; 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 m185si1018989ywf.256.2018.11.26.12.34.59 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 26 Nov 2018 12:34:59 -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=GbU9Kx8G; 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]:38725 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gRNas-0002ST-Ht for patch@linaro.org; Mon, 26 Nov 2018 15:34:58 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53704) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gRN81-0001lD-C1 for qemu-devel@nongnu.org; Mon, 26 Nov 2018 15:05:14 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gRN7y-0001Lb-S7 for qemu-devel@nongnu.org; Mon, 26 Nov 2018 15:05:09 -0500 Received: from mail-oi1-x243.google.com ([2607:f8b0:4864:20::243]:43919) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gRN7y-0001JL-HI for qemu-devel@nongnu.org; Mon, 26 Nov 2018 15:05:06 -0500 Received: by mail-oi1-x243.google.com with SMTP id u18so17068056oie.10 for ; Mon, 26 Nov 2018 12:05:02 -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=a9SFFzWbVmV4wiFtLAG/ZGimMa+HdsxX+nv8R2lrHko=; b=GbU9Kx8G6AtRNYcapF5weyXXfJ9LFJP34gJY0XwyFizA0AfWWQD80hGrDmHdbLFiez f4jLHaRhlE2iTJy8lHYfO3mAMDcl3CNXx66Lv4z1eVpBF7M1nH0UjQCWow8fPvPJ21kV vkckoPZllbzdIqtc+ENiBVQ1CPytzrJITwjfY/Zmv+0U19byKOPSMjX0aeBVJ5drUa8l TDSq/LRB8Aiw50uH9UvsZ9Q1gd7ZBCKZX5btxFpGE5umBs32AGqMfOTnmBjZ8cPPlcLT G1WNi7ZBLTMq/juvQeLvePqyBwsYAZcZZ/YQk6WLWdlZwD0sdGbQnFUT2LU6mLsh57ci vKRg== 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=a9SFFzWbVmV4wiFtLAG/ZGimMa+HdsxX+nv8R2lrHko=; b=DdyZkNqgNGmE9or8WMAAkm6vr8J7HOj6hSxxV9blmHbEDwE2lhFBiNOTZhu904Jz0Y ek6RqvOv6FdmLa7pgNPo7lraYfTHhlq75Ic8QjWg3jv+v7WRrLYok0uctACmaDzsnZ5E LpI8ajBQP4MGKM5GkAVodVrxnDIUawf3FZZZeWh7slt7S4cmssOf9Bi3g1NUYIMEivGV xy4YwjywPy+6bQDsY8t+zGdQpf7tfwTZK5uJzCWjFKdg7kyK3Cm1XVd1D5glpiT2U+LY Ka5aVwHfT3hZcg5ei7UHJ2lBuOGolmG+5GD1EXpbT/yx0CJv9IA6O2cuJ/NXkKK5u8S9 Bm6A== X-Gm-Message-State: AGRZ1gKCkjn48tQ4v43VUPD4BcGiKs7lSQ1w+7V8rDoIpPVLvhahOPye 2cScmsoJI2nQr7LWWHzBSLFIy0w= X-Received: by 2002:aca:cf04:: with SMTP id f4mr16890649oig.16.1543262701925; Mon, 26 Nov 2018 12:05:01 -0800 (PST) Received: from serve.minyard.net ([47.184.128.64]) by smtp.gmail.com with ESMTPSA id n185sm459115oih.18.2018.11.26.12.04.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 26 Nov 2018 12:04:58 -0800 (PST) Received: from t430.minyard.net (t430m.minyard.net [192.168.27.3]) by serve.minyard.net (Postfix) with ESMTPA id C362A1E62; Mon, 26 Nov 2018 14:04:49 -0600 (CST) Received: by t430.minyard.net (Postfix, from userid 1000) id BD83A30146D; Mon, 26 Nov 2018 14:04:46 -0600 (CST) From: minyard@acm.org To: qemu-devel@nongnu.org, "Dr . David Alan Gilbert" , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Peter Maydell Date: Mon, 26 Nov 2018 14:04:31 -0600 Message-Id: <20181126200435.23408-13-minyard@acm.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181126200435.23408-1-minyard@acm.org> References: <20181126200435.23408-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 v3 12/16] 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: 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 --- hw/i2c/smbus_eeprom.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) -- 2.17.1 Reviewed-by: Philippe Mathieu-Daudé 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);