From patchwork Mon Jan 28 17:54:55 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Corey Minyard X-Patchwork-Id: 156828 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp3720630jaa; Mon, 28 Jan 2019 10:05:53 -0800 (PST) X-Google-Smtp-Source: ALg8bN6KLBweMSlxybbGFyp7uEtKMObXcrwkWvtrqr2/1QcORtxYRKTYF1No3fW0XMLEJuyGcYRm X-Received: by 2002:a1c:7306:: with SMTP id d6mr17458524wmb.98.1548698753435; Mon, 28 Jan 2019 10:05:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548698753; cv=none; d=google.com; s=arc-20160816; b=ggLDn5dYo1FCQgmubkzW45axZQAE6sOZeLXkbdQy81vweFsNQrJDo9pVvIQh9aytGj CQRYpK7QctbHG4kXAQ0ShNBa4tmHdZFNLZrYn15hMmPSjw7r+3OEGFGcEi02GTGjkUCC m51aqupVCWuY388vLIp73zSt2BJ2N5LsCZH3UOxh5WbjtDOz6IVGL4KDCeJT21jtf2K7 nrC72Y7qI9oxLCh+0a1kAgWGUAAdQJdqqraYYKO/qro/Pq5QDXEwP5j8tT9gTvRjLAZW A8qk+y5I6u1ZSeXdStd/nHu7iISarfQ7uLNi8fFo3I1THJatNdxvEUDU7JSQya6ldhF4 sydg== 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=hM54xKHNMPKEPrbe3p0IRlYplJBwgFO1Kz4sA6bV9YCsx5N0M/prHbYXQ0OGny1r3l VVM0B388uovTGg2yM0xivdxQw2Ahm68tdsFkcne+hlg3WQci9otNtpxcowHgeQ4OEjxF 0iXj+xXZtwah71EhlmOFv9TC9O+AIbsh8AqYTrUMxDL80DVGVleQN+ciAv/BzykubBX4 mxQi0xOEmuGMsMlMah+qLhX4StuhJYe4/ejEbu3MSGfLmuk0GOxj45chMnrKbyrdVjLd eic/f1mmMgYmLWffMndeGQrLBoZiQNES+fcywsdIT8WKuUkT4vmsYs6+biqBoT0sMFYc ED8g== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=Vrna27ms; 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 c16si80135285wrp.71.2019.01.28.10.05.53 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 28 Jan 2019 10:05:53 -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=Vrna27ms; 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]:36274 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1goBI8-0006Vu-Dy for patch@linaro.org; Mon, 28 Jan 2019 13:05:52 -0500 Received: from eggs.gnu.org ([209.51.188.92]:36956) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1goBEC-000396-By for qemu-devel@nongnu.org; Mon, 28 Jan 2019 13:01:49 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1goB8U-0005si-JM for qemu-devel@nongnu.org; Mon, 28 Jan 2019 12:56:06 -0500 Received: from mail-pl1-x644.google.com ([2607:f8b0:4864:20::644]:45329) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1goB8U-0005Z4-DR for qemu-devel@nongnu.org; Mon, 28 Jan 2019 12:55:54 -0500 Received: by mail-pl1-x644.google.com with SMTP id a14so8043357plm.12 for ; Mon, 28 Jan 2019 09:55:20 -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=Vrna27msDMEOVJKbz6NAquTcrFpwWLnXSfDrYh4a6/qTjlMQ9UlPkI1O+HXSgl5dLH FBig2fItf6KP5c4G8nA7NXV25POP6lRlbtCNhzxHWcwWs7iPPD7tEHCbvZ3kaOpIKNkN ELfxC8x/sUDWxLbvOtmeAXBflOYpKwTRskejSvuZAkGIU5X/5gqaHj5GbgZVkQWAKf7C jQyXnZiw9Cevky+y7r1qWMBdCKMto7HZHz0Wwe2ZofX3miYp08+KTsUj+ZSz9L5JkCWA LtTYP3yyT79iIGMNORA4df8/p0RY6x3TgNve1evqAoh7ecCAhUS1thC26sEU26rvAAcK OlvQ== 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=QoaRoAk9TglzBUU7tfwyqPB/vR378S/2MI6TGyQRABRhZ0y5pMOxw+wSi+1fz9fmDt CAIRPZsK7ajexraEt411wMB856Af361B4J31Rh3TinBuxDs39s96jXphWPG/DFWFTvKu mmrqH9R37jxP/aBcPjXqZf+ixzkryjHLvX1bql5HWb6ZNVxOGl/JOHFomaHEG0SD7aAy DWlA6lCpBJcHLMD9gQh4hlPzhVYl6YcBoYs9XvZ8ZZEJSPY9g19DTVQXfRoCI/IfVWex 6sewgtDTJoZuP+bHDV2UOJHmXnhJNaKrBUUDXzZ7pEhQxqvXMoxuYz9fIzRYdP632uIw VqUw== X-Gm-Message-State: AJcUukct0IhqZ9FMExY1W7KjXcfXuJctKLH3AcbC3XC+PKoTUvrlQNH7 owc3l6wde2MnaZ8VaF/0ug== X-Received: by 2002:a17:902:1126:: with SMTP id d35mr21346176pla.1.1548698119705; Mon, 28 Jan 2019 09:55:19 -0800 (PST) Received: from serve.minyard.net (serve.minyard.net. [2001:470:b8f6:1b::1]) by smtp.gmail.com with ESMTPSA id t24sm64300967pfm.127.2019.01.28.09.55.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 28 Jan 2019 09:55:16 -0800 (PST) Received: from t430.minyard.net (unknown [IPv6:2001:470:b8f6:1b:c8f8:7971:e432:a838]) by serve.minyard.net (Postfix) with ESMTPA id 879DEFB0; Mon, 28 Jan 2019 11:55:12 -0600 (CST) Received: by t430.minyard.net (Postfix, from userid 1000) id 2B409301164; Mon, 28 Jan 2019 11:55:10 -0600 (CST) From: minyard@acm.org To: qemu-devel@nongnu.org, "Dr . David Alan Gilbert" Date: Mon, 28 Jan 2019 11:54:55 -0600 Message-Id: <20190128175458.27255-17-minyard@acm.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190128175458.27255-1-minyard@acm.org> References: <20190128175458.27255-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::644 Subject: [Qemu-devel] [PATCH v4 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 , Paolo Bonzini , Corey Minyard , Corey Minyard , "Michael S . Tsirkin" 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)); } }