From patchwork Wed Feb 20 13:59:53 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Corey Minyard X-Patchwork-Id: 10822407 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 A7B6B1399 for ; Wed, 20 Feb 2019 15:47:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 90C022EA9A for ; Wed, 20 Feb 2019 15:47:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 84B5E2EAC5; Wed, 20 Feb 2019 15:47:19 +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 29FA72EA9A for ; Wed, 20 Feb 2019 15:47:19 +0000 (UTC) Received: from localhost ([127.0.0.1]:41231 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwU5e-0001oH-CL for patchwork-qemu-devel@patchwork.kernel.org; Wed, 20 Feb 2019 10:47:18 -0500 Received: from eggs.gnu.org ([209.51.188.92]:46138) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwTqJ-0005qN-Tc for qemu-devel@nongnu.org; Wed, 20 Feb 2019 10:31:33 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gwTqH-000237-NY for qemu-devel@nongnu.org; Wed, 20 Feb 2019 10:31:27 -0500 Received: from mail-ot1-x341.google.com ([2607:f8b0:4864:20::341]:39564) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gwTq7-0001yu-R0 for qemu-devel@nongnu.org; Wed, 20 Feb 2019 10:31:17 -0500 Received: by mail-ot1-x341.google.com with SMTP id n8so40771762otl.6 for ; Wed, 20 Feb 2019 07:31:15 -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=9BByOpfKlj5BdmNNBOif+f406Blfw2gzhg0xpDJUO0Y=; b=oV11Np8rOnBdZXzoFi+b1JajqDCjZwLaZc8Ue2XlTeERFSwQILHqpH99ungjxj5WcB OhfhiHgPjUm9xfVaWTKNVISuu9XoPsBfHgndRwfh4pt3ohxyxm7bSH74WuJBW0XzBSVf DwCxTZkfVpHhL83rBNdOJTKtxOFwyN61i/J/lH/7Saak/6GWj+H1WkUAffPaSkX+fn+X Zb5/PW3xjcGZab1jZO9CFpKDD0+IyWfT7tlBALBbR8n7OTh1AwJK6ee54nE9AO7XtJv9 KJIjTozuwSbDi2TECuCmdpFN4Vzq+KQn5V3rwEg2xC0PsthmfIbNB9kDqcyFgpkOIiCi dlEA== 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=9BByOpfKlj5BdmNNBOif+f406Blfw2gzhg0xpDJUO0Y=; b=OSKy9J9SRWd+pC43+x3OjsHH/4qnY3C1IwZV6WoCv+LyIO8CYKMFvT1OzWtq82v3H4 R1wPp6rY/igWxksqm7p05Bwco1CEhyIkd8LqemGUyVJVwGAuTm8stvph8MmHBssoWOO/ vUbnkJAQOoARAWDWGcClr0boWRmU4v1M1RHUjVi8+0LvTJUiTPNvfDM8lHH72UqyRBYH ky8Sec3IufDKEG5FZUdBlOzOrqCir7g6nWhK6TQ7QcBGanIY4DFDoqOfKdxsoGzDHJfn aN5UcFsTMQsdxWnvw7O0ZvsQRjrz70XzZGrwvhv5W6E0ZoFPZE9IztA/EOlvAro8vXeD dXKA== X-Gm-Message-State: AHQUAuYymiY5lP2HdIAHM1LGAdxKTreoO41w15Dpoov+e2ysSWi8bA7G UYCe8h0na1hkBi2X+nfh5Kk/iJDwTA== X-Google-Smtp-Source: AHgI3IZXz8sB/DyZGzOViuEzZgDaGvsTP8RbF4v4tKPW01WH5JIgZe8o03vmBzNGe16NF2QsBO0Yzw== X-Received: by 2002:a05:6830:1103:: with SMTP id w3mr1135421otq.61.1550671219478; Wed, 20 Feb 2019 06:00:19 -0800 (PST) Received: from serve.minyard.net ([47.184.128.64]) by smtp.gmail.com with ESMTPSA id q67sm2024648oif.40.2019.02.20.06.00.13 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 20 Feb 2019 06:00:17 -0800 (PST) Received: from t430.minyard.net (t430m.minyard.net [192.168.27.3]) by serve.minyard.net (Postfix) with ESMTPA id 0FFED1808F2; Wed, 20 Feb 2019 14:00:11 +0000 (UTC) Received: by t430.minyard.net (Postfix, from userid 1000) id DBFF9302812; 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:53 -0600 Message-Id: <20190220135956.22589-17-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: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::341 Subject: [Qemu-devel] [PATCH 16/19] i2c:smbus_eeprom: Add a size constant for the smbus_eeprom size 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 It was hard-coded to 256 in a number of places, create a constant for that. Signed-off-by: Corey Minyard Reviewed-by: Philippe Mathieu-Daudé --- hw/i2c/smbus_eeprom.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/hw/i2c/smbus_eeprom.c b/hw/i2c/smbus_eeprom.c index 91d68ff588..b3cc9c7083 100644 --- a/hw/i2c/smbus_eeprom.c +++ b/hw/i2c/smbus_eeprom.c @@ -35,6 +35,8 @@ #define SMBUS_EEPROM(obj) \ OBJECT_CHECK(SMBusEEPROMDevice, (obj), TYPE_SMBUS_EEPROM) +#define SMBUS_EEPROM_SIZE 256 + typedef struct SMBusEEPROMDevice { SMBusDevice smbusdev; void *data; @@ -70,7 +72,7 @@ static int eeprom_write_data(SMBusDevice *dev, uint8_t *buf, uint8_t len) for (; len > 0; len--) { data[eeprom->offset] = *buf++; - eeprom->offset = (eeprom->offset + 1) % 256; + eeprom->offset = (eeprom->offset + 1) % SMBUS_EEPROM_SIZE; } return 0; @@ -129,12 +131,14 @@ void smbus_eeprom_init(I2CBus *smbus, int nb_eeprom, const uint8_t *eeprom_spd, int eeprom_spd_size) { int i; - uint8_t *eeprom_buf = g_malloc0(8 * 256); /* XXX: make this persistent */ + /* XXX: make this persistent */ + uint8_t *eeprom_buf = g_malloc0(8 * SMBUS_EEPROM_SIZE); if (eeprom_spd_size > 0) { memcpy(eeprom_buf, eeprom_spd, eeprom_spd_size); } for (i = 0; i < nb_eeprom; i++) { - smbus_eeprom_init_one(smbus, 0x50 + i, eeprom_buf + (i * 256)); + smbus_eeprom_init_one(smbus, 0x50 + i, + eeprom_buf + (i * SMBUS_EEPROM_SIZE)); } }