From nobody Sun Nov 9 17:50:11 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1551378225443882.2742064150844; Thu, 28 Feb 2019 10:23:45 -0800 (PST) Received: from localhost ([127.0.0.1]:44562 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gzQLO-0004PL-DE for importer@patchew.org; Thu, 28 Feb 2019 13:23:42 -0500 Received: from eggs.gnu.org ([209.51.188.92]:46736) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gzQFm-0000ZG-5u for qemu-devel@nongnu.org; Thu, 28 Feb 2019 13:18:06 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gzQFY-0002JI-1d for qemu-devel@nongnu.org; Thu, 28 Feb 2019 13:17:53 -0500 Received: from mail-ot1-x331.google.com ([2607:f8b0:4864:20::331]:33980) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gzQFV-0002CX-Nz for qemu-devel@nongnu.org; Thu, 28 Feb 2019 13:17:37 -0500 Received: by mail-ot1-x331.google.com with SMTP id 98so18591442oty.1 for ; Thu, 28 Feb 2019 10:17:26 -0800 (PST) Received: from serve.minyard.net (serve.minyard.net. [2001:470:b8f6:1b::1]) by smtp.gmail.com with ESMTPSA id c131sm8064759oif.3.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 (unknown [IPv6:2001:470:b8f6:1b:b89e:c7bf:12ab:ad14]) by serve.minyard.net (Postfix) with ESMTPA id B5F13180900; Thu, 28 Feb 2019 18:17:14 +0000 (UTC) Received: by t430.minyard.net (Postfix, from userid 1000) id A52683028D0; Thu, 28 Feb 2019 12:17:14 -0600 (CST) 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=6NzHN8+bT4MvQ1gFeAYgeaVdN5GDDM/VncB+6EIJ1Xw=; b=oZQHgIa/Y9fE76eVpekate921BjvL0BT1Ht4+SKMrH1r/wvDldkRSRaB/kpN8VlKOJ aPuNg3hs1DNnaZgtV5rm2oF1BicAe3V+T8k8SF7GrecVGp8ronGHbq5cQaLdZVO58FOO n/tsBcjcRW4vfOA6uuiuIF5jt68vDMGdhVgljzyZ5SW0ZLMsedYp9ea2n2uE7LnGdHD1 EwvwLvujkAc2l4d6MI3QlWowAJG+fDJSR79w/JqCGEke54xhOyYufJggbAMtVWt8xpCm 1wVBFNKijizAoV1lNyaNkTJSlRNCVhaI3r1rfvmhiSgNfME0nGW5cUnoWUG55s7DoLHK XGhQ== 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=6NzHN8+bT4MvQ1gFeAYgeaVdN5GDDM/VncB+6EIJ1Xw=; b=GoVC7yFwQau8R7IPoUJ6MjqlGaAUxWgPXokVJJz8cxMYKyyyGC+45DJsI1ExYAvBxn CWJdebybi9EzaKC/dbbC8//Iq4g9Rj4QoMslSU+xC2WyV0C2JGJGXlcwJwd84dwUvmXa SWLu7bLsmkGhU0Lg9HZ01K2FEUMb6XtVRTYTjPb6b1xzzAbR8GIAnDR2Cxi8HBJs1bAJ n7Xr8D2jPCseyeoK6TnQhcWGaLokwzgwmbA34MtY69e0dxKVdez/oRl9g5UQxjkcC6S9 yAniOTP6P+3/CmdtVFvDBkF3yEAHza6hZALRbkmbI+Rdkr86ZATNXAZ5UHF0KlBuifLY gmdQ== X-Gm-Message-State: APjAAAXXmpR89lKK5x0jFuka69FwHl0m5VX/wwBpeeaX93VOGbjmr9nl fQnjH//bsoBEMF4UsAG9aA== X-Google-Smtp-Source: APXvYqzGtBYvVrNDUOQha9BpqL0kg4Y8ixS/QvTOb+8Zdsha1EpPJmbQIjPrvl6d+UTQBH0wJMeKgg== X-Received: by 2002:a9d:5e07:: with SMTP id d7mr644898oti.315.1551377846104; Thu, 28 Feb 2019 10:17:26 -0800 (PST) From: minyard@acm.org To: Peter Maydell Date: Thu, 28 Feb 2019 12:17:07 -0600 Message-Id: <20190228181710.2477-17-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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::331 Subject: [Qemu-devel] [PULL 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: Corey Minyard , QEMU Developers , minyard@acm.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) 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=C3=A9 --- 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 76f0d4aab0..3fbbffb4de 100644 --- a/hw/i2c/smbus_eeprom.c +++ b/hw/i2c/smbus_eeprom.c @@ -37,6 +37,8 @@ #define SMBUS_EEPROM(obj) \ OBJECT_CHECK(SMBusEEPROMDevice, (obj), TYPE_SMBUS_EEPROM) =20 +#define SMBUS_EEPROM_SIZE 256 + typedef struct SMBusEEPROMDevice { SMBusDevice smbusdev; void *data; @@ -72,7 +74,7 @@ static int eeprom_write_data(SMBusDevice *dev, uint8_t *b= uf, uint8_t len) =20 for (; len > 0; len--) { data[eeprom->offset] =3D *buf++; - eeprom->offset =3D (eeprom->offset + 1) % 256; + eeprom->offset =3D (eeprom->offset + 1) % SMBUS_EEPROM_SIZE; } =20 return 0; @@ -131,13 +133,15 @@ void smbus_eeprom_init(I2CBus *smbus, int nb_eeprom, const uint8_t *eeprom_spd, int eeprom_spd_size) { int i; - uint8_t *eeprom_buf =3D g_malloc0(8 * 256); /* XXX: make this persiste= nt */ + /* XXX: make this persistent */ + uint8_t *eeprom_buf =3D g_malloc0(8 * SMBUS_EEPROM_SIZE); if (eeprom_spd_size > 0) { memcpy(eeprom_buf, eeprom_spd, eeprom_spd_size); } =20 for (i =3D 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)); } } =20 --=20 2.17.1