diff options
author | Burman Yan <yan_952@hotmail.com> | 2007-02-14 03:33:07 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-02-14 11:09:52 -0500 |
commit | 8f31bb39ec2a5622974666c72257e74c22492602 (patch) | |
tree | 48f38c994f02c8699fe2a69599e8cc1bc8d36ea8 /drivers/serial/jsm | |
parent | 3689a0ec60bc8f56cc372c1dfa0d89dab48f7c9c (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>
Diffstat (limited to 'drivers/serial/jsm')
-rw-r--r-- | drivers/serial/jsm/jsm_driver.c | 6 | ||||
-rw-r--r-- | drivers/serial/jsm/jsm_tty.c | 12 |
2 files changed, 6 insertions, 12 deletions
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 | ||