[PATCH 5/8] staging: dgap: remove dgap_newnode()

2014-07-14 Thread Daeseok Youn
The dgap_newnode() is useless for creating new node.
So just use kzalloc and set a type in case statement.

Signed-off-by: Daeseok Youn 
---
 drivers/staging/dgap/dgap.c |  104 ++
 1 files changed, 74 insertions(+), 30 deletions(-)

diff --git a/drivers/staging/dgap/dgap.c b/drivers/staging/dgap/dgap.c
index 1e52092..06c55cb 100644
--- a/drivers/staging/dgap/dgap.c
+++ b/drivers/staging/dgap/dgap.c
@@ -152,7 +152,6 @@ static void dgap_firmware_reset_port(struct channel_t *ch);
  */
 static int dgap_gettok(char **in);
 static char *dgap_getword(char **in);
-static struct cnode *dgap_newnode(int t);
 static int dgap_checknode(struct cnode *p);
 static void dgap_err(char *s);
 
@@ -6367,13 +6366,15 @@ static int dgap_parsefile(char **in)
case BOARD: /* board info */
if (dgap_checknode(p))
return -1;
-   p->next = dgap_newnode(BNODE);
+
+   p->next = kzalloc(sizeof(struct cnode), GFP_KERNEL);
if (!p->next) {
dgap_err("out of memory");
return -1;
}
p = p->next;
 
+   p->type = BNODE;
p->u.board.status = kstrdup("No", GFP_KERNEL);
line = conc = NULL;
brd = p;
@@ -6658,12 +6659,16 @@ static int dgap_parsefile(char **in)
case TTYN:  /* tty name prefix */
if (dgap_checknode(p))
return -1;
-   p->next = dgap_newnode(TNODE);
+
+   p->next = kzalloc(sizeof(struct cnode), GFP_KERNEL);
if (!p->next) {
dgap_err("out of memory");
return -1;
}
+
p = p->next;
+   p->type = TNODE;
+
s = dgap_getword(in);
if (!s) {
dgap_err("unexpeced end of file");
@@ -6679,12 +6684,16 @@ static int dgap_parsefile(char **in)
case CU:/* cu name prefix */
if (dgap_checknode(p))
return -1;
-   p->next = dgap_newnode(CUNODE);
+
+   p->next = kzalloc(sizeof(struct cnode), GFP_KERNEL);
if (!p->next) {
dgap_err("out of memory");
return -1;
}
+
p = p->next;
+   p->type = CUNODE;
+
s = dgap_getword(in);
if (!s) {
dgap_err("unexpeced end of file");
@@ -6709,12 +6718,15 @@ static int dgap_parsefile(char **in)
dgap_err("line not vaild for PC/em");
return -1;
}
-   p->next = dgap_newnode(LNODE);
+
+   p->next = kzalloc(sizeof(struct cnode), GFP_KERNEL);
if (!p->next) {
dgap_err("out of memory");
return -1;
}
+
p = p->next;
+   p->type = LNODE;
conc = NULL;
line = p;
linecnt++;
@@ -6727,13 +6739,17 @@ static int dgap_parsefile(char **in)
dgap_err("must specify line info before 
concentrator");
return -1;
}
-   p->next = dgap_newnode(CNODE);
+
+   p->next = kzalloc(sizeof(struct cnode), GFP_KERNEL);
if (!p->next) {
dgap_err("out of memory");
return -1;
}
+
p = p->next;
+   p->type = CNODE;
conc = p;
+
if (linecnt)
brd->u.board.conc2++;
else
@@ -6776,12 +6792,15 @@ static int dgap_parsefile(char **in)
return -1;
}
}
-   p->next = dgap_newnode(MNODE);
+
+   p->next = kzalloc(sizeof(struct cnode), GFP_KERNEL);
if (!p->next) {
dgap_err("out of memory");
return -1;
}
p = p->next;
+   p->type = MNODE;
+
if (linecnt)

