blob: a0e4e930fcb4f76cee19e7d1ef415c67107446b3 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
#include <getopt.h>
#include <asm/errno.h>
#include <string.h>
#include "debug.h"
uint32_t tsnif_debug;
static int enable_flag(int debug, char *flag)
{
int i;
for(i = 0; i < FLAGS_MAX; i++) {
char *f = debug_flag_name[i];
if (!strcmp(flag, f))
break;
}
if (FLAGS_MAX != i) {
if (!debug)
i += 16;
tsnif_debug |= BIT2NUM(i);
return 0;
}
if (!strcmp(flag, "all")) {
tsnif_debug |= debug ? 0xffff : 0xffff0000;
return 0;
}
return -EINVAL;
}
int debug_parse_flags(int debug, char *flags)
{
char *flag;
int ret = 0, in = 0;
for(;(flag = strtok(flags, ",")) ;flags = NULL, in++)
ret |= enable_flag(debug, flag);
return in ? ret : -EINVAL;
}
|