From nobody Tue Feb 10 14:33:27 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of _spf.google.com designates 209.85.221.68 as permitted sender) client-ip=209.85.221.68; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-wr1-f68.google.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of _spf.google.com designates 209.85.221.68 as permitted sender) smtp.mailfrom=philippe.mathieu.daude@gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1602350788; cv=none; d=zohomail.com; s=zohoarc; b=UZSikNtI7fbnLbGzsMLdp3LuWUuiEayLF1Y4EwIFhIB1w+UOnhd7cR6RmCtI0QvoCHzaWV1F1D+JyA+7whabI53hiM1uWGhuS4iC7cjhIThnpe93tO/yiYcr6H3GUj+FDgQm+Bwq2HC80N5AVXK4fcPTr6GQiqujhcfDYa53rB0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1602350788; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Sender:Subject:To; bh=MCMj0TR+Fl9dY8Kl27uG0iFSZwgVew5RPBCHaa3rL38=; b=Y+fIPlRb0YXqAQN9xiftbYrDoNpSb/RLcO1SH9Kb11AfRQiEq0lan/wfjpwh1KeztX0l2POnmHx/9Xr/d8e6Zwj/WQITH4+qfGp5PH11E0P2wZXoRjRYtt/LocW8zmggGFsy8bhlc50+Lvl8log74JjDhmYH/Xf/PWa1ltzPJBk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of _spf.google.com designates 209.85.221.68 as permitted sender) smtp.mailfrom=philippe.mathieu.daude@gmail.com Received: from mail-wr1-f68.google.com (mail-wr1-f68.google.com [209.85.221.68]) by mx.zohomail.com with SMTPS id 160235078841234.62591161800492; Sat, 10 Oct 2020 10:26:28 -0700 (PDT) Received: by mail-wr1-f68.google.com with SMTP id t9so13658937wrq.11 for ; Sat, 10 Oct 2020 10:26:27 -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 i11sm16786068wre.32.2020.10.10.10.26.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 10 Oct 2020 10:26:25 -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=VNZIODbJL37JdFqCpr8kQ4CBc8EulYHr0VJqZx/+Orbb5nKbOzCXCSSo5SB0+FF8kZ DnMXv1pEC1DNxu3foBY+noVBDKvyYSdJUOLYqddyKwRkeU/NDFF3nCdbh8uuJY6lK/6J dJx6VTVZ/N7qtjHogWgQ6psBGWpq81OHQ67UVR3iHo0BzhsNqzezDmqFm/7V/HtYmrsq SLmtS/nTXTbWl9jdXDeB3hLY+gKiUHKf2DpZfj1jPMSh5sH9IpIklriETN0+Q9a//ubL viJpNFEgJDbo7sWmjTafCQssG3sIGs5npE3smZJRztLKTv3qS8ZYEC7TAtgD/3ItfCh/ oigQ== 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=M0r1+25uLZFMB0YKrmIRRXfq19INTAkgN3cZDEhk0k8uphgubybML1IAC1ZabzSoNV qVvXVVgzmmRVPm3zo+6J1OyUWoUj3lC6P8N5I2WdxoT9w5bFtRlogkzY7OyqAxso/x7j LHXjUICOXs5arEkyVS4N6W8HvRnT2+A6NPlU7Nz+JIve+LUDluHUYjvOOnsFcbVF6sxV oJWhlXjx7sSPtrRq2xkDMaWOBZsSmhujWkONc6Oo0EG6Xd+5dfDDtUj+EPY/fWnwVJ3c 1I8H0MU1STUBW1zKmdE/ZACOcafu9vo2JUR6tP0tMfvR6GSOTXo+VDb4f/ngx6DwlPsf GGzQ== X-Gm-Message-State: AOAM532Jf6RqEV8hnISWd/TjyUvMmTFjpjSDXpuVP0/tb3YVMJ/PBEUg jjG5kAlUYgfJ7EQB2Aaknng= X-Google-Smtp-Source: ABdhPJz4lAvTPNnGvkCrGFLKN7Vg2JsNstR2Yc01E+EHwOft1i1t+TkkN39/E911C82DJ7yNtbgn8w== X-Received: by 2002:a5d:4d10:: with SMTP id z16mr1004043wrt.360.1602350786429; Sat, 10 Oct 2020 10:26:26 -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: Damien Hedde , =?UTF-8?q?Herv=C3=A9=20Poussineau?= , Huacai Chen , =?UTF-8?q?Alex=20Benn=C3=A9e?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Richard Henderson , Paolo Bonzini , Aurelien Jarno , Huacai Chen , Aleksandar Rikalo , Paul Burton , Jiaxun Yang , Luc Michel Subject: [PATCH v2 04/20] hw/core/clock: add the clock_new helper function Date: Sat, 10 Oct 2020 19:26:01 +0200 Message-Id: <20201010172617.3079633-5-f4bug@amsat.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201010172617.3079633-1-f4bug@amsat.org> References: <20201010172617.3079633-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