From patchwork Wed Feb 20 13:59:52 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Corey Minyard X-Patchwork-Id: 158822 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp5064783jaa; Wed, 20 Feb 2019 07:38:19 -0800 (PST) X-Google-Smtp-Source: AHgI3Ibo63ePWLrbgWJY/pwRNU3RwLGAipke2U6qNXT8NBN//OkKDaV+MNuGp1PeDgA/y4v3+P6p X-Received: by 2002:a25:d090:: with SMTP id h138mr20367348ybg.0.1550677099895; Wed, 20 Feb 2019 07:38:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550677099; cv=none; d=google.com; s=arc-20160816; b=BcEInZQllpFTrJRbhN2gaUetzVtlZuw5GVzTksWK5VpQbebEhPqSJlzMjHP6F5U/i8 HrSQL4GguEWNLG0YSYPayzXuH7i0rDy54dztkF8gbPFDUzK3ptGkPk8IJrfrXlG5g4Zs FV9E+ycMN2/xbPjRxTSWzdPtyRmaKzbFPEtQwdmheWxdINU3NBgJISeu5YY7yYJ4wQzk NWjER3Zfe6ULkU9ZhgaXgFgH3f0pHopsX1rMiT5wN6wj12UTD9HBk/p2Mn8/JvwwblZB DaDIn/Gjlw1vpfs4Z/E8X3xp9oWyCju4jYgfLK7Fcvqu+c5UDCmQIIfzQ2HKNFr8zmUF LLcQ== 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=QxF+p+LfjUdh9WEGc+TYID4ANibck8WNknHB9WT06fRU545BHO9RwMv+bI7IDhBc7f jat9IZUOAoWJkxP8eyqzCEzTH9ILwFRrWVtpWjGXuBrGleRK9wuqLZYhhSKwZNGC45mY 1fp94lwjvxTbkx6y4NRex9hBfDLIvshyGYlgPpiD7RM+n50HE0JwfmhntuU9LUyKaHm/ cr3/MHv04WOVyW/gpFZdftisc9rO6VLOQw5KY0fOxVOaxrWDaPkZ53fhrxtPX8x/8r4p wuKRGeV70sU7RjlOvqOMLgckyaxaETQWO0ERPjVcMq5CvpmVwRWVmWh5ndzLRdgjjZKK Zu3g== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=ZYA55BC6; 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 p191si11818212ywe.69.2019.02.20.07.38.19 for (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 20 Feb 2019 07:38:19 -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=ZYA55BC6; 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]:41005 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwTwx-0001c5-Aq for patch@linaro.org; Wed, 20 Feb 2019 10:38:19 -0500 Received: from eggs.gnu.org ([209.51.188.92]:42495) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwTkD-00006H-PZ for qemu-devel@nongnu.org; Wed, 20 Feb 2019 10:25:10 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gwTkB-0007kb-9G for qemu-devel@nongnu.org; Wed, 20 Feb 2019 10:25:09 -0500 Received: from mail-ot1-f65.google.com ([209.85.210.65]:34571) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gwTk9-0007cI-5P for qemu-devel@nongnu.org; Wed, 20 Feb 2019 10:25:05 -0500 Received: by mail-ot1-f65.google.com with SMTP id 98so40817037oty.1 for ; Wed, 20 Feb 2019 07:24:39 -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=ZYA55BC65sEb8shIyn2te8Mlar8qd9iqNp2lkiCg/M6Gya8ig3ix3Q76R67GFgT4Vz Y6nLeBMKpj3q+fuuRYcSPdHQ+3NcVDh7XQ3zcOVfX7LiA3cDWHuTZXIHD5cJu8X3hegn Ph/GcH00A6Ins7fhno1y2QPUt6bMcAjmeI2GmBo2XY34Vjut4FuKuAhG8AKl/jOscQiL hIPYIncFZNmoewmWraG8xu1XWQp1Ie2me0fR0eL6NYIRkI9CQDaRJFCHyarXksrYJRuv DJmwhyHaUZm9HdpJOyPsmZHJ7L1bzcKk3vsnwD1Yix6ctkmxWR+0x/HhEqW0ML1PKuzC t7Sw== 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=dypSaGieaY48CPhFZBNb8LX+63C/mWuuWLhheLfzAmXdIyWP7OYrGu/cIdTlMoLlPK foz0zavtbivQMVy7MVfvTEPIPSG5eyRsWx/M570VyETb59us3ru0l7FRnCjHe3P+j+X6 KVDeT5vhkHFPfG+rkH3ucm+lfoZ+P4FP7HgRW1BeO+z7zl/JTeNpOabcap50/ZQLztrQ TQ5AhNWJPmzM0DhQiGraXsLt8HiGyJnxMVjYVG9h0o0zGhKpg3YEi5uwjjr2e1HgxPo6 Y6xFA72fFF0XJbIEcNhbdFwLHzrfWmqiBKeBZGSBDR64TIFUqIhN0tFsXv3Jc8urtkZ6 zXmA== X-Gm-Message-State: AHQUAuZTauwFCpxkavnjmdz3ap9wtmJozNk5cbbN5gHAYJCSs6JEk2Ee Vlw3ChsPCKMkO1QmDai7/lavx5+OgA== X-Received: by 2002:aca:3746:: with SMTP id e67mr6211685oia.103.1550671221813; Wed, 20 Feb 2019 06:00:21 -0800 (PST) Received: from serve.minyard.net (serve.minyard.net. [2001:470:b8f6:1b::1]) by smtp.gmail.com with ESMTPSA id n65sm8579718oib.12.2019.02.20.06.00.14 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 20 Feb 2019 06:00:20 -0800 (PST) Received: from t430.minyard.net (t430m.minyard.net [192.168.27.3]) by serve.minyard.net (Postfix) with ESMTPA id 2C2EB1808FD; Wed, 20 Feb 2019 14:00:11 +0000 (UTC) Received: by t430.minyard.net (Postfix, from userid 1000) id 06F48302A62; Wed, 20 Feb 2019 08:00:10 -0600 (CST) From: minyard@acm.org To: qemu-devel@nongnu.org Date: Wed, 20 Feb 2019 07:59:52 -0600 Message-Id: <20190220135956.22589-16-minyard@acm.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190220135956.22589-1-minyard@acm.org> References: <20190220135956.22589-1-minyard@acm.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.85.210.65 Subject: [Qemu-devel] [PATCH 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 , Corey Minyard , Corey Minyard , "Michael S . Tsirkin" , "Dr . David Alan Gilbert" , Paolo Bonzini 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);