From nobody Tue Feb 10 22:18:38 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of _spf.google.com designates 209.85.221.42 as permitted sender) client-ip=209.85.221.42; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-wr1-f42.google.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of _spf.google.com designates 209.85.221.42 as permitted sender) smtp.mailfrom=philippe.mathieu.daude@gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1602943381; cv=none; d=zohomail.com; s=zohoarc; b=l+o6Apen3rORjM6/zA2db23Kb4HwCfneId1UFawQM6UMwtwMBwzDooOAGRValStC2fOhdUZ79n4NXqEx9wmpruwBM6YDW1CkqPaKv65sRQTW4V8MilvsLZTm8C2z0DihU3FvsrFGQJ6jpmU1Wc4mnK9PIv0fHJnvby9nHFa6Lj4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1602943381; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Sender:Subject:To; bh=N+6P5UyNzQt64543jNV3+JqEP1ruUMZwDb9XjKLtnVQ=; b=XA71pCe9MQk7ZlZK5TSDKTXvJLCpKusGfB1B4cQsKNQ4bwfxAgWXD+CldamfZ9/z4ZdeHI1CjIiTyxuS19RV6i8iMCSuRixgr/XfvOxtS8Fr5ZB5hnif3wi1gAFlCbo1vgrFGQJTXOhHpDo0ZI+ljdxjmofsLTMsHs4He0CB3C8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of _spf.google.com designates 209.85.221.42 as permitted sender) smtp.mailfrom=philippe.mathieu.daude@gmail.com Received: from mail-wr1-f42.google.com (mail-wr1-f42.google.com [209.85.221.42]) by mx.zohomail.com with SMTPS id 1602943381700276.6139911614571; Sat, 17 Oct 2020 07:03:01 -0700 (PDT) Received: by mail-wr1-f42.google.com with SMTP id x7so6608011wrl.3 for ; Sat, 17 Oct 2020 07:03:01 -0700 (PDT) Return-Path: Return-Path: Received: from localhost.localdomain (117.red-83-52-172.dynamicip.rima-tde.net. [83.52.172.117]) by smtp.gmail.com with ESMTPSA id x18sm9349551wrg.4.2020.10.17.07.02.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 17 Oct 2020 07:02:59 -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=N+6P5UyNzQt64543jNV3+JqEP1ruUMZwDb9XjKLtnVQ=; b=UokLcAdfIvbxLFzHsZ+I+CiGEmjwM5PeSp77ZmCFFk3RV6ATrDiOffn65e2v7lhduq 7jMmhJEcYCjBJJG2CoPiX6dcTlXZ2kuo2teiO/ZxttnL60Wa04bFnw3HiqcLGaqK7vzQ LdYyr3hVim3AQvLtvbU19ewYtKwT9ynX1D1W2chfWAgvUqjvfXJ/MmFJr7xeqWBm2EwK BDDl9wYhbeouIv4p5X/3maRTAPAqp5ZqpXKIRMiE5ueaiRAYVAS/oltTiFFb+2k5w/GG m/3LUit1+mgriud4JH5Blu+KAVP4YuQCeCiwq+b3HoTSLrx0ygcpXQH6QgFAe29oAOly lrpQ== 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=N+6P5UyNzQt64543jNV3+JqEP1ruUMZwDb9XjKLtnVQ=; b=BulQ54tBFLvwEnNSFrkx1jJwGjECHtN/0BjDEozEZfXcquIIt7J3bvFsPp/IM4KTKD Vy4qt2owBlLphRTBHf/ewKZhyP+JURmZ6a37bSO6Y5r8R6moz6BLf9dyj1u/2FFkgybH OjkkVVISnUYJ458L2uYMKGWQUZtowAjVDPedT7cvXh2wOB++yO6yKSRHvUM1NjtsriKx nFTEXrLvjh5dzP8W0hmCLOiBxW23PCD54j1wwPykENLecYwKbBMGJhUORkWVwblwO81Q EJcDVOqvp9I7dwVpy2F6tlYFoavNk7Ax63X3Bv/fPyI05QYpnuQvtfVglgo7IpLOKxx9 PzWA== X-Gm-Message-State: AOAM5321vwNVBHJBJc/jdMqyF7QXJPczwVJEkhBPj8NBP6vkQ4N2GLzj Ebxm7R5LS+QQL4Qe5C/tSHU= X-Google-Smtp-Source: ABdhPJyqrT+skP3Rc8vENV40BvEMM08JKTFVY/XKZPXcFmyh4Ppc3MLpElduEL+7q18vql3cCLBBDw== X-Received: by 2002:adf:e50b:: with SMTP id j11mr10486045wrm.263.1602943379830; Sat, 17 Oct 2020 07:02:59 -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: Jiaxun Yang , Huacai Chen , Paul Burton , =?UTF-8?q?Herv=C3=A9=20Poussineau?= , Aurelien Jarno , Aleksandar Rikalo , Luc Michel , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PULL 03/44] hw/core/clock: Add the clock_new helper function Date: Sat, 17 Oct 2020 16:02:02 +0200 Message-Id: <20201017140243.1078718-4-f4bug@amsat.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201017140243.1078718-1-f4bug@amsat.org> References: <20201017140243.1078718-1-f4bug@amsat.org> MIME-Version: 1.0 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 Tested-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Philippe Mathieu-Daud=C3=A9 Message-Id: <20201010135759.437903-4-luc@lmichel.fr> 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