From patchwork Thu Feb 28 18:17:06 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Corey Minyard X-Patchwork-Id: 159412 Delivered-To: patch@linaro.org Received: by 2002:ac9:18c7:0:0:0:0:0 with SMTP id i7csp979911oce; Thu, 28 Feb 2019 10:24:34 -0800 (PST) X-Google-Smtp-Source: APXvYqzyySOdrYKNSIlQOEZTjZttUBI/Eqom8ASCaE0UYupNkrkhQPCDVScLxRsBSmn2hmxQwf0p X-Received: by 2002:a25:b96:: with SMTP id 144mr740914ybl.31.1551378274634; Thu, 28 Feb 2019 10:24:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551378274; cv=none; d=google.com; s=arc-20160816; b=OSs5O7QEL9sLiIfF4sV3m0VdZr03PTqiVGCEKQbCanZW/xma3sgrYJrL9+Jun3rdAe 9IP5NSZ2knwuB+hi/db+jH08ozfA1cqtq5yNRa6Psp10m8AC0qWcSVmZr2x38aG/lVVj 53Fu3PbJND6vGHR7jWE58cg2DyqXWLiLYiVMUHUf0SvbURRh9lco/dS+oIghscqFvZ+4 marQ0RTDyFEWuoZetvm12q6i8Q/gRd3sg4UQc1eTrKUBOiNdCgOy3SPG2BihWWLTcXRj Ef2N6aXd+w3ciBy93AKREo5sN4IZ5i4HdYyCej01xO0lbBdgMNimcVIiQ1DG1aAFIgYa +O8Q== 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=phVcIZ91pPZo7YJfCc5Psb+Hz4cvw3ogTugWINPoDh8=; b=ug4FxIjuBiLHPZTdxn0TpkRSkGSQzZ+golZatXNgpsPDVBavcg0WTtvPbB2PKNDjXB mwOuvhzXk9MF+EhM3B4RYS3Gn5deQdTgVU+L4blQWBD4BvreDwWCaTj8ws5AXDU9B1y6 Z/SBJnulTSccSgDuEmDIFsCq7FK9ExwJGqiANUa1hHb7kxU0quo4QJ041jv85LEwCgpz tHohyAurWB5t2AoOuYnUU2UTJP+Lus9vW2NHAFXK08T86/qy9Ur+J+AJHnukURxjAlj4 kgq0G4DGx5wOLRTQjnLM9uV59qqLc2rU6SwAa0PSbT5t+qXMFYIoK3ZiTjjLNs/ClQem fUTA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=I7CSSJF+; 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 g16si11373632ybk.427.2019.02.28.10.24.34 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 28 Feb 2019 10:24:34 -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=I7CSSJF+; 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]:44564 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gzQME-0004S4-6I for patch@linaro.org; Thu, 28 Feb 2019 13:24:34 -0500 Received: from eggs.gnu.org ([209.51.188.92]:46626) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gzQFe-0000VK-BM for qemu-devel@nongnu.org; Thu, 28 Feb 2019 13:17:57 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gzQFV-0002I8-N8 for qemu-devel@nongnu.org; Thu, 28 Feb 2019 13:17:42 -0500 Received: from mail-ot1-x341.google.com ([2607:f8b0:4864:20::341]:46741) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gzQFV-0002DP-E3 for qemu-devel@nongnu.org; Thu, 28 Feb 2019 13:17:37 -0500 Received: by mail-ot1-x341.google.com with SMTP id c18so18489701otl.13 for ; Thu, 28 Feb 2019 10:17:29 -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=phVcIZ91pPZo7YJfCc5Psb+Hz4cvw3ogTugWINPoDh8=; b=I7CSSJF+P2yXXOO2uudtf+4mzFOXaprMGtUInhKW96IZkCxtO+5qRXvjtFDnbzAKmd bY7HD1z8rnRuZ/m630jCgbhvpjRpxleLD/++Il9BE2QdtiR07oEKtn9vRODUWo5Ha87l lWxu8dejdqMdpT6e1Veut8IJ2lDCsZwm8HaQvq/2K7kr1LdoYoTrtXIb5W2HrOQbg258 5CNTyHwPp+3liV15+qd0z5MFJ/aJnMPbmliT9ec7koU1hG4fq+dj4CGUdKuwqr6Obqun ZhPK/LUm+hcI62myLKmqd4JqJ8rid8GrGhLNZofFqxLkyrAw1HK8kT3IF9pQQr+5iOfp MFMA== 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=phVcIZ91pPZo7YJfCc5Psb+Hz4cvw3ogTugWINPoDh8=; b=joi7hwxqKX5OsthBry3+70E27S12D82TZeB18YdS6WyvYOhhPWRVYrlK8ZyhFYxjKI hFVm4L2rDN5ucZQ8BdtYFlA7Yv78apm/T2rqHrhmi4C2w5avGPuzM68XeYz1pxx1ifcc SQlKwFcKrzVjzGZEZTn+hWC7hZVEMYtT2nbTcyFpngrhc4Z0XJ3+9CnxzFf61icjsy/u xtrPOANpxcj9qurMaqDnDsgIMP1k6fne6raFHMtcsY0NQ9L/bXSSITNbtwYL1vEexlXV nnfSmKh27/ozxGKlIXfiRk+mpozTccArXfyTVALULeIzH5AANLdIHPTJzXgQbWSE6YA4 Ovhw== X-Gm-Message-State: APjAAAXWaF0MqUXrdWBjzDiY0rSaYslkYQ3L9UaMJuwdzP0a2lR0IluF ZFslV0mlFiJzXbMCNhliSg== X-Received: by 2002:a9d:2944:: with SMTP id d62mr642525otb.193.1551377848407; Thu, 28 Feb 2019 10:17:28 -0800 (PST) Received: from serve.minyard.net (serve.minyard.net. [2001:470:b8f6:1b::1]) by smtp.gmail.com with ESMTPSA id 3sm5363623ots.75.2019.02.28.10.17.18 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 28 Feb 2019 10:17:25 -0800 (PST) Received: from t430.minyard.net (t430m.minyard.net [192.168.27.3]) by serve.minyard.net (Postfix) with ESMTPA id ACD9A1808FF; Thu, 28 Feb 2019 18:17:14 +0000 (UTC) Received: by t430.minyard.net (Postfix, from userid 1000) id 721B63028CF; Thu, 28 Feb 2019 12:17:14 -0600 (CST) From: minyard@acm.org To: Peter Maydell Date: Thu, 28 Feb 2019 12:17:06 -0600 Message-Id: <20190228181710.2477-16-minyard@acm.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190228181710.2477-1-minyard@acm.org> References: <20190228181710.2477-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::341 Subject: [Qemu-devel] [PULL 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: Corey Minyard , QEMU Developers , minyard@acm.org 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 2816e35bcc..76f0d4aab0 100644 --- a/hw/i2c/smbus_eeprom.c +++ b/hw/i2c/smbus_eeprom.c @@ -32,6 +32,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; @@ -40,7 +45,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++]; @@ -53,7 +58,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 @@ -75,7 +80,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; } @@ -99,7 +104,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, @@ -116,7 +121,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);