From patchwork Mon Nov 26 20:04:32 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Corey Minyard X-Patchwork-Id: 10699145 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 BFE78181D for ; Mon, 26 Nov 2018 20:36:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B0C3F29B20 for ; Mon, 26 Nov 2018 20:36:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A4E6929DE8; Mon, 26 Nov 2018 20:36:26 +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 2ED0B29B20 for ; Mon, 26 Nov 2018 20:36:26 +0000 (UTC) Received: from localhost ([::1]:38748 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gRNcG-0005xr-Oe for patchwork-qemu-devel@patchwork.kernel.org; Mon, 26 Nov 2018 15:36:24 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53717) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gRN81-0001lN-EU for qemu-devel@nongnu.org; Mon, 26 Nov 2018 15:05:14 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gRN7z-0001MB-0I for qemu-devel@nongnu.org; Mon, 26 Nov 2018 15:05:09 -0500 Received: from mail-ot1-x343.google.com ([2607:f8b0:4864:20::343]:40588) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gRN7y-0001Ip-N9 for qemu-devel@nongnu.org; Mon, 26 Nov 2018 15:05:06 -0500 Received: by mail-ot1-x343.google.com with SMTP id s5so17846948oth.7 for ; Mon, 26 Nov 2018 12:05: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 :mime-version:content-transfer-encoding; bh=Y7KbsuCciN5/9HqSHwSWCKdiHKFRMKL4fYimIM/10QE=; b=mv2W9vkUKhhcAk60rNqBXKw70E3e95ztaBbk5zZhytUrWsW6DdxYbXXfzNz0RNsKGY bP1juBNmSuw8zATtwhKOsAi96me+uT6hsfVM4aXnZYrSenVWwLpFVduddIBPbOYnlEk4 wREMOpSn2yHpQFfUv56Yqg2TVBDTaJlqJF0aLDUwbFAc3VPJRNvEwqDYYAxlEKEcriHk FmhhX5fZdBqaLO+8QoiHYgWXU+io3cK6MtWuXrJ7tbI9D32EFWIysJIiHvSm5YfmMWjn ASfPnOE8LzicYfdDCgU5Jrx2g7/TYzRQd+ZJA9apUiOO8F3zrPWcLjVl4FhA8F1n6frq 9G9Q== 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=Y7KbsuCciN5/9HqSHwSWCKdiHKFRMKL4fYimIM/10QE=; b=OKmn4lm2lUyyIPCY13NkJxcgPW44wFkSFrIBGVTm2rkwZxF88f2rFj0FRgzqVkYnmI rf7ScHhR8q/DMOBqwMVSh5vxi1rabt0t1MbfbgmHUVYGFJ1wbEnMRRjKOcaGmLSo+Sje +c+Swy4t40VY8Rs6YcvRfXK/mJkFXzG7lYradqsPh91KqchRa6Zc9Q65jkM338P1vsCm +q9Lbz/c4l//n4pDid7a5UhnjrrlCD+AB6YxhImvlpt0xEh97IcIHh8KmL68kXExgIxF b6B04kWOX5ceS/APiMnP0w+HtFIgzFz4sN7SeeQUOUayV7igIT7KXC+oleFJcMIxc2nG bh+A== X-Gm-Message-State: AA+aEWbgk4yq4aRyEqMzGTr40cc9hwNj1RABcSHE0nJVK9ma3Y9ww7s2 UK/7Rv87Yk5o/51hHGOprw== X-Google-Smtp-Source: AFSGD/XVcz/kwQwpB0LwGjVyNghy90faaK+y8uBWAlpZ55pq3wZsVHbV9s6pzpjnRz0e+dEN0MzNyg== X-Received: by 2002:a05:6830:200d:: with SMTP id e13mr16875340otp.334.1543262701158; Mon, 26 Nov 2018 12:05:01 -0800 (PST) Received: from serve.minyard.net ([47.184.128.64]) by smtp.gmail.com with ESMTPSA id y17sm1116937oie.41.2018.11.26.12.04.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 26 Nov 2018 12:04:58 -0800 (PST) Received: from t430.minyard.net (t430m.minyard.net [192.168.27.3]) by serve.minyard.net (Postfix) with ESMTPA id D660B1EDD; Mon, 26 Nov 2018 14:04:49 -0600 (CST) Received: by t430.minyard.net (Postfix, from userid 1000) id CBCDD30146E; Mon, 26 Nov 2018 14:04:46 -0600 (CST) From: minyard@acm.org To: qemu-devel@nongnu.org, "Dr . David Alan Gilbert" , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Peter Maydell Date: Mon, 26 Nov 2018 14:04:32 -0600 Message-Id: <20181126200435.23408-14-minyard@acm.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181126200435.23408-1-minyard@acm.org> References: <20181126200435.23408-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::343 Subject: [Qemu-devel] [PATCH v3 13/16] 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: Paolo Bonzini , Corey Minyard , Corey Minyard , "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)); } }