From nobody Mon Feb 9 19:30:39 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of _spf.google.com designates 209.85.218.49 as permitted sender) client-ip=209.85.218.49; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-ej1-f49.google.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of _spf.google.com designates 209.85.218.49 as permitted sender) smtp.mailfrom=philippe.mathieu.daude@gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1617949487; cv=none; d=zohomail.com; s=zohoarc; b=ENVwHMN6oXPkCjco7dNZt+8vjlFDE5nUVtNEABmGA47EKlfdxTIT7v6/iHkpEYFOm7tEBMQweryrck7b7ql3IADiqIEYVyTM7QhaKK52jlEuoTga/iO6Z1Ypr7PfYXHdn/DyMWp0xA+T6JvuOyTx4qBIAwMcTM9DrerPxZf+vmU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1617949487; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Sender:Subject:To; bh=nDFbUJf+zSiSog/LYin0LAf7wyvK1G5JKV9wmLaTU9M=; b=dEUEtMu8JB43BgxI9JUNBFTCEuADG15YWTMg2oruujgNGQWKf9v6ia9yNvUAebwavs56HgZV9ooXEKbHHm/E8g8Mk643VnziS1GRLkbWqD1PH7lOL78gD/AWWwnBSckRGL/IT+O75JBJr6XmJkpeEu2xT8o69qmWu6ETnUyuRpo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of _spf.google.com designates 209.85.218.49 as permitted sender) smtp.mailfrom=philippe.mathieu.daude@gmail.com Received: from mail-ej1-f49.google.com (mail-ej1-f49.google.com [209.85.218.49]) by mx.zohomail.com with SMTPS id 1617949487218924.5202345649709; Thu, 8 Apr 2021 23:24:47 -0700 (PDT) Received: by mail-ej1-f49.google.com with SMTP id r12so6865686ejr.5 for ; Thu, 08 Apr 2021 23:24:46 -0700 (PDT) Return-Path: Return-Path: Received: from x1w.redhat.com (17.red-88-21-201.staticip.rima-tde.net. [88.21.201.17]) by smtp.gmail.com with ESMTPSA id b21sm711872ejz.123.2021.04.08.23.24.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Apr 2021 23:24:44 -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=nDFbUJf+zSiSog/LYin0LAf7wyvK1G5JKV9wmLaTU9M=; b=uuS4Pk/VAJDOp6Pwxln8iW/mJ4KnaTDRn50NXb+1N5XW12GifvULQ/vjj0op//bMN7 LkAj7c+hNguynBubJgAGCMtSqcXeqwzU8Lmv/GvTxql7KWHFodLx6pLXHBGM2+1PPuZR bfp/fDE5JrTqZ4cznaVDktC2aFy763BbFLvHcOWIMY29k+RvphJ3OEO5fDrfUJsvmMHm /I/IlUxBd8J6ts3c2rxPitHPTCXyogm2DpZ7HKnnQpI9PT1iI/T9d+iwsFtWI9bdU5aV 0kDhAi9dMXLgqAFr03CWuSNjEy2us7nTo42cd+/iYlWT/3AD2MVabsaqyxhyxKfeKB/w 714Q== 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=nDFbUJf+zSiSog/LYin0LAf7wyvK1G5JKV9wmLaTU9M=; b=SFfilcsHWu4kZc0kv2Os8Kvr5f0T+ZwBz8fj8Kv9YamSHN7j934yUOPfQo9oyRLuE0 BXNMLEoe8dEbHtd6aG3WYQrF/9eaJDviLMeFoQKfW2YWRHckYO9pJ4wDvN+uKWoI6aZC w44+UwmrKBFfNXonNe9Qwa0SV4gt9Zr1+S/UvF8pJPWtiTMseY3+BJKLpmronKql/W12 o9ybXzMV1BBmYvOWWINY5d3BwoYK2Xm5kpH+XJP0U6HR2/RCMwoyiyYzfzM6RWgR/RXZ BX0AGL8GFVZi1PdQU1FADzX5U8GJjRBVIllzVIS1AoAmYEobFRrRHdj0L7FqjiEFBgK9 NWZg== X-Gm-Message-State: AOAM533sICofHGmUxANrngM4yqbevX1LJwoqt5d9p+VyDF9x5zN3Z9lK zm/Tj9pJbKvDMtdQF307eGc= X-Google-Smtp-Source: ABdhPJxo+77+8B6ZlCyBZlhyE6lnabwzE/4mu9v6/6AQ6+Trohef5kPe/Q2tCvpfrpxcUzPkBATJUg== X-Received: by 2002:a17:906:e0b:: with SMTP id l11mr14989236eji.111.1617949485397; Thu, 08 Apr 2021 23:24:45 -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: qemu-arm@nongnu.org, Paolo Bonzini , Luc Michel , Peter Maydell , Damien Hedde , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Eduardo Habkost , Marcel Apfelbaum , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= Subject: [RFC PATCH-for-6.1 8/9] hw/clock: Declare clock_new() internally Date: Fri, 9 Apr 2021 08:24:00 +0200 Message-Id: <20210409062401.2350436-9-f4bug@amsat.org> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210409062401.2350436-1-f4bug@amsat.org> References: <20210409062401.2350436-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) To enforce correct API usage, restrict the clock creation to hw/core/. The only possible ways to create a clock are: - Constant clock at the board level Using machine_create_constant_clock() in machine_init() - Propagated clock in QDev Using qdev_init_clock_in() or qdev_init_clock_out() in TYPE_DEVICE instance_init(). Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- hw/core/clock-internal.h | 32 ++++++++++++++++++++++++++++++++ include/hw/clock.h | 13 ------------- hw/core/clock.c | 1 + hw/core/machine.c | 1 + hw/core/qdev-clock.c | 1 + MAINTAINERS | 1 + 6 files changed, 36 insertions(+), 13 deletions(-) create mode 100644 hw/core/clock-internal.h diff --git a/hw/core/clock-internal.h b/hw/core/clock-internal.h new file mode 100644 index 00000000000..2207be74c0f --- /dev/null +++ b/hw/core/clock-internal.h @@ -0,0 +1,32 @@ +/* + * Hardware Clocks + * + * Copyright GreenSocs 2016-2020 + * + * Authors: + * Frederic Konrad + * Damien Hedde + * + * This work is licensed under the terms of the GNU GPL, version 2 or late= r. + * See the COPYING file in the top-level directory. + */ + +#ifndef QEMU_HW_CLOCK_INTERNAL_H +#define QEMU_HW_CLOCK_INTERNAL_H + +#include "hw/clock.h" + +/** + * 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); + +#endif diff --git a/include/hw/clock.h b/include/hw/clock.h index a7187eab95e..47cb65edb32 100644 --- a/include/hw/clock.h +++ b/include/hw/clock.h @@ -109,19 +109,6 @@ 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 a42dc3c3d29..bfa54ca0a93 100644 --- a/hw/core/clock.c +++ b/hw/core/clock.c @@ -14,6 +14,7 @@ #include "qemu/osdep.h" #include "qemu/cutils.h" #include "hw/clock.h" +#include "clock-internal.h" #include "trace.h" =20 #define CLOCK_PATH(_clk) (_clk->canonical_path) diff --git a/hw/core/machine.c b/hw/core/machine.c index 41baf80559d..e8bdcd10854 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -35,6 +35,7 @@ #include "exec/confidential-guest-support.h" #include "hw/virtio/virtio.h" #include "hw/virtio/virtio-pci.h" +#include "clock-internal.h" =20 GlobalProperty hw_compat_5_2[] =3D { { "ICH9-LPC", "smm-compat", "on"}, diff --git a/hw/core/qdev-clock.c b/hw/core/qdev-clock.c index a46384a84b7..09e14009fcd 100644 --- a/hw/core/qdev-clock.c +++ b/hw/core/qdev-clock.c @@ -16,6 +16,7 @@ #include "hw/qdev-clock.h" #include "hw/qdev-core.h" #include "qapi/error.h" +#include "clock-internal.h" =20 /* * qdev_init_clocklist: diff --git a/MAINTAINERS b/MAINTAINERS index 58f342108e9..2b10744169c 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -2925,6 +2925,7 @@ S: Maintained F: include/hw/clock.h F: include/hw/qdev-clock.h F: hw/core/clock.c +F: hw/core/clock-internal.h F: hw/core/clock-vmstate.c F: hw/core/qdev-clock.c F: docs/devel/clocks.rst --=20 2.26.3