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: 152077 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp340415ljp; Mon, 26 Nov 2018 12:35:26 -0800 (PST) X-Google-Smtp-Source: AFSGD/Wgu1ZgqDZOB/N4hMkmNbMhjMrvwMZgdQx54q5U5FzHwHde7EB3FRhQYGh8YXbnMQSTTjfi X-Received: by 2002:a25:da4a:: with SMTP id n71-v6mr29975028ybf.377.1543264526012; Mon, 26 Nov 2018 12:35:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543264526; cv=none; d=google.com; s=arc-20160816; b=xa486y1y2vIoPMFQeKZb9920EngvOSPwIHgNVp3hbhisOicJKDWzTBXHZziCbvEpMV TcWHgCDeQvVOfcUdmR3qZaCZ3qoPU5hFqGhw9PON4OhArx2jxQiYYQdt3hm0dB2Wt2UD PHLLI9U1RZWwg7UPFtM6CKerI8wbUIcRxSuzznsVRbIrpQ5v8n5cnyW8TBnTnrDAIUQc 0rESlAyW/GB43q6fMovsHXhEbliuTL0oNomuaN7dVYjX7P73D+6XbxyXdp1Wa3NnuKZs GrFp4VugDtn/3KAwCOMhhKXcv6V8SdXOJznYpUf/FryGrvKvHtKnlMewHhzVnSSfat0f ZRng== 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=Y7KbsuCciN5/9HqSHwSWCKdiHKFRMKL4fYimIM/10QE=; b=uwUHqljBWhBumocJ53YfWK75zse6yRkBlmlHZqPb61yXwl06l6gbCNTfVTv+1dHUhH pUEXcIFNVTXoNyrLf/kCg5o7Fch2l/yP3gV6PKxRiHAvzrMo2lLxp6ST6flQsfZgoby5 mBDTQLU+Sbu0I8ei+7xpXaFEP3T5IZQOmg51CEsyJCgnQ+MSmUUbaYMjPjLFdHWJrvjJ ey9hFtteJRBUvZqo2oZGpjO4+lYXRYgkFN/dY0qQWAsD/0gtkpNtfbwZKUuUYW82Owwl M/f/AszCWoxwu80PHNM1FzMMlUqSdONwbE3y2vkhIz76pT1r9zhAkp0bTe5jzYnhcfDj lyNg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=mv2W9vkU; 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 m10si998604ywc.357.2018.11.26.12.35.25 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 26 Nov 2018 12:35:26 -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=mv2W9vkU; 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]:38731 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gRNbJ-0003pA-FV for patch@linaro.org; Mon, 26 Nov 2018 15:35:25 -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-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+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 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)); } }