+// SPDX-License-Identifier: GPL-2.0+
/*
* Copyright (c) 2013 Google, Inc
*
* (C) Copyright 2012
- *
- * SPDX-License-Identifier: GPL-2.0+
*/
-#include <common.h>
+#include <command.h>
+#include <dm.h>
#include <dm-demo.h>
#include <mapmem.h>
#include <asm/io.h>
struct udevice *demo_dev;
-static int do_demo_hello(cmd_tbl_t *cmdtp, int flag, int argc,
- char * const argv[])
+static int do_demo_hello(struct cmd_tbl *cmdtp, int flag, int argc,
+ char *const argv[])
{
int ch = 0;
return demo_hello(demo_dev, ch);
}
-static int do_demo_status(cmd_tbl_t *cmdtp, int flag, int argc,
- char * const argv[])
+static int do_demo_status(struct cmd_tbl *cmdtp, int flag, int argc,
+ char *const argv[])
{
int status;
int ret;
return 0;
}
-static int do_demo_light(cmd_tbl_t *cmdtp, int flag, int argc,
- char * const argv[])
+static int do_demo_light(struct cmd_tbl *cmdtp, int flag, int argc,
+ char *const argv[])
{
int light;
int ret;
if (argc) {
- light = simple_strtoul(argv[0], NULL, 16);
+ light = hextoul(argv[0], NULL);
ret = demo_set_light(demo_dev, light);
} else {
ret = demo_get_light(demo_dev);
return ret;
}
-int do_demo_list(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+int do_demo_list(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
{
struct udevice *dev;
- int i, ret;
+ int i, ret, err = 0;
puts("Demo uclass entries:\n");
- for (i = 0, ret = uclass_first_device(UCLASS_DEMO, &dev);
+ for (i = 0, ret = uclass_first_device_check(UCLASS_DEMO, &dev);
dev;
- ret = uclass_next_device(&dev)) {
- printf("entry %d - instance %08x, ops %08x, platdata %08x\n",
- i++, map_to_sysmem(dev),
- map_to_sysmem(dev->driver->ops),
- map_to_sysmem(dev_get_platdata(dev)));
+ ret = uclass_next_device_check(&dev)) {
+ printf("entry %d - instance %08x, ops %08x, plat %08x, status %i\n",
+ i++, (uint)map_to_sysmem(dev),
+ (uint)map_to_sysmem(dev->driver->ops),
+ (uint)map_to_sysmem(dev_get_plat(dev)),
+ ret);
+ if (ret)
+ err = ret;
}
- return cmd_process_error(cmdtp, ret);
+ return cmd_process_error(cmdtp, err);
}
-static cmd_tbl_t demo_commands[] = {
+static struct cmd_tbl demo_commands[] = {
U_BOOT_CMD_MKENT(list, 0, 1, do_demo_list, "", ""),
U_BOOT_CMD_MKENT(hello, 2, 1, do_demo_hello, "", ""),
U_BOOT_CMD_MKENT(light, 2, 1, do_demo_light, "", ""),
U_BOOT_CMD_MKENT(status, 1, 1, do_demo_status, "", ""),
};
-static int do_demo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+static int do_demo(struct cmd_tbl *cmdtp, int flag, int argc,
+ char *const argv[])
{
- cmd_tbl_t *demo_cmd;
+ struct cmd_tbl *demo_cmd;
int devnum = 0;
int ret;
return CMD_RET_USAGE;
if (argc) {
- devnum = simple_strtoul(argv[0], NULL, 10);
+ devnum = dectoul(argv[0], NULL);
ret = uclass_get_device(UCLASS_DEMO, devnum, &demo_dev);
if (ret)
return cmd_process_error(cmdtp, ret);
"demo hello <num> [<char>] Say hello\n"
"demo light [<num>] Set or get the lights\n"
"demo status <num> Get demo device status\n"
- "demo list List available demo devices"
);