From patchwork Thu Feb 28 18:17:07 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Corey Minyard X-Patchwork-Id: 159411 Delivered-To: patch@linaro.org Received: by 2002:ac9:18c7:0:0:0:0:0 with SMTP id i7csp979860oce; Thu, 28 Feb 2019 10:24:32 -0800 (PST) X-Google-Smtp-Source: APXvYqyMiMrWn5OO44YLxSFdt90rCodp1gUEPa1bGn4FOo3VD9l4gFo8j9gYixML9PugTXd95mZ+ X-Received: by 2002:a25:8683:: with SMTP id z3mr749202ybk.216.1551378272371; Thu, 28 Feb 2019 10:24:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551378272; cv=none; d=google.com; s=arc-20160816; b=GwoBk8zOSpV7IBSyW7cp0b5GxUlmrrafCgryGtFY4qG/lirgQ5RIe4YkD6XhqKejeK 6bY9IkzZhS6e1zNWcEYwDASFLS/V8f+r2lPYaZHSMt+2qK9WM9LWuUUoc1cLhZTd/YdU jGtuzu3pWwzQzIxCeSLeAVEiDuzIY8Pi9Oj22q1fRoIpiYLV4EP8wc/MBbiK9EbeA5CR hy7TUq8UNd4lMGz0OH/FZEKXF6NbVGlDhY3EcnHriy2F4ypAEDVEyyXPYPeZiJhU6Z5K GNKh7abzJ/5KKz28ICVJBdImYJLmQRPZQa3eguvcmNi5y7GGffi3CKmBuZlRsP2Hjr89 bgPA== 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=6NzHN8+bT4MvQ1gFeAYgeaVdN5GDDM/VncB+6EIJ1Xw=; b=gZ+l5rdk1ZjvYW7NgtHybh5P5cH3G9QvccdY5V/b2pvhDx+itVkCPFc1RSZIQ+KIzb J91rYdUPa/uyCwpiqJhdMgcryZwy8d1QfU8e/glNvOENw3m8YkXVvrEoJZsfzZuMwCHJ BOFNLuNPcNN6WW55ZZSBN9dl+MsdHmiDUftC8OjlDqFHpHqmPq56TsQ211w460DzxxSE XM6P8S1wij+MXZDXw6kn4YMrPuFK6rX7OMXgB4TnaFaXwmD4KqII0VIgc+PBoxOCJQqm nbfvXG5Xy+Ze2y3DVqlVLQe5WwCgvv9EXWXRaVCRnOYN+NsaUnXemZmTfSAA0FDZZw+w /x2Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b="oZQHgIa/"; 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 r2si10458296ybg.48.2019.02.28.10.24.32 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 28 Feb 2019 10:24:32 -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="oZQHgIa/"; 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]:44562 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gzQMB-0004PL-Q6 for patch@linaro.org; Thu, 28 Feb 2019 13:24:31 -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) 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-Received: by 2002:a9d:5e07:: with SMTP id d7mr644898oti.315.1551377846104; 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) 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 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+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 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) +#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 *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; @@ -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 = 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)); } }