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: 10822389 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D4EF214E1 for ; Wed, 20 Feb 2019 15:36:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BC05C2E881 for ; Wed, 20 Feb 2019 15:36:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B013E2E932; Wed, 20 Feb 2019 15:36:40 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 739462E881 for ; Wed, 20 Feb 2019 15:36:39 +0000 (UTC) Received: from localhost ([127.0.0.1]:41005 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwTvK-0001c5-LE for patchwork-qemu-devel@patchwork.kernel.org; Wed, 20 Feb 2019 10:36:38 -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-Google-Smtp-Source: AHgI3IbkhLneFTbluakxwFQsInpAsKmDvSIraotdUvJvFZUOcIDLCz1OOuXK0xMQgHY4H57rT2R0sQ== 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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(-) 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);