]> git.ipfire.org Git - people/ms/u-boot.git/blob - board/hymod/input.c
Add GPL-2.0+ SPDX-License-Identifier to source files
[people/ms/u-boot.git] / board / hymod / input.c
1 /*
2 * (C) Copyright 2003
3 * Murray Jensen, CSIRO-MIT, <Murray.Jensen@csiro.au>
4 *
5 * SPDX-License-Identifier: GPL-2.0+
6 */
7
8 #include <common.h>
9
10 int
11 hymod_get_serno (const char *prompt)
12 {
13 for (;;) {
14 int n, serno;
15 char *p;
16
17 #ifdef CONFIG_BOOT_RETRY_TIME
18 reset_cmd_timeout ();
19 #endif
20
21 n = readline (prompt);
22
23 if (n < 0)
24 return (n);
25
26 if (n == 0)
27 continue;
28
29 serno = (int) simple_strtol (console_buffer, &p, 10);
30
31 if (p > console_buffer && *p == '\0' && serno > 0)
32 return (serno);
33
34 printf ("Invalid number (%s) - please re-enter\n",
35 console_buffer);
36 }
37 }
38
39 int
40 hymod_get_ethaddr (void)
41 {
42 for (;;) {
43 int n;
44
45 #ifdef CONFIG_BOOT_RETRY_TIME
46 reset_cmd_timeout ();
47 #endif
48
49 n = readline ("Enter board ethernet address: ");
50
51 if (n < 0)
52 return (n);
53
54 if (n == 0)
55 continue;
56
57 if (n == 17) {
58 int i;
59 char *p, *q;
60
61 /* see if it looks like an ethernet address */
62
63 p = console_buffer;
64
65 for (i = 0; i < 6; i++) {
66 char term = (i == 5 ? '\0' : ':');
67
68 (void)simple_strtol (p, &q, 16);
69
70 if ((q - p) != 2 || *q++ != term)
71 break;
72
73 p = q;
74 }
75
76 if (i == 6) {
77 /* it looks ok - set it */
78 printf ("Setting ethernet addr to %s\n",
79 console_buffer);
80
81 setenv ("ethaddr", console_buffer);
82
83 puts ("Remember to do a 'saveenv' to "
84 "make it permanent\n");
85
86 return (0);
87 }
88 }
89
90 printf ("Invalid ethernet addr (%s) - please re-enter\n",
91 console_buffer);
92 }
93 }