From nobody Tue Feb 10 06:07:30 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of _spf.google.com designates 209.85.221.67 as permitted sender) client-ip=209.85.221.67; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-wr1-f67.google.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of _spf.google.com designates 209.85.221.67 as permitted sender) smtp.mailfrom=philippe.mathieu.daude@gmail.com; dmarc=fail(p=none dis=none) header.from=amsat.org ARC-Seal: i=1; a=rsa-sha256; t=1602496709; cv=none; d=zohomail.com; s=zohoarc; b=kWHcE0L5jTk/BjSQ5mC5Yyc7TO+0EYee7L0c6U4ept9PZALk6HLVqbf7zNSDl02rQxTCMOsnsZsdEXp7TvWY5Fkxqr2pZKNU+1Aq3tgrZxWsjN+27CuNuLF3Cc8tVbIpNOoxUn0Veb0UCjmhn7+hemd5HPSjWBOuB97fF2OAPP0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1602496709; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Sender:Subject:To; bh=MCMj0TR+Fl9dY8Kl27uG0iFSZwgVew5RPBCHaa3rL38=; b=TeRKKLJ/2VN3HwPdiK2eCgEgQwhsGT6OxQqYagcl1+LeZmbmReyVM8AaIxL2Q8r/kUtvUJKR83Fm4LnZvM8tZ95U0gNWuD+jEpTamqI0QUIn6Rm1hIbQPDGLi/9HJTJEaq3/DrtRYT/sGD/YgqT2s5XH+WJEFM20s17yZcpSxz8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of _spf.google.com designates 209.85.221.67 as permitted sender) smtp.mailfrom=philippe.mathieu.daude@gmail.com; dmarc=fail header.from= (p=none dis=none) header.from= Received: from mail-wr1-f67.google.com (mail-wr1-f67.google.com [209.85.221.67]) by mx.zohomail.com with SMTPS id 1602496709757820.365148600446; Mon, 12 Oct 2020 02:58:29 -0700 (PDT) Received: by mail-wr1-f67.google.com with SMTP id e17so18417299wru.12 for ; Mon, 12 Oct 2020 02:58:29 -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 o4sm5818180wrv.8.2020.10.12.02.58.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Oct 2020 02:58:27 -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=dFmegpwxb8euMMRQQEGMouVsG2+0bmiCmTc0ht6OmWPSLFoSoSMjMpADS5CUOatHvg DQr5Wm7vAKUd7yPABbRsudghPUAhLKC7yT3RfcwGdno1nmgLNpiDOM1f3ZgzrFGhHoaQ T8UlI23l9kcsPTzqhyAM2N/YS1OKnHQgQMymlhZrQ7bo6qHorS2YJ7Kp7LbYkzo6BhYz 872jVlV0QZuOblFYoZNfBdK/1YsUjsODx29mYRBO2GfVK0fMFq14q9+jVWcYuIR8ZUeu U5Q+Oe7Q5gel/TsmRi7ks2TIm7K25tZJeZk7DyTt4mybBZ6eq1IVTYQy/RELLevpmV1E IfIg== 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=Dzy535/IGThVqzI3M6FUCsmQ+dik2/AmQ9DjqsNyfjVPjgJQSMnq4oZsq61Q4zfb/c EPzLiD5wHBKTwVzk+RV6z0T3o8kEKL2FacSMdFLV1bVV3vZ+GqQokIFGHd0pRUW4pTzm qPLhGioDAlRG6IAVNOoOgiv9YbsJ8G5l4sAMeW/yd6qzsDYQ5a2nv6tHIzkogb42Wcay c5RxsqEB2kzNz4mmCbbeCoBiwR/117/asYy/FOUR1jFV8cvI7B7UHXmq6b29e/JOk8yD /6QAT1CZsZAlzpQPYXKDDSVbjRFavxoAw2NZgPzbtFEOIbVv9qOPtKXqdoSCgjUgJvic nQ7A== X-Gm-Message-State: AOAM532PA/euZNLNhRXOEr4HlkwhYOm85BgofSGBfVGXB4INRTtjGDxe 4m/as24VCHtmf4/dcrLxm9I= X-Google-Smtp-Source: ABdhPJwFbeoXx9XHDBEuZvQYFu1qwSYmmyjHufFRObDw6JwXbGePhOXWueLuA/0O56yomKzXYNqYwg== X-Received: by 2002:adf:de89:: with SMTP id w9mr6094617wrl.212.1602496707924; Mon, 12 Oct 2020 02:58: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?= , Paolo Bonzini , Luc Michel , Eduardo Habkost , Aleksandar Rikalo , Huacai Chen , Paul Burton , Huacai Chen , Aurelien Jarno , Damien Hedde , Richard Henderson , Jiaxun Yang , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?Herv=C3=A9=20Poussineau?= Subject: [PATCH v4 04/21] hw/core/clock: add the clock_new helper function Date: Mon, 12 Oct 2020 11:57:47 +0200 Message-Id: <20201012095804.3335117-5-f4bug@amsat.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201012095804.3335117-1-f4bug@amsat.org> References: <20201012095804.3335117-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