From 7e5f460ec457fe310156e399198a41eb0ce1e98c Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sat, 24 Jul 2021 09:03:29 -0600 Subject: global: Convert simple_strtoul() with hex to hextoul() It is a pain to have to specify the value 16 in each call. Add a new hextoul() function and update the code to use it. Add a proper comment to simple_strtoul() while we are here. Signed-off-by: Simon Glass --- board/gdsys/common/osd.c | 18 +++++++++--------- board/gdsys/common/osd_cmd.c | 16 ++++++++-------- 2 files changed, 17 insertions(+), 17 deletions(-) (limited to 'board/gdsys') diff --git a/board/gdsys/common/osd.c b/board/gdsys/common/osd.c index 679f8f3..dc548ef 100644 --- a/board/gdsys/common/osd.c +++ b/board/gdsys/common/osd.c @@ -284,9 +284,9 @@ static int osd_print(struct cmd_tbl *cmdtp, int flag, int argc, if (!(osd_screen_mask & (1 << screen))) continue; - x = simple_strtoul(argv[1], NULL, 16); - y = simple_strtoul(argv[2], NULL, 16); - color = simple_strtoul(argv[3], NULL, 16); + x = hextoul(argv[1], NULL); + y = hextoul(argv[2], NULL); + color = hextoul(argv[3], NULL); text = argv[4]; charcount = strlen(text); len = (charcount > bufsize) ? bufsize : charcount; @@ -416,13 +416,13 @@ int osd_write(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) char *rp; u16 *wp = buffer; unsigned count = (argc > 4) ? - simple_strtoul(argv[4], NULL, 16) : 1; + hextoul(argv[4], NULL) : 1; if (!(osd_screen_mask & (1 << screen))) continue; - x = simple_strtoul(argv[1], NULL, 16); - y = simple_strtoul(argv[2], NULL, 16); + x = hextoul(argv[1], NULL); + y = hextoul(argv[2], NULL); rp = argv[3]; @@ -431,7 +431,7 @@ int osd_write(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) memcpy(substr, rp, 4); substr[4] = 0; - *wp = simple_strtoul(substr, NULL, 16); + *wp = hextoul(substr, NULL); rp += 4; wp++; @@ -463,8 +463,8 @@ int osd_size(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) return 1; } - x = simple_strtoul(argv[1], NULL, 16); - y = simple_strtoul(argv[2], NULL, 16); + x = hextoul(argv[1], NULL); + y = hextoul(argv[2], NULL); if (!x || (x > 64) || (x > MAX_X_CHARS) || !y || (y > 32) || (y > MAX_Y_CHARS)) { diff --git a/board/gdsys/common/osd_cmd.c b/board/gdsys/common/osd_cmd.c index fe62497..6a9c0b4 100644 --- a/board/gdsys/common/osd_cmd.c +++ b/board/gdsys/common/osd_cmd.c @@ -30,10 +30,10 @@ static int do_osd_write(struct cmd_tbl *cmdtp, int flag, int argc, if (argc < 4 || (strlen(argv[3])) % 2) return CMD_RET_USAGE; - x = simple_strtoul(argv[1], NULL, 16); - y = simple_strtoul(argv[2], NULL, 16); + x = hextoul(argv[1], NULL); + y = hextoul(argv[2], NULL); hexstr = argv[3]; - count = (argc > 4) ? simple_strtoul(argv[4], NULL, 16) : 1; + count = (argc > 4) ? hextoul(argv[4], NULL) : 1; buflen = strlen(hexstr) / 2; @@ -80,9 +80,9 @@ static int do_osd_print(struct cmd_tbl *cmdtp, int flag, int argc, if (argc < 5) return CMD_RET_USAGE; - x = simple_strtoul(argv[1], NULL, 16); - y = simple_strtoul(argv[2], NULL, 16); - color = simple_strtoul(argv[3], NULL, 16); + x = hextoul(argv[1], NULL); + y = hextoul(argv[2], NULL); + color = hextoul(argv[3], NULL); text = argv[4]; for (uclass_first_device(UCLASS_VIDEO_OSD, &dev); @@ -109,8 +109,8 @@ static int do_osd_size(struct cmd_tbl *cmdtp, int flag, int argc, if (argc < 3) return CMD_RET_USAGE; - x = simple_strtoul(argv[1], NULL, 16); - y = simple_strtoul(argv[2], NULL, 16); + x = hextoul(argv[1], NULL); + y = hextoul(argv[2], NULL); for (uclass_first_device(UCLASS_VIDEO_OSD, &dev); dev; -- cgit v1.1