[{"id":1782372,"web_url":"http://patchwork.ozlabs.org/comment/1782372/","msgid":"<6f338f6a-c6cb-19e8-2d6b-48f4a931c7da@amsat.org>","list_archive_url":null,"date":"2017-10-08T21:35:37","subject":"Re: [Qemu-devel] [PATCH v2 3/6] smbus: add a\n\tsmbus_eeprom_init_one() routine","submitter":{"id":70924,"url":"http://patchwork.ozlabs.org/api/people/70924/","name":"Philippe Mathieu-Daudé","email":"f4bug@amsat.org"},"content":"On 09/20/2017 04:01 AM, Cédric Le Goater wrote:\n> This is an helper routine to add a single EEPROM on an I2C bus. It can\n> be directly used by smbus_eeprom_init() which adds a certain number of\n> EEPROMs on mips and x86 machines.\n> \n> Signed-off-by: Cédric Le Goater <clg@kaod.org>\n\nReviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>\n\n> ---\n>  hw/i2c/smbus_eeprom.c  | 16 +++++++++++-----\n>  include/hw/i2c/smbus.h |  1 +\n>  2 files changed, 12 insertions(+), 5 deletions(-)\n> \n> diff --git a/hw/i2c/smbus_eeprom.c b/hw/i2c/smbus_eeprom.c\n> index b13ec0fe7a2a..2d24a4cd59bf 100644\n> --- a/hw/i2c/smbus_eeprom.c\n> +++ b/hw/i2c/smbus_eeprom.c\n> @@ -140,6 +140,16 @@ static void smbus_eeprom_register_types(void)\n>  \n>  type_init(smbus_eeprom_register_types)\n>  \n> +void smbus_eeprom_init_one(I2CBus *smbus, uint8_t address, uint8_t *eeprom_buf)\n> +{\n> +    DeviceState *dev;\n> +\n> +    dev = qdev_create((BusState *) smbus, \"smbus-eeprom\");\n> +    qdev_prop_set_uint8(dev, \"address\", address);\n> +    qdev_prop_set_ptr(dev, \"data\", eeprom_buf);\n> +    qdev_init_nofail(dev);\n> +}\n> +\n>  void smbus_eeprom_init(I2CBus *smbus, int nb_eeprom,\n>                         const uint8_t *eeprom_spd, int eeprom_spd_size)\n>  {\n> @@ -150,10 +160,6 @@ void smbus_eeprom_init(I2CBus *smbus, int nb_eeprom,\n>      }\n>  \n>      for (i = 0; i < nb_eeprom; i++) {\n> -        DeviceState *eeprom;\n> -        eeprom = qdev_create((BusState *)smbus, \"smbus-eeprom\");\n> -        qdev_prop_set_uint8(eeprom, \"address\", 0x50 + i);\n> -        qdev_prop_set_ptr(eeprom, \"data\", eeprom_buf + (i * 256));\n> -        qdev_init_nofail(eeprom);\n> +        smbus_eeprom_init_one(smbus, 0x50 + i, eeprom_buf + (i * 256));\n>      }\n>  }\n> diff --git a/include/hw/i2c/smbus.h b/include/hw/i2c/smbus.h\n> index 544bbc19574f..666cdeb04c07 100644\n> --- a/include/hw/i2c/smbus.h\n> +++ b/include/hw/i2c/smbus.h\n> @@ -77,6 +77,7 @@ int smbus_read_block(I2CBus *bus, uint8_t addr, uint8_t command, uint8_t *data);\n>  int smbus_write_block(I2CBus *bus, uint8_t addr, uint8_t command, uint8_t *data,\n>                        int len);\n>  \n> +void smbus_eeprom_init_one(I2CBus *smbus, uint8_t address, uint8_t *eeprom_buf);\n>  void smbus_eeprom_init(I2CBus *smbus, int nb_eeprom,\n>                         const uint8_t *eeprom_spd, int size);\n>  \n>","headers":{"Return-Path":"<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@bilbo.ozlabs.org","Authentication-Results":["ozlabs.org;\n\tspf=pass (mailfrom) smtp.mailfrom=nongnu.org\n\t(client-ip=2001:4830:134:3::11; helo=lists.gnu.org;\n\tenvelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org;\n\treceiver=<UNKNOWN>)","ozlabs.org;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tunprotected) header.d=gmail.com header.i=@gmail.com\n\theader.b=\"SNg0GWYJ\"; dkim-atps=neutral"],"Received":["from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11])\n\t(using TLSv1 with cipher AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3y9MLG00yCz9t3Z\n\tfor <incoming@patchwork.ozlabs.org>;\n\tMon,  9 Oct 2017 11:58:12 +1100 (AEDT)","from localhost ([::1]:55637 helo=lists.gnu.org)\n\tby lists.gnu.org with esmtp (Exim 4.71) (envelope-from\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>)\n\tid 1e1MOW-0001VL-B7\n\tfor incoming@patchwork.ozlabs.org; Sun, 08 Oct 2017 20:58:08 -0400","from eggs.gnu.org ([2001:4830:134:3::10]:50694)\n\tby lists.gnu.org with esmtp (Exim 4.71)\n\t(envelope-from <philippe.mathieu.daude@gmail.com>)\n\tid 1e1MOB-0001VF-7Y\n\tfor qemu-devel@nongnu.org; Sun, 08 Oct 2017 20:57:48 -0400","from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)\n\t(envelope-from <philippe.mathieu.daude@gmail.com>)\n\tid 1e1MO8-0007bv-3Z\n\tfor qemu-devel@nongnu.org; Sun, 08 Oct 2017 20:57:47 -0400","from mail-qt0-x241.google.com ([2607:f8b0:400d:c0d::241]:52271)\n\tby eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16)\n\t(Exim 4.71) (envelope-from <philippe.mathieu.daude@gmail.com>)\n\tid 1e1MO7-0007bQ-UJ; Sun, 08 Oct 2017 20:57:44 -0400","by mail-qt0-x241.google.com with SMTP id o52so40428636qtc.9;\n\tSun, 08 Oct 2017 17:57:43 -0700 (PDT)","from [150.168.2.172] (200-127-152-82.net.prima.net.ar.\n\t[200.127.152.82]) by smtp.gmail.com with ESMTPSA id\n\tw8sm4103291qka.88.2017.10.08.17.57.40\n\t(version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);\n\tSun, 08 Oct 2017 17:57:42 -0700 (PDT)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;\n\th=sender:subject:to:cc:references:from:message-id:date:user-agent\n\t:mime-version:in-reply-to:content-language:content-transfer-encoding; \n\tbh=vUeOsSFZIvZxn1LH7LCUcf81nYygLB1tdFBUKDbOmkE=;\n\tb=SNg0GWYJO4CvqvAHMfp2fxP07aY2Qho25rmFjhrQtl89y0FCiN+yDmDkzFLMAqOWwS\n\t/YZunl4b4HBQ8NIZPI3I97J4LhdgFKV0WsI9wugiuGEVwYYsXgUDkqVJmoaQSD2/uB50\n\tneMG5jRahf3nLeheCop7MD0OlrY9xP1BsEX2wb/3ODGmnwMQYFR/qxC9NNJYOY1xUngC\n\tVszbU0pppr08cZe7MQkUysv5jFrNqlhp9p6KNVkCrwL3tfUDzwyvWluUYtDe9O3o483u\n\tgbRZ7wzr4q4BbN+SBtvDBQWHDIkpYh/yBJ4xmp7qoD+0z9LXP65rDz8xRtHC/j086+0T\n\tRaYg==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:sender:subject:to:cc:references:from:message-id\n\t:date:user-agent:mime-version:in-reply-to:content-language\n\t:content-transfer-encoding;\n\tbh=vUeOsSFZIvZxn1LH7LCUcf81nYygLB1tdFBUKDbOmkE=;\n\tb=JGTqCN3RducEB7DxuJdQZ5RYPpxo+UGCkcT8q9UhrjV8tSmp4Zq+Mjigu9UXx/+K17\n\tu2DNS+ZzWGvKrlVTjbsqjJV3Txe2qv63v0Cn0AcOXblgdSLVDeMvTu/BPsXCGuxPOZc7\n\t5/MsmkE05z+Yvvn5oh2GPHtWp9TmL2xn+ROv1hE1XsjtB9WgueFpXQZBDyu6f9smOqXB\n\ttdWxQdQ+E0qUon1TpdrtKAq5GSBxJKmx3eknFEljkI5W0ZAKR81AFX3DlmPruffmjhTL\n\tmde8g0KWF0I5qSmRfVwTdWK2YNSza4cA85zxMz4eHxXOoi+Rew4QrhK9fUviVBH3odgX\n\tllqQ==","X-Gm-Message-State":"AMCzsaWuz5NqQu7xs27LO7/ys7saL23HPxx20qpWIOCn/ElPQNjeLCSO\n\tQW2jkdB6wPGH5ZYflfP5Lrg=","X-Google-Smtp-Source":"AOwi7QBkcqGWJxbSHVqXFa58pV/4ImDarJxhn5to4yYNG0VcMDL1hFAmSBC6hI77y62m6E6ssTvcOQ==","X-Received":"by 10.200.46.146 with SMTP id h18mr12768783qta.100.1507510662995;\n\tSun, 08 Oct 2017 17:57:42 -0700 (PDT)","To":"=?utf-8?q?C=C3=A9dric_Le_Goater?= <clg@kaod.org>","References":"<20170920070135.31379-1-clg@kaod.org>\n\t<20170920070135.31379-4-clg@kaod.org>","From":"=?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= <f4bug@amsat.org>","Message-ID":"<6f338f6a-c6cb-19e8-2d6b-48f4a931c7da@amsat.org>","Date":"Sun, 8 Oct 2017 18:35:37 -0300","User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101\n\tThunderbird/52.3.0","MIME-Version":"1.0","In-Reply-To":"<20170920070135.31379-4-clg@kaod.org>","Content-Type":"text/plain; charset=utf-8","Content-Language":"en-US","Content-Transfer-Encoding":"8bit","X-detected-operating-system":"by eggs.gnu.org: Genre and OS details not\n\trecognized.","X-Received-From":"2607:f8b0:400d:c0d::241","Subject":"Re: [Qemu-devel] [PATCH v2 3/6] smbus: add a\n\tsmbus_eeprom_init_one() routine","X-BeenThere":"qemu-devel@nongnu.org","X-Mailman-Version":"2.1.21","Precedence":"list","List-Id":"<qemu-devel.nongnu.org>","List-Unsubscribe":"<https://lists.nongnu.org/mailman/options/qemu-devel>,\n\t<mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>","List-Archive":"<http://lists.nongnu.org/archive/html/qemu-devel/>","List-Post":"<mailto:qemu-devel@nongnu.org>","List-Help":"<mailto:qemu-devel-request@nongnu.org?subject=help>","List-Subscribe":"<https://lists.nongnu.org/mailman/listinfo/qemu-devel>,\n\t<mailto:qemu-devel-request@nongnu.org?subject=subscribe>","Cc":"Andrew Jeffery <andrew@aj.id.au>,\n\tPeter Maydell <peter.maydell@linaro.org>, \n\tqemu-arm@nongnu.org, qemu-devel@nongnu.org, Joel Stanley <joel@jms.id.au>","Errors-To":"qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org","Sender":"\"Qemu-devel\"\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>"}}]