[PATCH v2 2/2] timer: Return count from timer_ops.get_count

Simon Glass sjg at chromium.org
Fri Oct 9 19:23:45 CEST 2020


Hi Sean,

On Wed, 7 Oct 2020 at 12:38, Sean Anderson <seanga2 at gmail.com> wrote:
>
> No timer drivers return an error from get_count. Instead of possibly
> returning an error, just return the count directly.
>
> Signed-off-by: Sean Anderson <seanga2 at gmail.com>
> ---
>
> Changes in v2:
> - mchp-pit64b was added since v1, so convert it
> - Document when get_count may be called, and what assumptions the timer
>   subsystem makes about drivers
>
>  arch/riscv/lib/andes_plmt.c       |  6 ++----
>  arch/riscv/lib/sifive_clint.c     |  6 ++----
>  drivers/timer/ag101p_timer.c      |  5 ++---
>  drivers/timer/altera_timer.c      |  6 ++----
>  drivers/timer/arc_timer.c         |  6 ++----
>  drivers/timer/ast_timer.c         |  6 ++----
>  drivers/timer/atcpit100_timer.c   |  5 ++---
>  drivers/timer/atmel_pit_timer.c   |  6 ++----
>  drivers/timer/cadence-ttc.c       |  6 ++----
>  drivers/timer/dw-apb-timer.c      |  6 ++----
>  drivers/timer/mchp-pit64b-timer.c |  6 ++----
>  drivers/timer/mpc83xx_timer.c     |  6 ++----
>  drivers/timer/mtk_timer.c         |  6 ++----
>  drivers/timer/nomadik-mtu-timer.c |  6 ++----
>  drivers/timer/omap-timer.c        |  6 ++----
>  drivers/timer/ostm_timer.c        |  6 ++----
>  drivers/timer/riscv_timer.c       | 21 +++++++++------------
>  drivers/timer/rockchip_timer.c    |  5 ++---
>  drivers/timer/sandbox_timer.c     |  6 ++----
>  drivers/timer/sti-timer.c         |  6 ++----
>  drivers/timer/stm32_timer.c       |  6 ++----
>  drivers/timer/timer-uclass.c      |  3 ++-
>  drivers/timer/tsc_timer.c         |  6 ++----
>  include/timer.h                   |  9 ++++++---
>  24 files changed, 59 insertions(+), 97 deletions(-)
>

[..]

> diff --git a/include/timer.h b/include/timer.h
> index aa9d870619..a044cb034e 100644
> --- a/include/timer.h
> +++ b/include/timer.h
> @@ -67,11 +67,14 @@ struct timer_ops {
>          *
>          * @dev: The timer device
>          *
> -        * @count: pointer that returns the current 64-bit timer count
> +        * This function may be called at any time after the driver is probed.
> +        * All necessary initialization must be completed by the time probe()
> +        * returns. The count returned by this functions should be monotonic.
> +        * This function must succeed.
>          *
> -        * Return: 0 if OK, -ve on error
> +        * Return: The current 64-bit timer count
>          */
> -       int (*get_count)(struct udevice *dev, u64 *count);
> +       u64 (*get_count)(struct udevice *dev);

We can require this the driver be probed before this is called. We
have the early timer for the pre-DM case.

Reviewed-by: Simon Glass <sjg at chromium.org>

Regards,
Simon


More information about the U-Boot mailing list