[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v2 03/15] hw/core/clock: add the clock_new helper function
From: |
Philippe Mathieu-Daudé |
Subject: |
Re: [PATCH v2 03/15] hw/core/clock: add the clock_new helper function |
Date: |
Tue, 6 Oct 2020 11:10:14 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.11.0 |
On 10/5/20 9:56 PM, Luc Michel wrote:
> This function creates a clock a parent 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é <f4bug@amsat.org>
> Signed-off-by: Luc Michel <luc@lmichel.fr>
> ---
> include/hw/clock.h | 26 ++++++++++++++++++++++++++
> 1 file changed, 26 insertions(+)
>
> diff --git a/include/hw/clock.h b/include/hw/clock.h
> index c93e6113cd..a67c4c008b 100644
> --- a/include/hw/clock.h
> +++ b/include/hw/clock.h
> @@ -93,10 +93,36 @@ extern const VMStateDescription vmstate_clock;
> *
> * compute the canonical path of the clock (used by log messages)
> */
> void clock_setup_canonical_path(Clock *clk);
>
> +/**
> + * clock_new:
> + * @parent: the clock parent
> + * @name: the clock object name
> + *
> + * Helper function to create a new clock and parent it to @parent. There is
> no
> + * need to call clock_setup_canonical_path on the returned clock as it is
> done
> + * by this function.
> + *
> + * @return the newly created clock
> + */
> +static inline Clock *clock_new(Object *parent, const char *name)
> +{
> + Object *obj;
> + Clock *clk;
> +
> + obj = object_new(TYPE_CLOCK);
> + object_property_add_child(parent, name, obj);
> + object_unref(obj);
> +
> + clk = CLOCK(obj);
> + clock_setup_canonical_path(clk);
Thanks for adding this function. It doesn't seem justified
to have it inlined. Can you move it to hw/core/clock.c?
> +
> + return clk;
> +}
> +
> /**
> * clock_set_callback:
> * @clk: the clock to register the callback into
> * @cb: the callback function
> * @opaque: the argument to the callback
>
- [PATCH v2 00/15] raspi: add the bcm2835 cprman clock manager, Luc Michel, 2020/10/05
- [PATCH v2 03/15] hw/core/clock: add the clock_new helper function, Luc Michel, 2020/10/05
- Re: [PATCH v2 03/15] hw/core/clock: add the clock_new helper function,
Philippe Mathieu-Daudé <=
- [PATCH v2 01/15] hw/core/clock: provide the VMSTATE_ARRAY_CLOCK macro, Luc Michel, 2020/10/05
- [PATCH v2 02/15] hw/core/clock: trace clock values in Hz instead of ns, Luc Michel, 2020/10/05
- [PATCH v2 04/15] hw/arm/raspi: fix CPRMAN base address, Luc Michel, 2020/10/05
- [PATCH v2 06/15] hw/misc/bcm2835_cprman: add a PLL skeleton implementation, Luc Michel, 2020/10/05
- [PATCH v2 08/15] hw/misc/bcm2835_cprman: add a PLL channel skeleton implementation, Luc Michel, 2020/10/05
- [PATCH v2 05/15] hw/arm/raspi: add a skeleton implementation of the CPRMAN, Luc Michel, 2020/10/05
- [PATCH v2 07/15] hw/misc/bcm2835_cprman: implement PLLs behaviour, Luc Michel, 2020/10/05
- [PATCH v2 10/15] hw/misc/bcm2835_cprman: add a clock mux skeleton implementation, Luc Michel, 2020/10/05