From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E53E7C433E0 for ; Fri, 26 Jun 2020 21:29:05 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id BA84D20B1F for ; Fri, 26 Jun 2020 21:29:05 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org BA84D20B1F Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=amsat.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:41104 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jovuD-0004KC-1e for qemu-devel@archiver.kernel.org; Fri, 26 Jun 2020 17:29:05 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46420) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jovtY-0003ni-Id; Fri, 26 Jun 2020 17:28:24 -0400 Received: from mail-ej1-f66.google.com ([209.85.218.66]:36482) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jovtX-00016D-0a; Fri, 26 Jun 2020 17:28:24 -0400 Received: by mail-ej1-f66.google.com with SMTP id dr13so10696105ejc.3; Fri, 26 Jun 2020 14:28:22 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=0YBLVGKVflLEOwLhiklGG4a/eSP0ykqicWEX2Ka3r48=; b=gOfydeb4Piv/fG57QgLQkSVW5MUmM8lOoVsBuJiJB9XgCBG0QmQ/3ootySjE1aMgRH ZDBwWL/6lIbG10PaAjsvT1kHcdjoRAidikD1d54mUraacy6ifDMR6gwjLS6XRr2gmpMN 8bRP+lfijdbS6gxeIxNrigtoC49rIehHYiM/NLrJBToc2CagQFIhrG0UPQeaTCfQnC0e Rf1ErucfUpI0ocesw3yTn7EyLJ2NoLDjEGRms0/gJB896yp2TW5IHsIgOv6vBzUKTMr8 NgrP18BWmeQA3vRhqVc5W0br0uINHW9lpbJSuOsKt6gMBbvO2sXSbpZv2Y+okIHnL7qr njUA== X-Gm-Message-State: AOAM532RhZCgSBSxjpWjrsBEwRNECDBOIZVUHxEGzMXgFkW8eSx3QgDY vvmy14N0D37NLJLiBd3JnubhWtrH2Z/NJfzpDMA= X-Google-Smtp-Source: ABdhPJyPN+yDw1b5gGocfKq5L/ID5QSj/wm430bRA+JBDclBYWFB5e9FY6dTsqpedvgzbaYJxMi5IAIH6SIjmG4eK9I= X-Received: by 2002:a17:906:f155:: with SMTP id gw21mr4270582ejb.388.1593206901256; Fri, 26 Jun 2020 14:28:21 -0700 (PDT) MIME-Version: 1.0 References: <20200623072723.6324-1-f4bug@amsat.org> <20200623072723.6324-2-f4bug@amsat.org> In-Reply-To: From: =?UTF-8?Q?Philippe_Mathieu=2DDaud=C3=A9?= Date: Fri, 26 Jun 2020 23:28:09 +0200 Message-ID: Subject: Re: [PATCH v6 1/9] hw/i2c/core: Add i2c_try_create_slave() and i2c_realize_and_unref() To: Peter Maydell Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass client-ip=209.85.218.66; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-ej1-f66.google.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/26 17:28:21 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: 1 X-Spam_score: 0.1 X-Spam_bar: / X-Spam_report: (0.1 / 5.0 requ) BAYES_00=-1.9, FREEMAIL_FORGED_FROMDOMAIN=1, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Corey Minyard , Andrew Jeffery , QEMU Developers , Markus Armbruster , qemu-arm , Joel Stanley , =?UTF-8?Q?C=C3=A9dric_Le_Goater?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" On Fri, Jun 26, 2020 at 8:27 PM Peter Maydell wr= ote: > On Tue, 23 Jun 2020 at 08:27, Philippe Mathieu-Daud=C3=A9 wrote: > > Extract i2c_try_create_slave() and i2c_realize_and_unref() > > from i2c_create_slave(). > > We can now set properties on a I2CSlave before it is realized. > > > > This is in line with the recent qdev/QOM changes merged > > in commit 6675a653d2e. > > > > Reviewed-by: Corey Minyard > > Reviewed-by: C=C3=A9dric Le Goater > > Signed-off-by: Philippe Mathieu-Daud=C3=A9 > > Couple of things I belatedly noticed on this patch, which I don't > think are important enough for me to drop it from my pullreq, > but which I think it would be nice to address in a followup: > > > diff --git a/include/hw/i2c/i2c.h b/include/hw/i2c/i2c.h > > index 4117211565..d6e3d85faf 100644 > > --- a/include/hw/i2c/i2c.h > > +++ b/include/hw/i2c/i2c.h > > @@ -80,6 +80,8 @@ int i2c_send(I2CBus *bus, uint8_t data); > > uint8_t i2c_recv(I2CBus *bus); > > > > DeviceState *i2c_create_slave(I2CBus *bus, const char *name, uint8_t a= ddr); > > +DeviceState *i2c_try_create_slave(const char *name, uint8_t addr); > > +bool i2c_realize_and_unref(DeviceState *dev, I2CBus *bus, Error **errp= ); > > Can we have doc-comments for new global-scope functions, please ? Sure. > > > --- a/hw/i2c/core.c > > +++ b/hw/i2c/core.c > > @@ -267,13 +267,27 @@ const VMStateDescription vmstate_i2c_slave =3D { > > } > > }; > > > > -DeviceState *i2c_create_slave(I2CBus *bus, const char *name, uint8_t a= ddr) > > +DeviceState *i2c_try_create_slave(const char *name, uint8_t addr) > > { > > DeviceState *dev; > > > > dev =3D qdev_new(name); > > qdev_prop_set_uint8(dev, "address", addr); > > - qdev_realize_and_unref(dev, &bus->qbus, &error_fatal); > > + return dev; > > +} > > + > > +bool i2c_realize_and_unref(DeviceState *dev, I2CBus *bus, Error **errp= ) > > +{ > > + return qdev_realize_and_unref(dev, &bus->qbus, errp); > > +} > > + > > +DeviceState *i2c_create_slave(I2CBus *bus, const char *name, uint8_t a= ddr) > > +{ > > + DeviceState *dev; > > + > > + dev =3D i2c_try_create_slave(name, addr); > > + i2c_realize_and_unref(dev, bus, &error_fatal); > > + > > We now have a _try_ function which isn't "same behaviour as > the non-try function, but give me back an error status rather > than just killing QEMU". That seems confusing -- is there a > better name we can use ? Yes, Markus asked me to change that, but as it could be done on top, he didn't block the series. I'll address that next week. > thanks > -- PMM