aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBurman Yan <yan_952@hotmail.com>2007-02-14 03:33:07 -0500
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-02-14 11:09:52 -0500
commit8f31bb39ec2a5622974666c72257e74c22492602 (patch)
tree48f38c994f02c8699fe2a69599e8cc1bc8d36ea8
parent3689a0ec60bc8f56cc372c1dfa0d89dab48f7c9c (diff)
[PATCH] serial: replace kmalloc+memset with kzalloc
Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--drivers/serial/8250_acorn.c3
-rw-r--r--drivers/serial/8250_pci.c5
-rw-r--r--drivers/serial/icom.c4
-rw-r--r--drivers/serial/ioc3_serial.c6
-rw-r--r--drivers/serial/ioc4_serial.c9
-rw-r--r--drivers/serial/ip22zilog.c8
-rw-r--r--drivers/serial/jsm/jsm_driver.c6
-rw-r--r--drivers/serial/jsm/jsm_tty.c12
-rw-r--r--drivers/serial/serial_core.c7
-rw-r--r--drivers/serial/serial_cs.c3
10 files changed, 18 insertions, 45 deletions
diff --git a/drivers/serial/8250_acorn.c b/drivers/serial/8250_acorn.c
index ef8cc8a70c60..562ba745a044 100644
--- a/drivers/serial/8250_acorn.c
+++ b/drivers/serial/8250_acorn.c
@@ -47,11 +47,10 @@ serial_card_probe(struct expansion_card *ec, const struct ecard_id *id)
47 unsigned long bus_addr; 47 unsigned long bus_addr;
48 unsigned int i; 48 unsigned int i;
49 49
50 info = kmalloc(sizeof(struct serial_card_info), GFP_KERNEL); 50 info = kzalloc(sizeof(struct serial_card_info), GFP_KERNEL);
51 if (!info) 51 if (!info)
52 return -ENOMEM; 52 return -ENOMEM;
53 53
54 memset(info, 0, sizeof(struct serial_card_info));
55 info->num_ports = type->num_ports; 54 info->num_ports = type->num_ports;
56 55
57 bus_addr = ecard_resource_start(ec, type->type); 56 bus_addr = ecard_resource_start(ec, type->type);
diff --git a/drivers/serial/8250_pci.c b/drivers/serial/8250_pci.c
index a2dac378bda9..2989228ed701 100644
--- a/drivers/serial/8250_pci.c
+++ b/drivers/serial/8250_pci.c
@@ -1628,7 +1628,7 @@ pciserial_init_ports(struct pci_dev *dev, struct pciserial_board *board)
1628 nr_ports = rc; 1628 nr_ports = rc;
1629 } 1629 }
1630 1630
1631 priv = kmalloc(sizeof(struct serial_private) + 1631 priv = kzalloc(sizeof(struct serial_private) +
1632 sizeof(unsigned int) * nr_ports, 1632 sizeof(unsigned int) * nr_ports,
1633 GFP_KERNEL); 1633 GFP_KERNEL);
1634 if (!priv) { 1634 if (!priv) {
@@ -1636,9 +1636,6 @@ pciserial_init_ports(struct pci_dev *dev, struct pciserial_board *board)
1636 goto err_deinit; 1636 goto err_deinit;
1637 } 1637 }
1638 1638
1639 memset(priv, 0, sizeof(struct serial_private) +
1640 sizeof(unsigned int) * nr_ports);
1641
1642 priv->dev = dev; 1639 priv->dev = dev;
1643 priv->quirk = quirk; 1640 priv->quirk = quirk;
1644 1641
diff --git a/drivers/serial/icom.c b/drivers/serial/icom.c
index 71e6a24d8c28..1c4c381bbc5a 100644
--- a/drivers/serial/icom.c
+++ b/drivers/serial/icom.c
@@ -1417,14 +1417,12 @@ static int __devinit icom_alloc_adapter(struct icom_adapter
1417 struct list_head *tmp; 1417 struct list_head *tmp;
1418 1418
1419 icom_adapter = (struct icom_adapter *) 1419 icom_adapter = (struct icom_adapter *)
1420 kmalloc(sizeof(struct icom_adapter), GFP_KERNEL); 1420 kzalloc(sizeof(struct icom_adapter), GFP_KERNEL);
1421 1421
1422 if (!icom_adapter) { 1422 if (!icom_adapter) {
1423 return -ENOMEM; 1423 return -ENOMEM;
1424 } 1424 }
1425 1425
1426 memset(icom_adapter, 0, sizeof(struct icom_adapter));
1427
1428 list_for_each(tmp, &icom_adapter_head) { 1426 list_for_each(tmp, &icom_adapter_head) {
1429 cur_adapter_entry = 1427 cur_adapter_entry =
1430 list_entry(tmp, struct icom_adapter, 1428 list_entry(tmp, struct icom_adapter,
diff --git a/drivers/serial/ioc3_serial.c b/drivers/serial/ioc3_serial.c
index 9cc0be932316..168073f12cec 100644
--- a/drivers/serial/ioc3_serial.c
+++ b/drivers/serial/ioc3_serial.c
@@ -2019,13 +2019,12 @@ ioc3uart_probe(struct ioc3_submodule *is, struct ioc3_driver_data *idd)
2019 2019
2020 DPRINT_CONFIG(("%s (0x%p, 0x%p)\n", __FUNCTION__, is, idd)); 2020 DPRINT_CONFIG(("%s (0x%p, 0x%p)\n", __FUNCTION__, is, idd));
2021 2021
2022 card_ptr = kmalloc(sizeof(struct ioc3_card), GFP_KERNEL); 2022 card_ptr = kzalloc(sizeof(struct ioc3_card), GFP_KERNEL);
2023 if (!card_ptr) { 2023 if (!card_ptr) {
2024 printk(KERN_WARNING "ioc3_attach_one" 2024 printk(KERN_WARNING "ioc3_attach_one"
2025 ": unable to get memory for the IOC3\n"); 2025 ": unable to get memory for the IOC3\n");
2026 return -ENOMEM; 2026 return -ENOMEM;
2027 } 2027 }
2028 memset(card_ptr, 0, sizeof(struct ioc3_card));
2029 idd->data[is->id] = card_ptr; 2028 idd->data[is->id] = card_ptr;
2030 Submodule_slot = is->id; 2029 Submodule_slot = is->id;
2031 2030
@@ -2040,13 +2039,12 @@ ioc3uart_probe(struct ioc3_submodule *is, struct ioc3_driver_data *idd)
2040 2039
2041 /* Create port structures for each port */ 2040 /* Create port structures for each port */
2042 for (phys_port = 0; phys_port < PORTS_PER_CARD; phys_port++) { 2041 for (phys_port = 0; phys_port < PORTS_PER_CARD; phys_port++) {
2043 port = kmalloc(sizeof(struct ioc3_port), GFP_KERNEL); 2042 port = kzalloc(sizeof(struct ioc3_port), GFP_KERNEL);
2044 if (!port) { 2043 if (!port) {
2045 printk(KERN_WARNING 2044 printk(KERN_WARNING
2046 "IOC3 serial memory not available for port\n"); 2045 "IOC3 serial memory not available for port\n");
2047 goto out4; 2046 goto out4;
2048 } 2047 }
2049 memset(port, 0, sizeof(struct ioc3_port));
2050 spin_lock_init(&port->ip_lock); 2048 spin_lock_init(&port->ip_lock);
2051 2049
2052 /* we need to remember the previous ones, to point back to 2050 /* we need to remember the previous ones, to point back to
diff --git a/drivers/serial/ioc4_serial.c b/drivers/serial/ioc4_serial.c
index f540212e7409..0c179384fb0c 100644
--- a/drivers/serial/ioc4_serial.c
+++ b/drivers/serial/ioc4_serial.c
@@ -1076,13 +1076,12 @@ static int inline ioc4_attach_local(struct ioc4_driver_data *idd)
1076 /* Create port structures for each port */ 1076 /* Create port structures for each port */
1077 for (port_number = 0; port_number < IOC4_NUM_SERIAL_PORTS; 1077 for (port_number = 0; port_number < IOC4_NUM_SERIAL_PORTS;
1078 port_number++) { 1078 port_number++) {
1079 port = kmalloc(sizeof(struct ioc4_port), GFP_KERNEL); 1079 port = kzalloc(sizeof(struct ioc4_port), GFP_KERNEL);
1080 if (!port) { 1080 if (!port) {
1081 printk(KERN_WARNING 1081 printk(KERN_WARNING
1082 "IOC4 serial memory not available for port\n"); 1082 "IOC4 serial memory not available for port\n");
1083 return -ENOMEM; 1083 return -ENOMEM;
1084 } 1084 }
1085 memset(port, 0, sizeof(struct ioc4_port));
1086 spin_lock_init(&port->ip_lock); 1085 spin_lock_init(&port->ip_lock);
1087 1086
1088 /* we need to remember the previous ones, to point back to 1087 /* we need to remember the previous ones, to point back to
@@ -2811,7 +2810,7 @@ ioc4_serial_attach_one(struct ioc4_driver_data *idd)
2811 (void *)serial)); 2810 (void *)serial));
2812 2811
2813 /* Get memory for the new card */ 2812 /* Get memory for the new card */
2814 control = kmalloc(sizeof(struct ioc4_control), GFP_KERNEL); 2813 control = kzalloc(sizeof(struct ioc4_control), GFP_KERNEL);
2815 2814
2816 if (!control) { 2815 if (!control) {
2817 printk(KERN_WARNING "ioc4_attach_one" 2816 printk(KERN_WARNING "ioc4_attach_one"
@@ -2819,11 +2818,10 @@ ioc4_serial_attach_one(struct ioc4_driver_data *idd)
2819 ret = -ENOMEM; 2818 ret = -ENOMEM;
2820 goto out2; 2819 goto out2;
2821 } 2820 }
2822 memset(control, 0, sizeof(struct ioc4_control));
2823 idd->idd_serial_data = control; 2821 idd->idd_serial_data = control;
2824 2822
2825 /* Allocate the soft structure */ 2823 /* Allocate the soft structure */
2826 soft = kmalloc(sizeof(struct ioc4_soft), GFP_KERNEL); 2824 soft = kzalloc(sizeof(struct ioc4_soft), GFP_KERNEL);
2827 if (!soft) { 2825 if (!soft) {
2828 printk(KERN_WARNING 2826 printk(KERN_WARNING
2829 "ioc4 (%p): unable to get memory for the soft struct\n", 2827 "ioc4 (%p): unable to get memory for the soft struct\n",
@@ -2831,7 +2829,6 @@ ioc4_serial_attach_one(struct ioc4_driver_data *idd)
2831 ret = -ENOMEM; 2829 ret = -ENOMEM;
2832 goto out3; 2830 goto out3;
2833 } 2831 }
2834 memset(soft, 0, sizeof(struct ioc4_soft));
2835 2832
2836 spin_lock_init(&soft->is_ir_lock); 2833 spin_lock_init(&soft->is_ir_lock);
2837 soft->is_ioc4_misc_addr = idd->idd_misc_regs; 2834 soft->is_ioc4_misc_addr = idd->idd_misc_regs;
diff --git a/drivers/serial/ip22zilog.c b/drivers/serial/ip22zilog.c
index 0746c9446ae0..c475f22fb681 100644
--- a/drivers/serial/ip22zilog.c
+++ b/drivers/serial/ip22zilog.c
@@ -922,13 +922,7 @@ static int zilog_irq = -1;
922 922
923static void * __init alloc_one_table(unsigned long size) 923static void * __init alloc_one_table(unsigned long size)
924{ 924{
925 void *ret; 925 return kzalloc(size, GFP_KERNEL);
926
927 ret = kmalloc(size, GFP_KERNEL);
928 if (ret != NULL)
929 memset(ret, 0, size);
930
931 return ret;
932} 926}
933 927
934static void __init ip22zilog_alloc_tables(void) 928static void __init ip22zilog_alloc_tables(void)
diff --git a/drivers/serial/jsm/jsm_driver.c b/drivers/serial/jsm/jsm_driver.c
index 244f63be3a03..81792e6eeb2d 100644
--- a/drivers/serial/jsm/jsm_driver.c
+++ b/drivers/serial/jsm/jsm_driver.c
@@ -71,14 +71,13 @@ static int jsm_probe_one(struct pci_dev *pdev, const struct pci_device_id *ent)
71 goto out_disable_device; 71 goto out_disable_device;
72 } 72 }
73 73
74 brd = kmalloc(sizeof(struct jsm_board), GFP_KERNEL); 74 brd = kzalloc(sizeof(struct jsm_board), GFP_KERNEL);
75 if (!brd) { 75 if (!brd) {
76 dev_err(&pdev->dev, 76 dev_err(&pdev->dev,
77 "memory allocation for board structure failed\n"); 77 "memory allocation for board structure failed\n");
78 rc = -ENOMEM; 78 rc = -ENOMEM;
79 goto out_release_regions; 79 goto out_release_regions;
80 } 80 }
81 memset(brd, 0, sizeof(struct jsm_board));
82 81
83 /* store the info for the board we've found */ 82 /* store the info for the board we've found */
84 brd->boardnum = adapter_count++; 83 brd->boardnum = adapter_count++;
@@ -152,7 +151,7 @@ static int jsm_probe_one(struct pci_dev *pdev, const struct pci_device_id *ent)
152 * Okay to malloc with GFP_KERNEL, we are not at interrupt 151 * Okay to malloc with GFP_KERNEL, we are not at interrupt
153 * context, and there are no locks held. 152 * context, and there are no locks held.
154 */ 153 */
155 brd->flipbuf = kmalloc(MYFLIPLEN, GFP_KERNEL); 154 brd->flipbuf = kzalloc(MYFLIPLEN, GFP_KERNEL);
156 if (!brd->flipbuf) { 155 if (!brd->flipbuf) {
157 /* XXX: leaking all resources from jsm_tty_init and 156 /* XXX: leaking all resources from jsm_tty_init and
158 jsm_uart_port_init here! */ 157 jsm_uart_port_init here! */
@@ -160,7 +159,6 @@ static int jsm_probe_one(struct pci_dev *pdev, const struct pci_device_id *ent)
160 retval = -ENOMEM; 159 retval = -ENOMEM;
161 goto out_free_irq; 160 goto out_free_irq;
162 } 161 }
163 memset(brd->flipbuf, 0, MYFLIPLEN);
164 162
165 pci_set_drvdata(pdev, brd); 163 pci_set_drvdata(pdev, brd);
166 164
diff --git a/drivers/serial/jsm/jsm_tty.c b/drivers/serial/jsm/jsm_tty.c
index 7cf1c60027f8..be22bbdbc8e5 100644
--- a/drivers/serial/jsm/jsm_tty.c
+++ b/drivers/serial/jsm/jsm_tty.c
@@ -194,31 +194,28 @@ static int jsm_tty_open(struct uart_port *port)
194 /* Drop locks, as malloc with GFP_KERNEL can sleep */ 194 /* Drop locks, as malloc with GFP_KERNEL can sleep */
195 195
196 if (!channel->ch_rqueue) { 196 if (!channel->ch_rqueue) {
197 channel->ch_rqueue = (u8 *) kmalloc(RQUEUESIZE, GFP_KERNEL); 197 channel->ch_rqueue = kzalloc(RQUEUESIZE, GFP_KERNEL);
198 if (!channel->ch_rqueue) { 198 if (!channel->ch_rqueue) {
199 jsm_printk(INIT, ERR, &channel->ch_bd->pci_dev, 199 jsm_printk(INIT, ERR, &channel->ch_bd->pci_dev,
200 "unable to allocate read queue buf"); 200 "unable to allocate read queue buf");
201 return -ENOMEM; 201 return -ENOMEM;
202 } 202 }
203 memset(channel->ch_rqueue, 0, RQUEUESIZE);
204 } 203 }
205 if (!channel->ch_equeue) { 204 if (!channel->ch_equeue) {
206 channel->ch_equeue = (u8 *) kmalloc(EQUEUESIZE, GFP_KERNEL); 205 channel->ch_equeue = kzalloc(EQUEUESIZE, GFP_KERNEL);
207 if (!channel->ch_equeue) { 206 if (!channel->ch_equeue) {
208 jsm_printk(INIT, ERR, &channel->ch_bd->pci_dev, 207 jsm_printk(INIT, ERR, &channel->ch_bd->pci_dev,
209 "unable to allocate error queue buf"); 208 "unable to allocate error queue buf");
210 return -ENOMEM; 209 return -ENOMEM;
211 } 210 }
212 memset(channel->ch_equeue, 0, EQUEUESIZE);
213 } 211 }
214 if (!channel->ch_wqueue) { 212 if (!channel->ch_wqueue) {
215 channel->ch_wqueue = (u8 *) kmalloc(WQUEUESIZE, GFP_KERNEL); 213 channel->ch_wqueue = kzalloc(WQUEUESIZE, GFP_KERNEL);
216 if (!channel->ch_wqueue) { 214 if (!channel->ch_wqueue) {
217 jsm_printk(INIT, ERR, &channel->ch_bd->pci_dev, 215 jsm_printk(INIT, ERR, &channel->ch_bd->pci_dev,
218 "unable to allocate write queue buf"); 216 "unable to allocate write queue buf");
219 return -ENOMEM; 217 return -ENOMEM;
220 } 218 }
221 memset(channel->ch_wqueue, 0, WQUEUESIZE);
222 } 219 }
223 220
224 channel->ch_flags &= ~(CH_OPENING); 221 channel->ch_flags &= ~(CH_OPENING);
@@ -392,13 +389,12 @@ int jsm_tty_init(struct jsm_board *brd)
392 * Okay to malloc with GFP_KERNEL, we are not at 389 * Okay to malloc with GFP_KERNEL, we are not at
393 * interrupt context, and there are no locks held. 390 * interrupt context, and there are no locks held.
394 */ 391 */
395 brd->channels[i] = kmalloc(sizeof(struct jsm_channel), GFP_KERNEL); 392 brd->channels[i] = kzalloc(sizeof(struct jsm_channel), GFP_KERNEL);
396 if (!brd->channels[i]) { 393 if (!brd->channels[i]) {
397 jsm_printk(CORE, ERR, &brd->pci_dev, 394 jsm_printk(CORE, ERR, &brd->pci_dev,
398 "%s:%d Unable to allocate memory for channel struct\n", 395 "%s:%d Unable to allocate memory for channel struct\n",
399 __FILE__, __LINE__); 396 __FILE__, __LINE__);
400 } 397 }
401 memset(brd->channels[i], 0, sizeof(struct jsm_channel));
402 } 398 }
403 } 399 }
404 400
diff --git a/drivers/serial/serial_core.c b/drivers/serial/serial_core.c
index 66fdd3b2b958..0422c0f1f852 100644
--- a/drivers/serial/serial_core.c
+++ b/drivers/serial/serial_core.c
@@ -1523,9 +1523,8 @@ static struct uart_state *uart_get(struct uart_driver *drv, int line)
1523 } 1523 }
1524 1524
1525 if (!state->info) { 1525 if (!state->info) {
1526 state->info = kmalloc(sizeof(struct uart_info), GFP_KERNEL); 1526 state->info = kzalloc(sizeof(struct uart_info), GFP_KERNEL);
1527 if (state->info) { 1527 if (state->info) {
1528 memset(state->info, 0, sizeof(struct uart_info));
1529 init_waitqueue_head(&state->info->open_wait); 1528 init_waitqueue_head(&state->info->open_wait);
1530 init_waitqueue_head(&state->info->delta_msr_wait); 1529 init_waitqueue_head(&state->info->delta_msr_wait);
1531 1530
@@ -2178,13 +2177,11 @@ int uart_register_driver(struct uart_driver *drv)
2178 * Maybe we should be using a slab cache for this, especially if 2177 * Maybe we should be using a slab cache for this, especially if
2179 * we have a large number of ports to handle. 2178 * we have a large number of ports to handle.
2180 */ 2179 */
2181 drv->state = kmalloc(sizeof(struct uart_state) * drv->nr, GFP_KERNEL); 2180 drv->state = kzalloc(sizeof(struct uart_state) * drv->nr, GFP_KERNEL);
2182 retval = -ENOMEM; 2181 retval = -ENOMEM;
2183 if (!drv->state) 2182 if (!drv->state)
2184 goto out; 2183 goto out;
2185 2184
2186 memset(drv->state, 0, sizeof(struct uart_state) * drv->nr);
2187
2188 normal = alloc_tty_driver(drv->nr); 2185 normal = alloc_tty_driver(drv->nr);
2189 if (!normal) 2186 if (!normal)
2190 goto out; 2187 goto out;
diff --git a/drivers/serial/serial_cs.c b/drivers/serial/serial_cs.c
index 431433f4dd6d..10baa2c91302 100644
--- a/drivers/serial/serial_cs.c
+++ b/drivers/serial/serial_cs.c
@@ -334,10 +334,9 @@ static int serial_probe(struct pcmcia_device *link)
334 DEBUG(0, "serial_attach()\n"); 334 DEBUG(0, "serial_attach()\n");
335 335
336 /* Create new serial device */ 336 /* Create new serial device */
337 info = kmalloc(sizeof (*info), GFP_KERNEL); 337 info = kzalloc(sizeof (*info), GFP_KERNEL);
338 if (!info) 338 if (!info)
339 return -ENOMEM; 339 return -ENOMEM;
340 memset(info, 0, sizeof (*info));
341 info->p_dev = link; 340 info->p_dev = link;
342 link->priv = info; 341 link->priv = info;
343 342