]> Git Repo - J-u-boot.git/blobdiff - cmd/cyclic.c
Subtree merge tag 'v6.12-dts' of dts repo [1] into dts/upstream
[J-u-boot.git] / cmd / cyclic.c
index 946f1d78184d2cb5276723d62303f4f2628560a5..339dd4a7bceb8552851ff8b42b1403c74572a544 100644 (file)
@@ -8,20 +8,23 @@
  * Copyright (C) 2022 Stefan Roese <[email protected]>
  */
 
-#include <common.h>
 #include <command.h>
 #include <cyclic.h>
 #include <div64.h>
 #include <malloc.h>
+#include <time.h>
+#include <vsprintf.h>
 #include <linux/delay.h>
+#include <linux/kernel.h>
 
 struct cyclic_demo_info {
+       struct cyclic_info cyclic;
        uint delay_us;
 };
 
-static void cyclic_demo(void *ctx)
+static void cyclic_demo(struct cyclic_info *c)
 {
-       struct cyclic_demo_info *info = ctx;
+       struct cyclic_demo_info *info = container_of(c, struct cyclic_demo_info, cyclic);
 
        /* Just a small dummy delay here */
        udelay(info->delay_us);
@@ -31,7 +34,6 @@ static int do_cyclic_demo(struct cmd_tbl *cmdtp, int flag, int argc,
                          char *const argv[])
 {
        struct cyclic_demo_info *info;
-       struct cyclic_info *cyclic;
        uint time_ms;
 
        if (argc < 3)
@@ -47,10 +49,7 @@ static int do_cyclic_demo(struct cmd_tbl *cmdtp, int flag, int argc,
        info->delay_us = simple_strtoul(argv[2], NULL, 0);
 
        /* Register demo cyclic function */
-       cyclic = cyclic_register(cyclic_demo, time_ms * 1000, "cyclic_demo",
-                                info);
-       if (!cyclic)
-               printf("Registering of cyclic_demo failed\n");
+       cyclic_register(&info->cyclic, cyclic_demo, time_ms * 1000, "cyclic_demo");
 
        printf("Registered function \"%s\" to be executed all %dms\n",
               "cyclic_demo", time_ms);
@@ -76,9 +75,9 @@ static int do_cyclic_list(struct cmd_tbl *cmdtp, int flag, int argc,
        return 0;
 }
 
-static char cyclic_help_text[] =
+U_BOOT_LONGHELP(cyclic,
        "demo <cycletime_ms> <delay_us> - register cyclic demo function\n"
-       "cyclic list - list cyclic functions\n";
+       "cyclic list - list cyclic functions\n");
 
 U_BOOT_CMD_WITH_SUBCMDS(cyclic, "Cyclic", cyclic_help_text,
        U_BOOT_SUBCMD_MKENT(demo, 3, 1, do_cyclic_demo),
This page took 0.027279 seconds and 4 git commands to generate.