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

staging: dgap: uses kzalloc for allocating memory

Originally, this driver created it's own allocating
function. This patch removes that function and calls
kzalloc directly.

This patch affects:
- driver.c
- driver.h
- fep5.c
- tty.c

Signed-off-by: Lidza Louina <lidza.louina@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Lidza Louina and committed by
Greg Kroah-Hartman
0c5b5632 f0dcc9fa

+8 -23
+2 -16
drivers/staging/dgap/dgap_driver.c
··· 506 506 507 507 /* get the board structure and prep it */ 508 508 brd = dgap_Board[dgap_NumBoards] = 509 - (struct board_t *) dgap_driver_kzmalloc(sizeof(struct board_t), GFP_KERNEL); 509 + (struct board_t *) kzalloc(sizeof(struct board_t), GFP_KERNEL); 510 510 if (!brd) { 511 511 APR(("memory allocation for board structure failed\n")); 512 512 return(-ENOMEM); ··· 514 514 515 515 /* make a temporary message buffer for the boot messages */ 516 516 brd->msgbuf = brd->msgbuf_head = 517 - (char *) dgap_driver_kzmalloc(sizeof(char) * 8192, GFP_KERNEL); 517 + (char *) kzalloc(sizeof(char) * 8192, GFP_KERNEL); 518 518 if(!brd->msgbuf) { 519 519 kfree(brd); 520 520 APR(("memory allocation for board msgbuf failed\n")); ··· 922 922 * Utility functions 923 923 * 924 924 ************************************************************************/ 925 - 926 - 927 - /* 928 - * dgap_driver_kzmalloc() 929 - * 930 - * Malloc and clear memory, 931 - */ 932 - void *dgap_driver_kzmalloc(size_t size, int priority) 933 - { 934 - void *p = kmalloc(size, priority); 935 - if(p) 936 - memset(p, 0, size); 937 - return(p); 938 - } 939 925 940 926 941 927 /*
-1
drivers/staging/dgap/dgap_driver.h
··· 578 578 *************************************************************************/ 579 579 580 580 extern int dgap_ms_sleep(ulong ms); 581 - extern void *dgap_driver_kzmalloc(size_t size, int priority); 582 581 extern char *dgap_ioctl_name(int cmd); 583 582 extern void dgap_do_bios_load(struct board_t *brd, uchar __user *ubios, int len); 584 583 extern void dgap_do_fep_load(struct board_t *brd, uchar __user *ufep, int len);
+3 -3
drivers/staging/dgap/dgap_fep5.c
··· 75 75 char buf[U2BSIZE]; 76 76 int n; 77 77 78 - to_addr = dgap_config_buf = dgap_driver_kzmalloc(len + 1, GFP_ATOMIC); 78 + to_addr = dgap_config_buf = kzalloc(len + 1, GFP_ATOMIC); 79 79 if (!dgap_config_buf) { 80 80 DPR_INIT(("dgap_do_config_load - unable to allocate memory for file\n")); 81 81 dgap_driver_state = DRIVER_NEED_CONFIG_LOAD; ··· 130 130 /* 131 131 * allocate flip buffer for board. 132 132 */ 133 - dgap_Board[i]->flipbuf = dgap_driver_kzmalloc(MYFLIPLEN, GFP_ATOMIC); 134 - dgap_Board[i]->flipflagbuf = dgap_driver_kzmalloc(MYFLIPLEN, GFP_ATOMIC); 133 + dgap_Board[i]->flipbuf = kzalloc(MYFLIPLEN, GFP_ATOMIC); 134 + dgap_Board[i]->flipflagbuf = kzalloc(MYFLIPLEN, GFP_ATOMIC); 135 135 } 136 136 137 137 return rc;
+3 -3
drivers/staging/dgap/dgap_tty.c
··· 233 233 brd->SerialDriver->flags = (TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV | TTY_DRIVER_HARDWARE_BREAK); 234 234 235 235 /* The kernel wants space to store pointers to tty_structs */ 236 - brd->SerialDriver->ttys = dgap_driver_kzmalloc(MAXPORTS * sizeof(struct tty_struct *), GFP_KERNEL); 236 + brd->SerialDriver->ttys = kzalloc(MAXPORTS * sizeof(struct tty_struct *), GFP_KERNEL); 237 237 if (!brd->SerialDriver->ttys) 238 238 return(-ENOMEM); 239 239 ··· 266 266 brd->PrintDriver->flags = (TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV | TTY_DRIVER_HARDWARE_BREAK); 267 267 268 268 /* The kernel wants space to store pointers to tty_structs */ 269 - brd->PrintDriver->ttys = dgap_driver_kzmalloc(MAXPORTS * sizeof(struct tty_struct *), GFP_KERNEL); 269 + brd->PrintDriver->ttys = kzalloc(MAXPORTS * sizeof(struct tty_struct *), GFP_KERNEL); 270 270 if (!brd->PrintDriver->ttys) 271 271 return(-ENOMEM); 272 272 ··· 380 380 */ 381 381 for (i = 0; i < brd->nasync; i++) { 382 382 if (!brd->channels[i]) { 383 - brd->channels[i] = dgap_driver_kzmalloc(sizeof(struct channel_t), GFP_ATOMIC); 383 + brd->channels[i] = kzalloc(sizeof(struct channel_t), GFP_ATOMIC); 384 384 if (!brd->channels[i]) { 385 385 DPR_CORE(("%s:%d Unable to allocate memory for channel struct\n", 386 386 __FILE__, __LINE__));