Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

staging: dgap: remove dgap_newnode()

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.youn@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Daeseok Youn and committed by
Greg Kroah-Hartman
82512235 7bab00ff

+74 -30
+74 -30
drivers/staging/dgap/dgap.c
··· 152 152 */ 153 153 static int dgap_gettok(char **in); 154 154 static char *dgap_getword(char **in); 155 - static struct cnode *dgap_newnode(int t); 156 155 static int dgap_checknode(struct cnode *p); 157 156 static void dgap_err(char *s); 158 157 ··· 6366 6367 case BOARD: /* board info */ 6367 6368 if (dgap_checknode(p)) 6368 6369 return -1; 6369 - p->next = dgap_newnode(BNODE); 6370 + 6371 + p->next = kzalloc(sizeof(struct cnode), GFP_KERNEL); 6370 6372 if (!p->next) { 6371 6373 dgap_err("out of memory"); 6372 6374 return -1; 6373 6375 } 6374 6376 p = p->next; 6375 6377 6378 + p->type = BNODE; 6376 6379 p->u.board.status = kstrdup("No", GFP_KERNEL); 6377 6380 line = conc = NULL; 6378 6381 brd = p; ··· 6659 6658 case TTYN: /* tty name prefix */ 6660 6659 if (dgap_checknode(p)) 6661 6660 return -1; 6662 - p->next = dgap_newnode(TNODE); 6661 + 6662 + p->next = kzalloc(sizeof(struct cnode), GFP_KERNEL); 6663 6663 if (!p->next) { 6664 6664 dgap_err("out of memory"); 6665 6665 return -1; 6666 6666 } 6667 + 6667 6668 p = p->next; 6669 + p->type = TNODE; 6670 + 6668 6671 s = dgap_getword(in); 6669 6672 if (!s) { 6670 6673 dgap_err("unexpeced end of file"); ··· 6684 6679 case CU: /* cu name prefix */ 6685 6680 if (dgap_checknode(p)) 6686 6681 return -1; 6687 - p->next = dgap_newnode(CUNODE); 6682 + 6683 + p->next = kzalloc(sizeof(struct cnode), GFP_KERNEL); 6688 6684 if (!p->next) { 6689 6685 dgap_err("out of memory"); 6690 6686 return -1; 6691 6687 } 6688 + 6692 6689 p = p->next; 6690 + p->type = CUNODE; 6691 + 6693 6692 s = dgap_getword(in); 6694 6693 if (!s) { 6695 6694 dgap_err("unexpeced end of file"); ··· 6718 6709 dgap_err("line not vaild for PC/em"); 6719 6710 return -1; 6720 6711 } 6721 - p->next = dgap_newnode(LNODE); 6712 + 6713 + p->next = kzalloc(sizeof(struct cnode), GFP_KERNEL); 6722 6714 if (!p->next) { 6723 6715 dgap_err("out of memory"); 6724 6716 return -1; 6725 6717 } 6718 + 6726 6719 p = p->next; 6720 + p->type = LNODE; 6727 6721 conc = NULL; 6728 6722 line = p; 6729 6723 linecnt++; ··· 6739 6727 dgap_err("must specify line info before concentrator"); 6740 6728 return -1; 6741 6729 } 6742 - p->next = dgap_newnode(CNODE); 6730 + 6731 + p->next = kzalloc(sizeof(struct cnode), GFP_KERNEL); 6743 6732 if (!p->next) { 6744 6733 dgap_err("out of memory"); 6745 6734 return -1; 6746 6735 } 6736 + 6747 6737 p = p->next; 6738 + p->type = CNODE; 6748 6739 conc = p; 6740 + 6749 6741 if (linecnt) 6750 6742 brd->u.board.conc2++; 6751 6743 else ··· 6792 6776 return -1; 6793 6777 } 6794 6778 } 6795 - p->next = dgap_newnode(MNODE); 6779 + 6780 + p->next = kzalloc(sizeof(struct cnode), GFP_KERNEL); 6796 6781 if (!p->next) { 6797 6782 dgap_err("out of memory"); 6798 6783 return -1; 6799 6784 } 6800 6785 p = p->next; 6786 + p->type = MNODE; 6787 + 6801 6788 if (linecnt) 6802 6789 brd->u.board.module2++; 6803 6790 else ··· 6881 6862 case PRINT: /* transparent print name prefix */ 6882 6863 if (dgap_checknode(p)) 6883 6864 return -1; 6884 - p->next = dgap_newnode(PNODE); 6865 + 6866 + p->next = kzalloc(sizeof(struct cnode), GFP_KERNEL); 6885 6867 if (!p->next) { 6886 6868 dgap_err("out of memory"); 6887 6869 return -1; 6888 6870 } 6871 + 6889 6872 p = p->next; 6873 + p->type = PNODE; 6874 + 6890 6875 s = dgap_getword(in); 6891 6876 if (!s) { 6892 6877 dgap_err("unexpeced end of file"); ··· 6906 6883 case CMAJOR: /* major number */ 6907 6884 if (dgap_checknode(p)) 6908 6885 return -1; 6909 - p->next = dgap_newnode(JNODE); 6886 + 6887 + p->next = kzalloc(sizeof(struct cnode), GFP_KERNEL); 6910 6888 if (!p->next) { 6911 6889 dgap_err("out of memory"); 6912 6890 return -1; 6913 6891 } 6892 + 6914 6893 p = p->next; 6894 + p->type = JNODE; 6895 + 6915 6896 s = dgap_getword(in); 6916 6897 if (!s) { 6917 6898 dgap_err("unexpected end of file"); ··· 6930 6903 case ALTPIN: /* altpin setting */ 6931 6904 if (dgap_checknode(p)) 6932 6905 return -1; 6933 - p->next = dgap_newnode(ANODE); 6906 + 6907 + p->next = kzalloc(sizeof(struct cnode), GFP_KERNEL); 6934 6908 if (!p->next) { 6935 6909 dgap_err("out of memory"); 6936 6910 return -1; 6937 6911 } 6912 + 6938 6913 p = p->next; 6914 + p->type = ANODE; 6915 + 6939 6916 s = dgap_getword(in); 6940 6917 if (!s) { 6941 6918 dgap_err("unexpected end of file"); ··· 6954 6923 case USEINTR: /* enable interrupt setting */ 6955 6924 if (dgap_checknode(p)) 6956 6925 return -1; 6957 - p->next = dgap_newnode(INTRNODE); 6926 + 6927 + p->next = kzalloc(sizeof(struct cnode), GFP_KERNEL); 6958 6928 if (!p->next) { 6959 6929 dgap_err("out of memory"); 6960 6930 return -1; 6961 6931 } 6962 6932 p = p->next; 6933 + p->type = INTRNODE; 6963 6934 s = dgap_getword(in); 6964 6935 if (!s) { 6965 6936 dgap_err("unexpected end of file"); ··· 6976 6943 case TTSIZ: /* size of tty structure */ 6977 6944 if (dgap_checknode(p)) 6978 6945 return -1; 6979 - p->next = dgap_newnode(TSNODE); 6946 + 6947 + p->next = kzalloc(sizeof(struct cnode), GFP_KERNEL); 6980 6948 if (!p->next) { 6981 6949 dgap_err("out of memory"); 6982 6950 return -1; 6983 6951 } 6952 + 6984 6953 p = p->next; 6954 + p->type = TSNODE; 6955 + 6985 6956 s = dgap_getword(in); 6986 6957 if (!s) { 6987 6958 dgap_err("unexpected end of file"); ··· 7000 6963 case CHSIZ: /* channel structure size */ 7001 6964 if (dgap_checknode(p)) 7002 6965 return -1; 7003 - p->next = dgap_newnode(CSNODE); 6966 + 6967 + p->next = kzalloc(sizeof(struct cnode), GFP_KERNEL); 7004 6968 if (!p->next) { 7005 6969 dgap_err("out of memory"); 7006 6970 return -1; 7007 6971 } 6972 + 7008 6973 p = p->next; 6974 + p->type = CSNODE; 6975 + 7009 6976 s = dgap_getword(in); 7010 6977 if (!s) { 7011 6978 dgap_err("unexpected end of file"); ··· 7024 6983 case BSSIZ: /* board structure size */ 7025 6984 if (dgap_checknode(p)) 7026 6985 return -1; 7027 - p->next = dgap_newnode(BSNODE); 6986 + 6987 + p->next = kzalloc(sizeof(struct cnode), GFP_KERNEL); 7028 6988 if (!p->next) { 7029 6989 dgap_err("out of memory"); 7030 6990 return -1; 7031 6991 } 6992 + 7032 6993 p = p->next; 6994 + p->type = BSNODE; 6995 + 7033 6996 s = dgap_getword(in); 7034 6997 if (!s) { 7035 6998 dgap_err("unexpected end of file"); ··· 7048 7003 case UNTSIZ: /* sched structure size */ 7049 7004 if (dgap_checknode(p)) 7050 7005 return -1; 7051 - p->next = dgap_newnode(USNODE); 7006 + 7007 + p->next = kzalloc(sizeof(struct cnode), GFP_KERNEL); 7052 7008 if (!p->next) { 7053 7009 dgap_err("out of memory"); 7054 7010 return -1; 7055 7011 } 7012 + 7056 7013 p = p->next; 7014 + p->type = USNODE; 7015 + 7057 7016 s = dgap_getword(in); 7058 7017 if (!s) { 7059 7018 dgap_err("unexpected end of file"); ··· 7072 7023 case F2SIZ: /* f2200 structure size */ 7073 7024 if (dgap_checknode(p)) 7074 7025 return -1; 7075 - p->next = dgap_newnode(FSNODE); 7026 + 7027 + p->next = kzalloc(sizeof(struct cnode), GFP_KERNEL); 7076 7028 if (!p->next) { 7077 7029 dgap_err("out of memory"); 7078 7030 return -1; 7079 7031 } 7032 + 7080 7033 p = p->next; 7034 + p->type = FSNODE; 7035 + 7081 7036 s = dgap_getword(in); 7082 7037 if (!s) { 7083 7038 dgap_err("unexpected end of file"); ··· 7096 7043 case VPSIZ: /* vpix structure size */ 7097 7044 if (dgap_checknode(p)) 7098 7045 return -1; 7099 - p->next = dgap_newnode(VSNODE); 7046 + 7047 + p->next = kzalloc(sizeof(struct cnode), GFP_KERNEL); 7100 7048 if (!p->next) { 7101 7049 dgap_err("out of memory"); 7102 7050 return -1; 7103 7051 } 7052 + 7104 7053 p = p->next; 7054 + p->type = VSNODE; 7055 + 7105 7056 s = dgap_getword(in); 7106 7057 if (!s) { 7107 7058 dgap_err("unexpected end of file"); ··· 7219 7162 static void dgap_err(char *s) 7220 7163 { 7221 7164 pr_err("dgap: parse: %s\n", s); 7222 - } 7223 - 7224 - /* 7225 - * allocate a new configuration node of type t 7226 - */ 7227 - static struct cnode *dgap_newnode(int t) 7228 - { 7229 - struct cnode *n; 7230 - 7231 - n = kzalloc(sizeof(struct cnode), GFP_KERNEL); 7232 - if (n) 7233 - n->type = t; 7234 - return n; 7235 7165 } 7236 7166 7237 7167 /*