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: 10684931 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5314D13B5 for ; Thu, 15 Nov 2018 19:33:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 441DB2D09A for ; Thu, 15 Nov 2018 19:33:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 423EC2D0A3; Thu, 15 Nov 2018 19:33:03 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id CF1142D09A for ; Thu, 15 Nov 2018 19:33:02 +0000 (UTC) Received: from localhost ([::1]:40469 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gNNNt-0001WB-B7 for patchwork-qemu-devel@patchwork.kernel.org; Thu, 15 Nov 2018 14:33:01 -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-Google-Smtp-Source: AJdET5cTXuP2JQzlkpkl4JHszIMTEcanzhnlAjFNwi3I9NW4BJ9wQUwVUg27Q9CG7hx4tG6Gj85iNg== 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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(-) 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)); } }