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: 158827 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp5076470jaa; Wed, 20 Feb 2019 07:48:52 -0800 (PST) X-Google-Smtp-Source: AHgI3IbZjGfrEfFeCtYCzCeawJtLz4QYHZbpoedM6hZVUYSmy7LPudhBWm8X+NC7RP8/ua5Y+XZw X-Received: by 2002:a25:9b49:: with SMTP id u9mr10253509ybo.475.1550677732686; Wed, 20 Feb 2019 07:48:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550677732; cv=none; d=google.com; s=arc-20160816; b=a3zYoYEdZB8j9vcF/ff1hlvTSwAq6R92ZSNwC4QWkiw6y+9bC1WQjyAQkKINRUiTBy w7RmDT8ROveG1OgxWDLU1s52E3MrrpcXWE4mpx6BlB8iJIVEUONIVVq0BB85JvwwV6r5 oAxdcqYVgGEludmtenFkM6k7piPM2IAuxPXBOr0WblSDFCCB2zvvtXkAzTYO/Tu6Vgzu p3XK96jKIEA9AVGQcKEa+ruUzVgcegyrHFXL2bMPLhxSchA56c9kJuCHc8Ff3oNbpoIF +eXX2DvyxGlS15Ax6d8/JFAdHe6H37jCnhgfzd8zrJnofCDqNqGbQ4xFWUwJnYbGuROX yYgQ== 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=9BByOpfKlj5BdmNNBOif+f406Blfw2gzhg0xpDJUO0Y=; b=e/3mgYtv2lqiG7CQAOqdIOsCvu0S7VASswklRynkk5oQdjHhdwg8V01811xKJUpzmh TVgC9TK2heak+gHIyHAskpvSoDch2ObsyY0+oTsXQBaPFHaSZHL0fdiU1OKaRvk/rdd7 4anSNMB7ZjO/+uFsl8nvKO8j4mCBbVcWQNSn6stVlN9JzPyZWQqnQ0i6IqCZ5mcG0rK8 qN0d3LJP8JDZ1OZ+DCaNS7EeIARtMvLW8QxWD1XLzBLD9DaiJxIXf8snNa+uawUmoVj1 NgYrHPSPVH4PB/8aWSjCBRtNamOpi6cTliOgxzhd2brv73/wKhZ06p5qNPATl5H760kK DLSg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=oV11Np8r; 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 q203si2644968ybc.34.2019.02.20.07.48.52 for (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 20 Feb 2019 07:48:52 -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=oV11Np8r; 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]:41231 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwU79-0001oH-Po for patch@linaro.org; Wed, 20 Feb 2019 10:48:51 -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-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+patch=linaro.org@nongnu.org Sender: "Qemu-devel" 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(-) -- 2.17.1 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)); } }