Skip to content

Commit 77a4492

Browse files
daeseokyoungregkh
authored andcommitted
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: Daeseok Youn <daeseok.youn@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 35edf11 commit 77a4492

2 files changed

Lines changed: 16 additions & 94 deletions

File tree

‎drivers/staging/dgap/dgap.c‎

Lines changed: 16 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -399,10 +399,7 @@ struct toklist {
399399
char *string;
400400
};
401401

402-
static struct toklist dgap_tlist[] = {
403-
{ BEGIN, "config_begin" },
404-
{ END, "config_end" },
405-
{ BOARD, "board" },
402+
static struct toklist dgap_brdtype[] = {
406403
{ PCX, "Digi_AccelePort_C/X_PCI" },
407404
{ PEPC, "Digi_AccelePort_EPC/X_PCI" },
408405
{ PPCM, "Digi_AccelePort_Xem_PCI" },
@@ -411,6 +408,13 @@ static struct toklist dgap_tlist[] = {
411408
{ APORT8_920P, "Digi_AccelePort_8r_920_PCI" },
412409
{ PAPORT4, "Digi_AccelePort_4r_PCI(EIA-232/RS-422)" },
413410
{ PAPORT8, "Digi_AccelePort_8r_PCI(EIA-232/RS-422)" },
411+
{ 0, NULL }
412+
};
413+
414+
static struct toklist dgap_tlist[] = {
415+
{ BEGIN, "config_begin" },
416+
{ END, "config_end" },
417+
{ BOARD, "board" },
414418
{ IO, "io" },
415419
{ PCIINFO, "pciinfo" },
416420
{ LINE, "line" },
@@ -6382,6 +6386,8 @@ static int dgap_parsefile(char **in)
63826386
}
63836387

63846388
for (; ;) {
6389+
int board_type = 0;
6390+
63856391
rc = dgap_gettok(in);
63866392
if (rc == 0) {
63876393
dgap_err("unexpected EOF");
@@ -6412,88 +6418,13 @@ static int dgap_parsefile(char **in)
64126418
line = conc = NULL;
64136419
brd = p;
64146420
linecnt = -1;
6415-
break;
6416-
6417-
case APORT2_920P: /* AccelePort_4 */
6418-
if (p->type != BNODE) {
6419-
dgap_err("unexpected Digi_2r_920 string");
6420-
return -1;
6421-
}
6422-
p->u.board.type = APORT2_920P;
6423-
p->u.board.v_type = 1;
6424-
break;
64256421

6426-
case APORT4_920P: /* AccelePort_4 */
6427-
if (p->type != BNODE) {
6428-
dgap_err("unexpected Digi_4r_920 string");
6422+
board_type = dgap_gettok(in);
6423+
if (board_type == 0)
64296424
return -1;
6430-
}
6431-
p->u.board.type = APORT4_920P;
6432-
p->u.board.v_type = 1;
6433-
break;
64346425

6435-
case APORT8_920P: /* AccelePort_8 */
6436-
if (p->type != BNODE) {
6437-
dgap_err("unexpected Digi_8r_920 string");
6438-
return -1;
6439-
}
6440-
p->u.board.type = APORT8_920P;
6441-
p->u.board.v_type = 1;
6442-
break;
6426+
p->u.board.type = board_type;
64436427

6444-
case PAPORT4: /* AccelePort_4 PCI */
6445-
if (p->type != BNODE) {
6446-
dgap_err("unexpected Digi_4r(PCI) string");
6447-
return -1;
6448-
}
6449-
p->u.board.type = PAPORT4;
6450-
p->u.board.v_type = 1;
6451-
break;
6452-
6453-
case PAPORT8: /* AccelePort_8 PCI */
6454-
if (p->type != BNODE) {
6455-
dgap_err("unexpected Digi_8r string");
6456-
return -1;
6457-
}
6458-
p->u.board.type = PAPORT8;
6459-
p->u.board.v_type = 1;
6460-
break;
6461-
6462-
case PCX: /* PCI C/X */
6463-
if (p->type != BNODE) {
6464-
dgap_err("unexpected Digi_C/X_(PCI) string");
6465-
return -1;
6466-
}
6467-
p->u.board.type = PCX;
6468-
p->u.board.v_type = 1;
6469-
p->u.board.conc1 = 0;
6470-
p->u.board.conc2 = 0;
6471-
p->u.board.module1 = 0;
6472-
p->u.board.module2 = 0;
6473-
break;
6474-
6475-
case PEPC: /* PCI EPC/X */
6476-
if (p->type != BNODE) {
6477-
dgap_err("unexpected \"Digi_EPC/X_(PCI)\" string");
6478-
return -1;
6479-
}
6480-
p->u.board.type = PEPC;
6481-
p->u.board.v_type = 1;
6482-
p->u.board.conc1 = 0;
6483-
p->u.board.conc2 = 0;
6484-
p->u.board.module1 = 0;
6485-
p->u.board.module2 = 0;
6486-
break;
6487-
6488-
case PPCM: /* PCI/Xem */
6489-
if (p->type != BNODE) {
6490-
dgap_err("unexpected PCI/Xem string");
6491-
return -1;
6492-
}
6493-
p->u.board.type = PPCM;
6494-
p->u.board.v_type = 1;
6495-
p->u.board.conc1 = 0;
6496-
p->u.board.conc2 = 0;
64976428
break;
64986429

64996430
case IO: /* i/o port */
@@ -7198,12 +7129,11 @@ static int dgap_gettok(char **in)
71987129
if (strstr(dgap_cword, "board")) {
71997130
w = dgap_getword(in);
72007131
snprintf(dgap_cword, MAXCWORD, "%s", w);
7201-
for (t = dgap_tlist; t->token != 0; t++) {
7132+
for (t = dgap_brdtype; t->token != 0; t++) {
72027133
if (!strcmp(w, t->string))
72037134
return t->token;
72047135
}
72057136
dgap_err("board !!type not specified");
7206-
return 1;
72077137
} else {
72087138
while ((w = dgap_getword(in))) {
72097139
snprintf(dgap_cword, MAXCWORD, "%s", w);
@@ -7212,8 +7142,9 @@ static int dgap_gettok(char **in)
72127142
return t->token;
72137143
}
72147144
}
7215-
return 0;
72167145
}
7146+
7147+
return 0;
72177148
}
72187149

72197150
/*
@@ -7261,14 +7192,6 @@ static void dgap_err(char *s)
72617192
static int dgap_checknode(struct cnode *p)
72627193
{
72637194
switch (p->type) {
7264-
case BNODE:
7265-
if (p->u.board.v_type == 0) {
7266-
dgap_err("board type !not specified");
7267-
return 1;
7268-
}
7269-
7270-
return 0;
7271-
72727195
case LNODE:
72737196
if (p->u.line.v_speed == 0) {
72747197
dgap_err("line speed not specified");

‎drivers/staging/dgap/dgap.h‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1172,7 +1172,6 @@ struct cnode {
11721172
char *id; /* tty id */
11731173
long start; /* start of tty counting */
11741174
char *method; /* Install method */
1175-
char v_type;
11761175
char v_port;
11771176
char v_addr;
11781177
char v_pcibus;

0 commit comments

Comments
 (0)