Commit 0c5b5632 authored by Lidza Louina's avatar Lidza Louina Committed by Greg Kroah-Hartman

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: default avatarLidza Louina <lidza.louina@gmail.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent f0dcc9fa
...@@ -506,7 +506,7 @@ static int dgap_found_board(struct pci_dev *pdev, int id) ...@@ -506,7 +506,7 @@ static int dgap_found_board(struct pci_dev *pdev, int id)
/* get the board structure and prep it */ /* get the board structure and prep it */
brd = dgap_Board[dgap_NumBoards] = brd = dgap_Board[dgap_NumBoards] =
(struct board_t *) dgap_driver_kzmalloc(sizeof(struct board_t), GFP_KERNEL); (struct board_t *) kzalloc(sizeof(struct board_t), GFP_KERNEL);
if (!brd) { if (!brd) {
APR(("memory allocation for board structure failed\n")); APR(("memory allocation for board structure failed\n"));
return(-ENOMEM); return(-ENOMEM);
...@@ -514,7 +514,7 @@ static int dgap_found_board(struct pci_dev *pdev, int id) ...@@ -514,7 +514,7 @@ static int dgap_found_board(struct pci_dev *pdev, int id)
/* make a temporary message buffer for the boot messages */ /* make a temporary message buffer for the boot messages */
brd->msgbuf = brd->msgbuf_head = brd->msgbuf = brd->msgbuf_head =
(char *) dgap_driver_kzmalloc(sizeof(char) * 8192, GFP_KERNEL); (char *) kzalloc(sizeof(char) * 8192, GFP_KERNEL);
if(!brd->msgbuf) { if(!brd->msgbuf) {
kfree(brd); kfree(brd);
APR(("memory allocation for board msgbuf failed\n")); APR(("memory allocation for board msgbuf failed\n"));
...@@ -924,20 +924,6 @@ static void dgap_init_globals(void) ...@@ -924,20 +924,6 @@ static void dgap_init_globals(void)
************************************************************************/ ************************************************************************/
/*
* dgap_driver_kzmalloc()
*
* Malloc and clear memory,
*/
void *dgap_driver_kzmalloc(size_t size, int priority)
{
void *p = kmalloc(size, priority);
if(p)
memset(p, 0, size);
return(p);
}
/* /*
* dgap_mbuf() * dgap_mbuf()
* *
......
...@@ -578,7 +578,6 @@ struct channel_t { ...@@ -578,7 +578,6 @@ struct channel_t {
*************************************************************************/ *************************************************************************/
extern int dgap_ms_sleep(ulong ms); extern int dgap_ms_sleep(ulong ms);
extern void *dgap_driver_kzmalloc(size_t size, int priority);
extern char *dgap_ioctl_name(int cmd); extern char *dgap_ioctl_name(int cmd);
extern void dgap_do_bios_load(struct board_t *brd, uchar __user *ubios, int len); extern void dgap_do_bios_load(struct board_t *brd, uchar __user *ubios, int len);
extern void dgap_do_fep_load(struct board_t *brd, uchar __user *ufep, int len); extern void dgap_do_fep_load(struct board_t *brd, uchar __user *ufep, int len);
......
...@@ -75,7 +75,7 @@ void dgap_do_config_load(uchar __user *uaddr, int len) ...@@ -75,7 +75,7 @@ void dgap_do_config_load(uchar __user *uaddr, int len)
char buf[U2BSIZE]; char buf[U2BSIZE];
int n; int n;
to_addr = dgap_config_buf = dgap_driver_kzmalloc(len + 1, GFP_ATOMIC); to_addr = dgap_config_buf = kzalloc(len + 1, GFP_ATOMIC);
if (!dgap_config_buf) { if (!dgap_config_buf) {
DPR_INIT(("dgap_do_config_load - unable to allocate memory for file\n")); DPR_INIT(("dgap_do_config_load - unable to allocate memory for file\n"));
dgap_driver_state = DRIVER_NEED_CONFIG_LOAD; dgap_driver_state = DRIVER_NEED_CONFIG_LOAD;
...@@ -130,8 +130,8 @@ int dgap_after_config_loaded(void) ...@@ -130,8 +130,8 @@ int dgap_after_config_loaded(void)
/* /*
* allocate flip buffer for board. * allocate flip buffer for board.
*/ */
dgap_Board[i]->flipbuf = dgap_driver_kzmalloc(MYFLIPLEN, GFP_ATOMIC); dgap_Board[i]->flipbuf = kzalloc(MYFLIPLEN, GFP_ATOMIC);
dgap_Board[i]->flipflagbuf = dgap_driver_kzmalloc(MYFLIPLEN, GFP_ATOMIC); dgap_Board[i]->flipflagbuf = kzalloc(MYFLIPLEN, GFP_ATOMIC);
} }
return rc; return rc;
......
...@@ -233,7 +233,7 @@ int dgap_tty_register(struct board_t *brd) ...@@ -233,7 +233,7 @@ int dgap_tty_register(struct board_t *brd)
brd->SerialDriver->flags = (TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV | TTY_DRIVER_HARDWARE_BREAK); brd->SerialDriver->flags = (TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV | TTY_DRIVER_HARDWARE_BREAK);
/* The kernel wants space to store pointers to tty_structs */ /* The kernel wants space to store pointers to tty_structs */
brd->SerialDriver->ttys = dgap_driver_kzmalloc(MAXPORTS * sizeof(struct tty_struct *), GFP_KERNEL); brd->SerialDriver->ttys = kzalloc(MAXPORTS * sizeof(struct tty_struct *), GFP_KERNEL);
if (!brd->SerialDriver->ttys) if (!brd->SerialDriver->ttys)
return(-ENOMEM); return(-ENOMEM);
...@@ -266,7 +266,7 @@ int dgap_tty_register(struct board_t *brd) ...@@ -266,7 +266,7 @@ int dgap_tty_register(struct board_t *brd)
brd->PrintDriver->flags = (TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV | TTY_DRIVER_HARDWARE_BREAK); brd->PrintDriver->flags = (TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV | TTY_DRIVER_HARDWARE_BREAK);
/* The kernel wants space to store pointers to tty_structs */ /* The kernel wants space to store pointers to tty_structs */
brd->PrintDriver->ttys = dgap_driver_kzmalloc(MAXPORTS * sizeof(struct tty_struct *), GFP_KERNEL); brd->PrintDriver->ttys = kzalloc(MAXPORTS * sizeof(struct tty_struct *), GFP_KERNEL);
if (!brd->PrintDriver->ttys) if (!brd->PrintDriver->ttys)
return(-ENOMEM); return(-ENOMEM);
...@@ -380,7 +380,7 @@ int dgap_tty_init(struct board_t *brd) ...@@ -380,7 +380,7 @@ int dgap_tty_init(struct board_t *brd)
*/ */
for (i = 0; i < brd->nasync; i++) { for (i = 0; i < brd->nasync; i++) {
if (!brd->channels[i]) { if (!brd->channels[i]) {
brd->channels[i] = dgap_driver_kzmalloc(sizeof(struct channel_t), GFP_ATOMIC); brd->channels[i] = kzalloc(sizeof(struct channel_t), GFP_ATOMIC);
if (!brd->channels[i]) { if (!brd->channels[i]) {
DPR_CORE(("%s:%d Unable to allocate memory for channel struct\n", DPR_CORE(("%s:%d Unable to allocate memory for channel struct\n",
__FILE__, __LINE__)); __FILE__, __LINE__));
......
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