[PATCH 5/8] staging: dgap: remove dgap_newnode()

2014-07-14 Thread Daeseok Youn
The dgap_newnode() is useless for creating new node.
So just use kzalloc and set a type in case statement.

Signed-off-by: Daeseok Youn daeseok.y...@gmail.com
---
 drivers/staging/dgap/dgap.c |  104 ++
 1 files changed, 74 insertions(+), 30 deletions(-)

diff --git a/drivers/staging/dgap/dgap.c b/drivers/staging/dgap/dgap.c
index 1e52092..06c55cb 100644
--- a/drivers/staging/dgap/dgap.c
+++ b/drivers/staging/dgap/dgap.c
@@ -152,7 +152,6 @@ static void dgap_firmware_reset_port(struct channel_t *ch);
  */
 static int dgap_gettok(char **in);
 static char *dgap_getword(char **in);
-static struct cnode *dgap_newnode(int t);
 static int dgap_checknode(struct cnode *p);
 static void dgap_err(char *s);
 
@@ -6367,13 +6366,15 @@ static int dgap_parsefile(char **in)
case BOARD: /* board info */
if (dgap_checknode(p))
return -1;
-   p-next = dgap_newnode(BNODE);
+
+   p-next = kzalloc(sizeof(struct cnode), GFP_KERNEL);
if (!p-next) {
dgap_err(out of memory);
return -1;
}
p = p-next;
 
+   p-type = BNODE;
p-u.board.status = kstrdup(No, GFP_KERNEL);
line = conc = NULL;
brd = p;
@@ -6658,12 +6659,16 @@ static int dgap_parsefile(char **in)
case TTYN:  /* tty name prefix */
if (dgap_checknode(p))
return -1;
-   p-next = dgap_newnode(TNODE);
+
+   p-next = kzalloc(sizeof(struct cnode), GFP_KERNEL);
if (!p-next) {
dgap_err(out of memory);
return -1;
}
+
p = p-next;
+   p-type = TNODE;
+
s = dgap_getword(in);
if (!s) {
dgap_err(unexpeced end of file);
@@ -6679,12 +6684,16 @@ static int dgap_parsefile(char **in)
case CU:/* cu name prefix */
if (dgap_checknode(p))
return -1;
-   p-next = dgap_newnode(CUNODE);
+
+   p-next = kzalloc(sizeof(struct cnode), GFP_KERNEL);
if (!p-next) {
dgap_err(out of memory);
return -1;
}
+
p = p-next;
+   p-type = CUNODE;
+
s = dgap_getword(in);
if (!s) {
dgap_err(unexpeced end of file);
@@ -6709,12 +6718,15 @@ static int dgap_parsefile(char **in)
dgap_err(line not vaild for PC/em);
return -1;
}
-   p-next = dgap_newnode(LNODE);
+
+   p-next = kzalloc(sizeof(struct cnode), GFP_KERNEL);
if (!p-next) {
dgap_err(out of memory);
return -1;
}
+
p = p-next;
+   p-type = LNODE;
conc = NULL;
line = p;
linecnt++;
@@ -6727,13 +6739,17 @@ static int dgap_parsefile(char **in)
dgap_err(must specify line info before 
concentrator);
return -1;
}
-   p-next = dgap_newnode(CNODE);
+
+   p-next = kzalloc(sizeof(struct cnode), GFP_KERNEL);
if (!p-next) {
dgap_err(out of memory);
return -1;
}
+
p = p-next;
+   p-type = CNODE;
conc = p;
+
if (linecnt)
brd-u.board.conc2++;
else
@@ -6776,12 +6792,15 @@ static int dgap_parsefile(char **in)
return -1;
}
}
-   p-next = dgap_newnode(MNODE);
+
+   p-next = kzalloc(sizeof(struct cnode), GFP_KERNEL);
if (!p-next) {
dgap_err(out of memory);
return -1;
}
p = p-next;
+   p-type = MNODE;
+
if (linecnt)
brd-u.board.module2++;