* [PATCH 2.6.19-rc6] serial: replace kmalloc+memset with kzalloc
@ 2006-11-22 18:57 Burman Yan
2006-11-22 19:12 ` Russell King
0 siblings, 1 reply; 2+ messages in thread
From: Burman Yan @ 2006-11-22 18:57 UTC (permalink / raw)
To: linux-kernel; +Cc: trivial
[-- Attachment #1: Type: text/plain, Size: 289 bytes --]
Hi.
This patch replaces kmalloc+memset with kzalloc in serial driver sources.
Regards
Yan Burman
_________________________________________________________________
FREE pop-up blocking with the new MSN Toolbar - get it now!
http://toolbar.msn.click-url.com/go/onm00200415ave/direct/01/
[-- Attachment #2: kzalloc_serial.patch --]
[-- Type: application/octet-stream, Size: 11394 bytes --]
Replace kmalloc+memset with kzalloc
Signed-off-by: Yan Burman <yan_952@hotmail.com>
diff -rubp linux-2.6.19-rc5_orig/drivers/serial/8250_acorn.c linux-2.6.19-rc5_kzalloc/drivers/serial/8250_acorn.c
--- linux-2.6.19-rc5_orig/drivers/serial/8250_acorn.c 2006-11-09 12:16:21.000000000 +0200
+++ linux-2.6.19-rc5_kzalloc/drivers/serial/8250_acorn.c 2006-11-11 22:44:04.000000000 +0200
@@ -47,11 +47,10 @@ serial_card_probe(struct expansion_card
unsigned long bus_addr;
unsigned int i;
- info = kmalloc(sizeof(struct serial_card_info), GFP_KERNEL);
+ info = kzalloc(sizeof(struct serial_card_info), GFP_KERNEL);
if (!info)
return -ENOMEM;
- memset(info, 0, sizeof(struct serial_card_info));
info->num_ports = type->num_ports;
bus_addr = ecard_resource_start(ec, type->type);
diff -rubp linux-2.6.19-rc5_orig/drivers/serial/8250_pci.c linux-2.6.19-rc5_kzalloc/drivers/serial/8250_pci.c
--- linux-2.6.19-rc5_orig/drivers/serial/8250_pci.c 2006-11-09 12:16:21.000000000 +0200
+++ linux-2.6.19-rc5_kzalloc/drivers/serial/8250_pci.c 2006-11-11 22:44:18.000000000 +0200
@@ -1614,7 +1614,7 @@ pciserial_init_ports(struct pci_dev *dev
nr_ports = rc;
}
- priv = kmalloc(sizeof(struct serial_private) +
+ priv = kzalloc(sizeof(struct serial_private) +
sizeof(unsigned int) * nr_ports,
GFP_KERNEL);
if (!priv) {
@@ -1622,9 +1622,6 @@ pciserial_init_ports(struct pci_dev *dev
goto err_deinit;
}
- memset(priv, 0, sizeof(struct serial_private) +
- sizeof(unsigned int) * nr_ports);
-
priv->dev = dev;
priv->quirk = quirk;
diff -rubp linux-2.6.19-rc5_orig/drivers/serial/icom.c linux-2.6.19-rc5_kzalloc/drivers/serial/icom.c
--- linux-2.6.19-rc5_orig/drivers/serial/icom.c 2006-11-09 12:16:21.000000000 +0200
+++ linux-2.6.19-rc5_kzalloc/drivers/serial/icom.c 2006-11-11 22:44:04.000000000 +0200
@@ -1417,14 +1417,12 @@ static int __devinit icom_alloc_adapter(
struct list_head *tmp;
icom_adapter = (struct icom_adapter *)
- kmalloc(sizeof(struct icom_adapter), GFP_KERNEL);
+ kzalloc(sizeof(struct icom_adapter), GFP_KERNEL);
if (!icom_adapter) {
return -ENOMEM;
}
- memset(icom_adapter, 0, sizeof(struct icom_adapter));
-
list_for_each(tmp, &icom_adapter_head) {
cur_adapter_entry =
list_entry(tmp, struct icom_adapter,
diff -rubp linux-2.6.19-rc5_orig/drivers/serial/ioc3_serial.c linux-2.6.19-rc5_kzalloc/drivers/serial/ioc3_serial.c
--- linux-2.6.19-rc5_orig/drivers/serial/ioc3_serial.c 2006-11-09 12:16:21.000000000 +0200
+++ linux-2.6.19-rc5_kzalloc/drivers/serial/ioc3_serial.c 2006-11-11 22:44:04.000000000 +0200
@@ -2019,13 +2019,12 @@ ioc3uart_probe(struct ioc3_submodule *is
DPRINT_CONFIG(("%s (0x%p, 0x%p)\n", __FUNCTION__, is, idd));
- card_ptr = kmalloc(sizeof(struct ioc3_card), GFP_KERNEL);
+ card_ptr = kzalloc(sizeof(struct ioc3_card), GFP_KERNEL);
if (!card_ptr) {
printk(KERN_WARNING "ioc3_attach_one"
": unable to get memory for the IOC3\n");
return -ENOMEM;
}
- memset(card_ptr, 0, sizeof(struct ioc3_card));
idd->data[is->id] = card_ptr;
Submodule_slot = is->id;
@@ -2040,13 +2039,12 @@ ioc3uart_probe(struct ioc3_submodule *is
/* Create port structures for each port */
for (phys_port = 0; phys_port < PORTS_PER_CARD; phys_port++) {
- port = kmalloc(sizeof(struct ioc3_port), GFP_KERNEL);
+ port = kzalloc(sizeof(struct ioc3_port), GFP_KERNEL);
if (!port) {
printk(KERN_WARNING
"IOC3 serial memory not available for port\n");
goto out4;
}
- memset(port, 0, sizeof(struct ioc3_port));
spin_lock_init(&port->ip_lock);
/* we need to remember the previous ones, to point back to
diff -rubp linux-2.6.19-rc5_orig/drivers/serial/ioc4_serial.c linux-2.6.19-rc5_kzalloc/drivers/serial/ioc4_serial.c
--- linux-2.6.19-rc5_orig/drivers/serial/ioc4_serial.c 2006-11-09 12:16:21.000000000 +0200
+++ linux-2.6.19-rc5_kzalloc/drivers/serial/ioc4_serial.c 2006-11-11 22:44:04.000000000 +0200
@@ -1076,13 +1076,12 @@ static int inline ioc4_attach_local(stru
/* Create port structures for each port */
for (port_number = 0; port_number < IOC4_NUM_SERIAL_PORTS;
port_number++) {
- port = kmalloc(sizeof(struct ioc4_port), GFP_KERNEL);
+ port = kzalloc(sizeof(struct ioc4_port), GFP_KERNEL);
if (!port) {
printk(KERN_WARNING
"IOC4 serial memory not available for port\n");
return -ENOMEM;
}
- memset(port, 0, sizeof(struct ioc4_port));
spin_lock_init(&port->ip_lock);
/* we need to remember the previous ones, to point back to
@@ -2811,7 +2810,7 @@ ioc4_serial_attach_one(struct ioc4_drive
(void *)serial));
/* Get memory for the new card */
- control = kmalloc(sizeof(struct ioc4_control), GFP_KERNEL);
+ control = kzalloc(sizeof(struct ioc4_control), GFP_KERNEL);
if (!control) {
printk(KERN_WARNING "ioc4_attach_one"
@@ -2819,11 +2818,10 @@ ioc4_serial_attach_one(struct ioc4_drive
ret = -ENOMEM;
goto out2;
}
- memset(control, 0, sizeof(struct ioc4_control));
idd->idd_serial_data = control;
/* Allocate the soft structure */
- soft = kmalloc(sizeof(struct ioc4_soft), GFP_KERNEL);
+ soft = kzalloc(sizeof(struct ioc4_soft), GFP_KERNEL);
if (!soft) {
printk(KERN_WARNING
"ioc4 (%p): unable to get memory for the soft struct\n",
@@ -2831,7 +2829,6 @@ ioc4_serial_attach_one(struct ioc4_drive
ret = -ENOMEM;
goto out3;
}
- memset(soft, 0, sizeof(struct ioc4_soft));
spin_lock_init(&soft->is_ir_lock);
soft->is_ioc4_misc_addr = idd->idd_misc_regs;
diff -rubp linux-2.6.19-rc5_orig/drivers/serial/ip22zilog.c linux-2.6.19-rc5_kzalloc/drivers/serial/ip22zilog.c
--- linux-2.6.19-rc5_orig/drivers/serial/ip22zilog.c 2006-11-09 12:16:21.000000000 +0200
+++ linux-2.6.19-rc5_kzalloc/drivers/serial/ip22zilog.c 2006-11-11 22:44:04.000000000 +0200
@@ -922,13 +922,7 @@ static int zilog_irq = -1;
static void * __init alloc_one_table(unsigned long size)
{
- void *ret;
-
- ret = kmalloc(size, GFP_KERNEL);
- if (ret != NULL)
- memset(ret, 0, size);
-
- return ret;
+ return kzalloc(size, GFP_KERNEL);
}
static void __init ip22zilog_alloc_tables(void)
diff -rubp linux-2.6.19-rc5_orig/drivers/serial/jsm/jsm_driver.c linux-2.6.19-rc5_kzalloc/drivers/serial/jsm/jsm_driver.c
--- linux-2.6.19-rc5_orig/drivers/serial/jsm/jsm_driver.c 2006-11-09 12:16:21.000000000 +0200
+++ linux-2.6.19-rc5_kzalloc/drivers/serial/jsm/jsm_driver.c 2006-11-11 22:44:04.000000000 +0200
@@ -71,14 +71,13 @@ static int jsm_probe_one(struct pci_dev
goto out_disable_device;
}
- brd = kmalloc(sizeof(struct jsm_board), GFP_KERNEL);
+ brd = kzalloc(sizeof(struct jsm_board), GFP_KERNEL);
if (!brd) {
dev_err(&pdev->dev,
"memory allocation for board structure failed\n");
rc = -ENOMEM;
goto out_release_regions;
}
- memset(brd, 0, sizeof(struct jsm_board));
/* store the info for the board we've found */
brd->boardnum = adapter_count++;
@@ -152,7 +151,7 @@ static int jsm_probe_one(struct pci_dev
* Okay to malloc with GFP_KERNEL, we are not at interrupt
* context, and there are no locks held.
*/
- brd->flipbuf = kmalloc(MYFLIPLEN, GFP_KERNEL);
+ brd->flipbuf = kzalloc(MYFLIPLEN, GFP_KERNEL);
if (!brd->flipbuf) {
/* XXX: leaking all resources from jsm_tty_init and
jsm_uart_port_init here! */
@@ -160,7 +159,6 @@ static int jsm_probe_one(struct pci_dev
retval = -ENOMEM;
goto out_free_irq;
}
- memset(brd->flipbuf, 0, MYFLIPLEN);
pci_set_drvdata(pdev, brd);
diff -rubp linux-2.6.19-rc5_orig/drivers/serial/jsm/jsm_tty.c linux-2.6.19-rc5_kzalloc/drivers/serial/jsm/jsm_tty.c
--- linux-2.6.19-rc5_orig/drivers/serial/jsm/jsm_tty.c 2006-11-09 12:16:21.000000000 +0200
+++ linux-2.6.19-rc5_kzalloc/drivers/serial/jsm/jsm_tty.c 2006-11-11 22:44:04.000000000 +0200
@@ -194,31 +194,28 @@ static int jsm_tty_open(struct uart_port
/* Drop locks, as malloc with GFP_KERNEL can sleep */
if (!channel->ch_rqueue) {
- channel->ch_rqueue = (u8 *) kmalloc(RQUEUESIZE, GFP_KERNEL);
+ channel->ch_rqueue = kzalloc(RQUEUESIZE, GFP_KERNEL);
if (!channel->ch_rqueue) {
jsm_printk(INIT, ERR, &channel->ch_bd->pci_dev,
"unable to allocate read queue buf");
return -ENOMEM;
}
- memset(channel->ch_rqueue, 0, RQUEUESIZE);
}
if (!channel->ch_equeue) {
- channel->ch_equeue = (u8 *) kmalloc(EQUEUESIZE, GFP_KERNEL);
+ channel->ch_equeue = kzalloc(EQUEUESIZE, GFP_KERNEL);
if (!channel->ch_equeue) {
jsm_printk(INIT, ERR, &channel->ch_bd->pci_dev,
"unable to allocate error queue buf");
return -ENOMEM;
}
- memset(channel->ch_equeue, 0, EQUEUESIZE);
}
if (!channel->ch_wqueue) {
- channel->ch_wqueue = (u8 *) kmalloc(WQUEUESIZE, GFP_KERNEL);
+ channel->ch_wqueue = kzalloc(WQUEUESIZE, GFP_KERNEL);
if (!channel->ch_wqueue) {
jsm_printk(INIT, ERR, &channel->ch_bd->pci_dev,
"unable to allocate write queue buf");
return -ENOMEM;
}
- memset(channel->ch_wqueue, 0, WQUEUESIZE);
}
channel->ch_flags &= ~(CH_OPENING);
@@ -392,13 +389,12 @@ int jsm_tty_init(struct jsm_board *brd)
* Okay to malloc with GFP_KERNEL, we are not at
* interrupt context, and there are no locks held.
*/
- brd->channels[i] = kmalloc(sizeof(struct jsm_channel), GFP_KERNEL);
+ brd->channels[i] = kzalloc(sizeof(struct jsm_channel), GFP_KERNEL);
if (!brd->channels[i]) {
jsm_printk(CORE, ERR, &brd->pci_dev,
"%s:%d Unable to allocate memory for channel struct\n",
__FILE__, __LINE__);
}
- memset(brd->channels[i], 0, sizeof(struct jsm_channel));
}
}
diff -rubp linux-2.6.19-rc5_orig/drivers/serial/serial_core.c linux-2.6.19-rc5_kzalloc/drivers/serial/serial_core.c
--- linux-2.6.19-rc5_orig/drivers/serial/serial_core.c 2006-11-09 12:16:21.000000000 +0200
+++ linux-2.6.19-rc5_kzalloc/drivers/serial/serial_core.c 2006-11-11 22:44:04.000000000 +0200
@@ -1523,9 +1523,8 @@ static struct uart_state *uart_get(struc
}
if (!state->info) {
- state->info = kmalloc(sizeof(struct uart_info), GFP_KERNEL);
+ state->info = kzalloc(sizeof(struct uart_info), GFP_KERNEL);
if (state->info) {
- memset(state->info, 0, sizeof(struct uart_info));
init_waitqueue_head(&state->info->open_wait);
init_waitqueue_head(&state->info->delta_msr_wait);
@@ -2167,13 +2166,11 @@ int uart_register_driver(struct uart_dri
* Maybe we should be using a slab cache for this, especially if
* we have a large number of ports to handle.
*/
- drv->state = kmalloc(sizeof(struct uart_state) * drv->nr, GFP_KERNEL);
+ drv->state = kzalloc(sizeof(struct uart_state) * drv->nr, GFP_KERNEL);
retval = -ENOMEM;
if (!drv->state)
goto out;
- memset(drv->state, 0, sizeof(struct uart_state) * drv->nr);
-
normal = alloc_tty_driver(drv->nr);
if (!normal)
goto out;
diff -rubp linux-2.6.19-rc5_orig/drivers/serial/serial_cs.c linux-2.6.19-rc5_kzalloc/drivers/serial/serial_cs.c
--- linux-2.6.19-rc5_orig/drivers/serial/serial_cs.c 2006-11-09 12:16:21.000000000 +0200
+++ linux-2.6.19-rc5_kzalloc/drivers/serial/serial_cs.c 2006-11-11 22:44:04.000000000 +0200
@@ -334,10 +334,9 @@ static int serial_probe(struct pcmcia_de
DEBUG(0, "serial_attach()\n");
/* Create new serial device */
- info = kmalloc(sizeof (*info), GFP_KERNEL);
+ info = kzalloc(sizeof (*info), GFP_KERNEL);
if (!info)
return -ENOMEM;
- memset(info, 0, sizeof (*info));
info->p_dev = link;
link->priv = info;
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH 2.6.19-rc6] serial: replace kmalloc+memset with kzalloc
2006-11-22 18:57 [PATCH 2.6.19-rc6] serial: replace kmalloc+memset with kzalloc Burman Yan
@ 2006-11-22 19:12 ` Russell King
0 siblings, 0 replies; 2+ messages in thread
From: Russell King @ 2006-11-22 19:12 UTC (permalink / raw)
To: Burman Yan; +Cc: linux-kernel, trivial
On Wed, Nov 22, 2006 at 08:57:33PM +0200, Burman Yan wrote:
> diff -rubp linux-2.6.19-rc5_orig/drivers/serial/8250_acorn.c linux-2.6.19-rc5_kzalloc/drivers/serial/8250_acorn.c
> --- linux-2.6.19-rc5_orig/drivers/serial/8250_acorn.c 2006-11-09 12:16:21.000000000 +0200
> +++ linux-2.6.19-rc5_kzalloc/drivers/serial/8250_acorn.c 2006-11-11 22:44:04.000000000 +0200
> @@ -47,11 +47,10 @@ serial_card_probe(struct expansion_card
> unsigned long bus_addr;
> unsigned int i;
>
> - info = kmalloc(sizeof(struct serial_card_info), GFP_KERNEL);
> + info = kzalloc(sizeof(struct serial_card_info), GFP_KERNEL);
> if (!info)
> return -ENOMEM;
>
> - memset(info, 0, sizeof(struct serial_card_info));
> info->num_ports = type->num_ports;
>
> bus_addr = ecard_resource_start(ec, type->type);
> diff -rubp linux-2.6.19-rc5_orig/drivers/serial/8250_pci.c linux-2.6.19-rc5_kzalloc/drivers/serial/8250_pci.c
> --- linux-2.6.19-rc5_orig/drivers/serial/8250_pci.c 2006-11-09 12:16:21.000000000 +0200
> +++ linux-2.6.19-rc5_kzalloc/drivers/serial/8250_pci.c 2006-11-11 22:44:18.000000000 +0200
> @@ -1614,7 +1614,7 @@ pciserial_init_ports(struct pci_dev *dev
> nr_ports = rc;
> }
>
> - priv = kmalloc(sizeof(struct serial_private) +
> + priv = kzalloc(sizeof(struct serial_private) +
> sizeof(unsigned int) * nr_ports,
> GFP_KERNEL);
> if (!priv) {
> @@ -1622,9 +1622,6 @@ pciserial_init_ports(struct pci_dev *dev
> goto err_deinit;
> }
>
> - memset(priv, 0, sizeof(struct serial_private) +
> - sizeof(unsigned int) * nr_ports);
> -
> priv->dev = dev;
> priv->quirk = quirk;
>
> diff -rubp linux-2.6.19-rc5_orig/drivers/serial/serial_core.c linux-2.6.19-rc5_kzalloc/drivers/serial/serial_core.c
> --- linux-2.6.19-rc5_orig/drivers/serial/serial_core.c 2006-11-09 12:16:21.000000000 +0200
> +++ linux-2.6.19-rc5_kzalloc/drivers/serial/serial_core.c 2006-11-11 22:44:04.000000000 +0200
> @@ -1523,9 +1523,8 @@ static struct uart_state *uart_get(struc
> }
>
> if (!state->info) {
> - state->info = kmalloc(sizeof(struct uart_info), GFP_KERNEL);
> + state->info = kzalloc(sizeof(struct uart_info), GFP_KERNEL);
> if (state->info) {
> - memset(state->info, 0, sizeof(struct uart_info));
> init_waitqueue_head(&state->info->open_wait);
> init_waitqueue_head(&state->info->delta_msr_wait);
>
> @@ -2167,13 +2166,11 @@ int uart_register_driver(struct uart_dri
> * Maybe we should be using a slab cache for this, especially if
> * we have a large number of ports to handle.
> */
> - drv->state = kmalloc(sizeof(struct uart_state) * drv->nr, GFP_KERNEL);
> + drv->state = kzalloc(sizeof(struct uart_state) * drv->nr, GFP_KERNEL);
> retval = -ENOMEM;
> if (!drv->state)
> goto out;
>
> - memset(drv->state, 0, sizeof(struct uart_state) * drv->nr);
> -
> normal = alloc_tty_driver(drv->nr);
> if (!normal)
> goto out;
> diff -rubp linux-2.6.19-rc5_orig/drivers/serial/serial_cs.c linux-2.6.19-rc5_kzalloc/drivers/serial/serial_cs.c
> --- linux-2.6.19-rc5_orig/drivers/serial/serial_cs.c 2006-11-09 12:16:21.000000000 +0200
> +++ linux-2.6.19-rc5_kzalloc/drivers/serial/serial_cs.c 2006-11-11 22:44:04.000000000 +0200
> @@ -334,10 +334,9 @@ static int serial_probe(struct pcmcia_de
> DEBUG(0, "serial_attach()\n");
>
> /* Create new serial device */
> - info = kmalloc(sizeof (*info), GFP_KERNEL);
> + info = kzalloc(sizeof (*info), GFP_KERNEL);
> if (!info)
> return -ENOMEM;
> - memset(info, 0, sizeof (*info));
> info->p_dev = link;
> link->priv = info;
>
The above (and only the above 4 files):
Acked-by: Russell King <rmk+kernel@arm.linux.org.uk>
--
Russell King
Linux kernel 2.6 ARM Linux - http://www.arm.linux.org.uk/
maintainer of:
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2006-11-22 19:12 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-11-22 18:57 [PATCH 2.6.19-rc6] serial: replace kmalloc+memset with kzalloc Burman Yan
2006-11-22 19:12 ` Russell King
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®