Commit 77a4492f authored by Daeseok Youn's avatar Daeseok Youn Committed by Greg Kroah-Hartman

staging: dgap: Simplify set a board type from configration file

Board types need to separate normal command like IO, MEM and so on.
And the board type will come after "board" string in config file normally.
(If it is not, dgap_gettok returns an error with zero)
After that, set a variable of a number which is matched with specific
a board number to "board.type". The dgap_gettok() returns that number so
just set to "board.type" and also "v_type" can be removed.

In case of boards of PCI type are set variables to zero. These can
be removed because "p" as cnode get memory from kzalloc so already
set to zero.
Signed-off-by: default avatarDaeseok Youn <daeseok.youn@gmail.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 35edf11b
...@@ -399,10 +399,7 @@ struct toklist { ...@@ -399,10 +399,7 @@ struct toklist {
char *string; char *string;
}; };
static struct toklist dgap_tlist[] = { static struct toklist dgap_brdtype[] = {
{ BEGIN, "config_begin" },
{ END, "config_end" },
{ BOARD, "board" },
{ PCX, "Digi_AccelePort_C/X_PCI" }, { PCX, "Digi_AccelePort_C/X_PCI" },
{ PEPC, "Digi_AccelePort_EPC/X_PCI" }, { PEPC, "Digi_AccelePort_EPC/X_PCI" },
{ PPCM, "Digi_AccelePort_Xem_PCI" }, { PPCM, "Digi_AccelePort_Xem_PCI" },
...@@ -411,6 +408,13 @@ static struct toklist dgap_tlist[] = { ...@@ -411,6 +408,13 @@ static struct toklist dgap_tlist[] = {
{ APORT8_920P, "Digi_AccelePort_8r_920_PCI" }, { APORT8_920P, "Digi_AccelePort_8r_920_PCI" },
{ PAPORT4, "Digi_AccelePort_4r_PCI(EIA-232/RS-422)" }, { PAPORT4, "Digi_AccelePort_4r_PCI(EIA-232/RS-422)" },
{ PAPORT8, "Digi_AccelePort_8r_PCI(EIA-232/RS-422)" }, { PAPORT8, "Digi_AccelePort_8r_PCI(EIA-232/RS-422)" },
{ 0, NULL }
};
static struct toklist dgap_tlist[] = {
{ BEGIN, "config_begin" },
{ END, "config_end" },
{ BOARD, "board" },
{ IO, "io" }, { IO, "io" },
{ PCIINFO, "pciinfo" }, { PCIINFO, "pciinfo" },
{ LINE, "line" }, { LINE, "line" },
...@@ -6382,6 +6386,8 @@ static int dgap_parsefile(char **in) ...@@ -6382,6 +6386,8 @@ static int dgap_parsefile(char **in)
} }
for (; ;) { for (; ;) {
int board_type = 0;
rc = dgap_gettok(in); rc = dgap_gettok(in);
if (rc == 0) { if (rc == 0) {
dgap_err("unexpected EOF"); dgap_err("unexpected EOF");
...@@ -6412,88 +6418,13 @@ static int dgap_parsefile(char **in) ...@@ -6412,88 +6418,13 @@ static int dgap_parsefile(char **in)
line = conc = NULL; line = conc = NULL;
brd = p; brd = p;
linecnt = -1; linecnt = -1;
break;
case APORT2_920P: /* AccelePort_4 */
if (p->type != BNODE) {
dgap_err("unexpected Digi_2r_920 string");
return -1;
}
p->u.board.type = APORT2_920P;
p->u.board.v_type = 1;
break;
case APORT4_920P: /* AccelePort_4 */ board_type = dgap_gettok(in);
if (p->type != BNODE) { if (board_type == 0)
dgap_err("unexpected Digi_4r_920 string");
return -1; return -1;
}
p->u.board.type = APORT4_920P;
p->u.board.v_type = 1;
break;
case APORT8_920P: /* AccelePort_8 */ p->u.board.type = board_type;
if (p->type != BNODE) {
dgap_err("unexpected Digi_8r_920 string");
return -1;
}
p->u.board.type = APORT8_920P;
p->u.board.v_type = 1;
break;
case PAPORT4: /* AccelePort_4 PCI */
if (p->type != BNODE) {
dgap_err("unexpected Digi_4r(PCI) string");
return -1;
}
p->u.board.type = PAPORT4;
p->u.board.v_type = 1;
break;
case PAPORT8: /* AccelePort_8 PCI */
if (p->type != BNODE) {
dgap_err("unexpected Digi_8r string");
return -1;
}
p->u.board.type = PAPORT8;
p->u.board.v_type = 1;
break;
case PCX: /* PCI C/X */
if (p->type != BNODE) {
dgap_err("unexpected Digi_C/X_(PCI) string");
return -1;
}
p->u.board.type = PCX;
p->u.board.v_type = 1;
p->u.board.conc1 = 0;
p->u.board.conc2 = 0;
p->u.board.module1 = 0;
p->u.board.module2 = 0;
break;
case PEPC: /* PCI EPC/X */
if (p->type != BNODE) {
dgap_err("unexpected \"Digi_EPC/X_(PCI)\" string");
return -1;
}
p->u.board.type = PEPC;
p->u.board.v_type = 1;
p->u.board.conc1 = 0;
p->u.board.conc2 = 0;
p->u.board.module1 = 0;
p->u.board.module2 = 0;
break;
case PPCM: /* PCI/Xem */
if (p->type != BNODE) {
dgap_err("unexpected PCI/Xem string");
return -1;
}
p->u.board.type = PPCM;
p->u.board.v_type = 1;
p->u.board.conc1 = 0;
p->u.board.conc2 = 0;
break; break;
case IO: /* i/o port */ case IO: /* i/o port */
...@@ -7198,12 +7129,11 @@ static int dgap_gettok(char **in) ...@@ -7198,12 +7129,11 @@ static int dgap_gettok(char **in)
if (strstr(dgap_cword, "board")) { if (strstr(dgap_cword, "board")) {
w = dgap_getword(in); w = dgap_getword(in);
snprintf(dgap_cword, MAXCWORD, "%s", w); snprintf(dgap_cword, MAXCWORD, "%s", w);
for (t = dgap_tlist; t->token != 0; t++) { for (t = dgap_brdtype; t->token != 0; t++) {
if (!strcmp(w, t->string)) if (!strcmp(w, t->string))
return t->token; return t->token;
} }
dgap_err("board !!type not specified"); dgap_err("board !!type not specified");
return 1;
} else { } else {
while ((w = dgap_getword(in))) { while ((w = dgap_getword(in))) {
snprintf(dgap_cword, MAXCWORD, "%s", w); snprintf(dgap_cword, MAXCWORD, "%s", w);
...@@ -7212,8 +7142,9 @@ static int dgap_gettok(char **in) ...@@ -7212,8 +7142,9 @@ static int dgap_gettok(char **in)
return t->token; return t->token;
} }
} }
return 0;
} }
return 0;
} }
/* /*
...@@ -7261,14 +7192,6 @@ static void dgap_err(char *s) ...@@ -7261,14 +7192,6 @@ static void dgap_err(char *s)
static int dgap_checknode(struct cnode *p) static int dgap_checknode(struct cnode *p)
{ {
switch (p->type) { switch (p->type) {
case BNODE:
if (p->u.board.v_type == 0) {
dgap_err("board type !not specified");
return 1;
}
return 0;
case LNODE: case LNODE:
if (p->u.line.v_speed == 0) { if (p->u.line.v_speed == 0) {
dgap_err("line speed not specified"); dgap_err("line speed not specified");
......
...@@ -1172,7 +1172,6 @@ struct cnode { ...@@ -1172,7 +1172,6 @@ struct cnode {
char *id; /* tty id */ char *id; /* tty id */
long start; /* start of tty counting */ long start; /* start of tty counting */
char *method; /* Install method */ char *method; /* Install method */
char v_type;
char v_port; char v_port;
char v_addr; char v_addr;
char v_pcibus; char v_pcibus;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment