From nobody Sat Feb 7 06:54:29 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of _spf.google.com designates 209.85.128.68 as permitted sender) client-ip=209.85.128.68; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-wm1-f68.google.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of _spf.google.com designates 209.85.128.68 as permitted sender) smtp.mailfrom=philippe.mathieu.daude@gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1602362609; cv=none; d=zohomail.com; s=zohoarc; b=N3y3CSpNu7ePkAabBHJbVQqH/xKI3jJi80GOKYhignb8UZQ1MSaUuGXIYU4G0Jix7Uy2lzMKjbj9EDLP9DM5udJ20c8pPmtdOSexU5CmdoplezZLWmC7oJqNPYYqGRcQC/HGL040NAxX8gfACz28Uer9OfPGTcLarvNAZp9qKrg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1602362609; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Sender:Subject:To; bh=MCMj0TR+Fl9dY8Kl27uG0iFSZwgVew5RPBCHaa3rL38=; b=Y2kqlvWXtcM60ARLN2lXw3FS87SDycgHLekZC0TvjVAbO52TbNzBLMlaaY9IPj+Gh5H6D7sjyivVGywWxDLBMTZASPvXA2rbgP+eOqsoAW6yLkgYP+WmMmE4MTAAML6PMP+XN+fDW1nPE4jvWR3u4BZPm21qnax8TATfdT6Hh+A= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of _spf.google.com designates 209.85.128.68 as permitted sender) smtp.mailfrom=philippe.mathieu.daude@gmail.com Received: from mail-wm1-f68.google.com (mail-wm1-f68.google.com [209.85.128.68]) by mx.zohomail.com with SMTPS id 1602362609260805.52319490911; Sat, 10 Oct 2020 13:43:29 -0700 (PDT) Received: by mail-wm1-f68.google.com with SMTP id p15so13281214wmi.4 for ; Sat, 10 Oct 2020 13:43:28 -0700 (PDT) Return-Path: Return-Path: Received: from localhost.localdomain (106.red-83-59-162.dynamicip.rima-tde.net. [83.59.162.106]) by smtp.gmail.com with ESMTPSA id 205sm2705471wme.38.2020.10.10.13.43.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 10 Oct 2020 13:43:26 -0700 (PDT) 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=MCMj0TR+Fl9dY8Kl27uG0iFSZwgVew5RPBCHaa3rL38=; b=ZuqtjKpT5MXbZVwy+FCYabCWRL6j3TgGf5uHfwWaDOUujD/i3aHxKCH9SdbSTmCRE7 Ldrjq3hdIkTevQpyVltIu4Ik78DmwkNiJmvYyUSmf6qUNz/sNbdPcoVfc1HqrwtlQUi+ S5K2387QYUddiFSrOYNZabGxI8eEpmRm8067t6B7LQVe88FIvIWV4s+G9MFbB9+RzsGc vUh52T2qn3xdsmoTxet8kBKxF0QFYOozKtlXeFWFguFyL3pHdnNx2TCUmtXYlzxr8jJW gxJDTb9rBFmRGNYghxQ02OcOoX+jHHGizV0rg0pT2l+dvV7J5UdY4G7emSMi/elejCmy YE9w== 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=MCMj0TR+Fl9dY8Kl27uG0iFSZwgVew5RPBCHaa3rL38=; b=i/MbO+fT9xp/+NLFB/4BSp6DjtjnPAuAtKhcJx8hB6Al9wQ/NXBDUfE2W4llPiAa2h o1xDhBZW9OIrCnupRPKU2g0vtJXlerm//Ttokm97z4dHfh0KHQ4GkT1RAKXLO4WJnOC5 pJmwSdd86huYiFK5VQZCCd5FN79yY3djntp6yS020Bs/yMztNwSnXcTjeuHquJbUj+TI gdOw8mot/Nkf+a7RvcP2ADM43iqkoIRMBdqHX3qP++0gjXzia46GtrOh09DbPkSYwS6r jEYq+4koBYV3r5U7DGCFlKFOLYcj+zbSxN5IH6x4VOKD9U8pgJwBRsP5DmoyXHwg+A38 Z8ZA== X-Gm-Message-State: AOAM530/hGNDEbeIquh5BpoGrC32gA8EwNFurUgZHPDdkW1LERMGmEo8 Shj/ZAziEuMMaXofTFPseTOF7YSUdcM= X-Google-Smtp-Source: ABdhPJwwKkazENrdC7jgR5WP9EMaZvakRFVl6PX+zsV16ZunlWBU1LR8Hi7WFFbadpmjmkfe72dMGA== X-Received: by 2002:a1c:2cc4:: with SMTP id s187mr3910567wms.36.1602362607246; Sat, 10 Oct 2020 13:43:27 -0700 (PDT) Sender: =?UTF-8?Q?Philippe_Mathieu=2DDaud=C3=A9?= From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Alex=20Benn=C3=A9e?= , Huacai Chen , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Damien Hedde , Paul Burton , Luc Michel , Aleksandar Rikalo , Huacai Chen , Richard Henderson , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Eduardo Habkost , =?UTF-8?q?Herv=C3=A9=20Poussineau?= , Paolo Bonzini , Aurelien Jarno , Jiaxun Yang Subject: [PATCH v3 04/20] hw/core/clock: add the clock_new helper function Date: Sat, 10 Oct 2020 22:43:03 +0200 Message-Id: <20201010204319.3119239-5-f4bug@amsat.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201010204319.3119239-1-f4bug@amsat.org> References: <20201010204319.3119239-1-f4bug@amsat.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) From: Luc Michel This function creates a clock and parents it to another object with a given name. It calls clock_setup_canonical_path before returning the new clock. This function is useful to create clocks in devices when one doesn't want to expose it at the qdev level (as an input or an output). Suggested-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Luc Michel Message-Id: <20201010135759.437903-4-luc@lmichel.fr> Reviewed-by: Philippe Mathieu-Daud=C3=A9 Tested-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- include/hw/clock.h | 13 +++++++++++++ hw/core/clock.c | 15 +++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/include/hw/clock.h b/include/hw/clock.h index d357594df99..cbc5e6ced1e 100644 --- a/include/hw/clock.h +++ b/include/hw/clock.h @@ -90,6 +90,19 @@ extern const VMStateDescription vmstate_clock; */ void clock_setup_canonical_path(Clock *clk); =20 +/** + * clock_new: + * @parent: the clock parent + * @name: the clock object name + * + * Helper function to create a new clock and parent it to @parent. There i= s no + * need to call clock_setup_canonical_path on the returned clock as it is = done + * by this function. + * + * @return the newly created clock + */ +Clock *clock_new(Object *parent, const char *name); + /** * clock_set_callback: * @clk: the clock to register the callback into diff --git a/hw/core/clock.c b/hw/core/clock.c index 7066282f7b9..f866717a835 100644 --- a/hw/core/clock.c +++ b/hw/core/clock.c @@ -23,6 +23,21 @@ void clock_setup_canonical_path(Clock *clk) clk->canonical_path =3D object_get_canonical_path(OBJECT(clk)); } =20 +Clock *clock_new(Object *parent, const char *name) +{ + Object *obj; + Clock *clk; + + obj =3D object_new(TYPE_CLOCK); + object_property_add_child(parent, name, obj); + object_unref(obj); + + clk =3D CLOCK(obj); + clock_setup_canonical_path(clk); + + return clk; +} + void clock_set_callback(Clock *clk, ClockCallback *cb, void *opaque) { clk->callback =3D cb; --=20 2.26.2