From patchwork Thu Nov 15 19:24:44 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Corey Minyard X-Patchwork-Id: 151246 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp7407193ljp; Thu, 15 Nov 2018 11:34:42 -0800 (PST) X-Google-Smtp-Source: AJdET5dLN+yPLi4Q/1As9fLFk+HZY2LdJ8aaTjVTYxukNxeAY1QJg8a7VkA/i5CCGe2HSvLbM9su X-Received: by 2002:a0c:e5c1:: with SMTP id u1mr7520875qvm.113.1542310482792; Thu, 15 Nov 2018 11:34:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542310482; cv=none; d=google.com; s=arc-20160816; b=CmWV1DNGTcEr2I/Xa5egxrH6NBPIWmPuOXJ+Rqg/sNeA0OAyhsqq6M2xIuPSIkxhwb MOj0vP3DvZpK2aiF5BMyOrfejz4goUSQrR2rmLupBCdFzy3L1mWQ9hYyLViXGqrVvm2V bn/jcOxF9ePRl8o8KjXdgoxJPIp4bRBxiGOn/Vg+1I2kpiX3ylf5I+aBU70y/7/uG5s4 7GgzxEzJpuD3Vj1YH7G4+QG2gK4z28DuQ5/M9lY560KAuNz4IUc+wj+DTUy9Ugogv6/N rzsIrrqq351ycLRwkH+qZY6PE8jTEz1EnG0/WQV0TilKbQKpaFI1C02cS6sB6zzfiAYO yg9Q== 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:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=WGWZ/A5CWQyjZ9068r1xhryf7pPtyLCsz3dYwI0IRSI=; b=bQsGjwOAj0aYLvqCNWp1Rhv4zupB0aBbpEKY33+Tf6AMbFYrQBbI2B53rCiZujEg9s jEwtAsJOoWZvai4W8sFkvSgapEA//I9iFtAn90hyOM24/TJa1LUcpvg8yrAhFK/EyxkK aH4hP67aTUblYkG/1M11sc94ymcP5SE4wexQqqQMl6T9SQOmn3RnQ1TCCAUqDrCbjKz4 Vgf5Uuf7yCFmxgQSOxkg9PEfWRxVQZG92nSexIiyp4iQ2NOZuLqc0RIb33+IvDFzkZKi W/pdvwZ7uz9dv+VmJ6eu+J99yLhEsqd+djOHL3oUT6N+BH1FWwkFh3xgCHBIuhENR8X9 NiNw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=XUv5Cj1P; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org" Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id t64si371705qkf.154.2018.11.15.11.34.42 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 15 Nov 2018 11:34:42 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=XUv5Cj1P; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org" Received: from localhost ([::1]:40469 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gNNPW-0001WB-63 for patch@linaro.org; Thu, 15 Nov 2018 14:34:42 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56270) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gNNGL-0003YX-MA for qemu-devel@nongnu.org; Thu, 15 Nov 2018 14:25:25 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gNNGB-000838-QA for qemu-devel@nongnu.org; Thu, 15 Nov 2018 14:25:13 -0500 Received: from mail-ot1-x341.google.com ([2607:f8b0:4864:20::341]:41810) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gNNG9-00081p-SV for qemu-devel@nongnu.org; Thu, 15 Nov 2018 14:25:03 -0500 Received: by mail-ot1-x341.google.com with SMTP id u16so18785967otk.8 for ; Thu, 15 Nov 2018 11:25:01 -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; bh=WGWZ/A5CWQyjZ9068r1xhryf7pPtyLCsz3dYwI0IRSI=; b=XUv5Cj1Pp+Uzm59o71pCac2YY4mcigMsnLaTvgej+apopWy3w/l7mAW6wIFt3bgVVa dKAeaKpIMuWtZlFWMxbRXUMgHGuECA/wPtGY6FI8PWyDTXo/k/f17HhlX4pfY7zbqkRd v1ncOcQyyFacQqTDxkc7J99rioVs4Tr7ifzk2Me5b53N37ivAdC9+2u+ImhOkAFWgX9c SbPasSy3jNGV57N5rwEyEEx2VPvHACy8ViNWIkhTrLcyAfXtY4QDiqC/kEIyaOrFjuB7 pfGyLvWlC/SIYVSis+J0wyPOMqppwaSI4zxAOUZCd6lSaZMvKZ7zNf2LMDHa0xxFDhx7 ZCgw== 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; bh=WGWZ/A5CWQyjZ9068r1xhryf7pPtyLCsz3dYwI0IRSI=; b=PinAxb8W+bR57XEiqdPg8+Y18Pvkybn7O8CbhA6zPrTV6SfdVh+J7no+1zKHpw9pee lZK5VE2G6EOzJdWGtdvtJbHELqa4TXRJ+YtmBQVf6N6VrTEXcLtYKeRqclB7HtK4KQW8 WX+wsVb7NZ7NqhSqpb6j3vnNFtqUss4gUD26iV0JehIaQ2OQoevnPvpDO8KLdFqVD1nB 2Cod1it4PXr2tr3XViJuPKL01VyH7PJ9izMrtCdsq3MC2I2O9QznRbT2rlNoM9DrOzvg QelT1tTqYZghofwZeU4cl+DK/pGYFEF6jowh9cM/MGUuHhqXJ3EFYukZ+OyVrrsIyFCF eT9g== X-Gm-Message-State: AGRZ1gJ/7Y/NL0HHaYbJbe/61tOB6yg5SUKo1z9TFgfC/y9trhvCPeVp /qc/mBFeBSnEzAhddDvstQ== X-Received: by 2002:a9d:44df:: with SMTP id p31mr4611758otg.122.1542309900416; Thu, 15 Nov 2018 11:25:00 -0800 (PST) Received: from serve.minyard.net ([47.184.128.64]) by smtp.gmail.com with ESMTPSA id k207sm5384591oih.58.2018.11.15.11.24.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 15 Nov 2018 11:24:57 -0800 (PST) Received: from t430.minyard.net (t430m.minyard.net [192.168.27.3]) by serve.minyard.net (Postfix) with ESMTPA id 996551E5A; Thu, 15 Nov 2018 13:24:51 -0600 (CST) Received: by t430.minyard.net (Postfix, from userid 1000) id 24A0930146D; Thu, 15 Nov 2018 13:24:49 -0600 (CST) From: minyard@acm.org To: qemu-devel@nongnu.org Date: Thu, 15 Nov 2018 13:24:44 -0600 Message-Id: <20181115192446.17187-11-minyard@acm.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181115192446.17187-1-minyard@acm.org> References: <20181115192446.17187-1-minyard@acm.org> 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 v2 10/12] i2c: 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: Paolo Bonzini , Corey Minyard , "Dr . David Alan Gilbert" , minyard@acm.org, "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 --- hw/i2c/smbus_eeprom.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) -- 2.17.1 Reviewed-by: Philippe Mathieu-Daudé diff --git a/hw/i2c/smbus_eeprom.c b/hw/i2c/smbus_eeprom.c index 8d4eed129f..8e9b734c09 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)); } }