diff options
author | Christoph Hellwig <hch@lst.de> | 2006-01-13 12:27:50 -0500 |
---|---|---|
committer | James Bottomley <jejb@mulgrave.(none)> | 2006-01-14 11:54:58 -0500 |
commit | 1ca00bb7916cb40b8140173c23481e11d92d6f6a (patch) | |
tree | e5a16f6f230556ce43f77139c729f09a16ec95fb | |
parent | eeb846cefdd842af479393a7d0fd399a29e42532 (diff) |
[SCSI] fusion: kzalloc / kcalloc conversion
Convert kmalloc + memset to kzalloc or kcalloc in fusion.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
-rw-r--r-- | drivers/message/fusion/mptbase.c | 3 | ||||
-rw-r--r-- | drivers/message/fusion/mptfc.c | 26 | ||||
-rw-r--r-- | drivers/message/fusion/mptlan.c | 14 | ||||
-rw-r--r-- | drivers/message/fusion/mptsas.c | 35 | ||||
-rw-r--r-- | drivers/message/fusion/mptscsih.c | 6 | ||||
-rw-r--r-- | drivers/message/fusion/mptspi.c | 26 |
6 files changed, 35 insertions, 75 deletions
diff --git a/drivers/message/fusion/mptbase.c b/drivers/message/fusion/mptbase.c index 537836068c49..80ec89c505d2 100644 --- a/drivers/message/fusion/mptbase.c +++ b/drivers/message/fusion/mptbase.c | |||
@@ -1232,12 +1232,11 @@ mpt_attach(struct pci_dev *pdev, const struct pci_device_id *id) | |||
1232 | dprintk((KERN_INFO MYNAM | 1232 | dprintk((KERN_INFO MYNAM |
1233 | ": Not using 64 bit consistent mask\n")); | 1233 | ": Not using 64 bit consistent mask\n")); |
1234 | 1234 | ||
1235 | ioc = kmalloc(sizeof(MPT_ADAPTER), GFP_ATOMIC); | 1235 | ioc = kzalloc(sizeof(MPT_ADAPTER), GFP_ATOMIC); |
1236 | if (ioc == NULL) { | 1236 | if (ioc == NULL) { |
1237 | printk(KERN_ERR MYNAM ": ERROR - Insufficient memory to add adapter!\n"); | 1237 | printk(KERN_ERR MYNAM ": ERROR - Insufficient memory to add adapter!\n"); |
1238 | return -ENOMEM; | 1238 | return -ENOMEM; |
1239 | } | 1239 | } |
1240 | memset(ioc, 0, sizeof(MPT_ADAPTER)); | ||
1241 | ioc->alloc_total = sizeof(MPT_ADAPTER); | 1240 | ioc->alloc_total = sizeof(MPT_ADAPTER); |
1242 | ioc->req_sz = MPT_DEFAULT_FRAME_SIZE; /* avoid div by zero! */ | 1241 | ioc->req_sz = MPT_DEFAULT_FRAME_SIZE; /* avoid div by zero! */ |
1243 | ioc->reply_sz = MPT_REPLY_FRAME_SIZE; | 1242 | ioc->reply_sz = MPT_REPLY_FRAME_SIZE; |
diff --git a/drivers/message/fusion/mptfc.c b/drivers/message/fusion/mptfc.c index ba61e1828858..5083a556a258 100644 --- a/drivers/message/fusion/mptfc.c +++ b/drivers/message/fusion/mptfc.c | |||
@@ -148,11 +148,10 @@ mptfc_probe(struct pci_dev *pdev, const struct pci_device_id *id) | |||
148 | MPT_SCSI_HOST *hd; | 148 | MPT_SCSI_HOST *hd; |
149 | MPT_ADAPTER *ioc; | 149 | MPT_ADAPTER *ioc; |
150 | unsigned long flags; | 150 | unsigned long flags; |
151 | int sz, ii; | 151 | int ii; |
152 | int numSGE = 0; | 152 | int numSGE = 0; |
153 | int scale; | 153 | int scale; |
154 | int ioc_cap; | 154 | int ioc_cap; |
155 | u8 *mem; | ||
156 | int error=0; | 155 | int error=0; |
157 | int r; | 156 | int r; |
158 | 157 | ||
@@ -268,36 +267,27 @@ mptfc_probe(struct pci_dev *pdev, const struct pci_device_id *id) | |||
268 | /* SCSI needs scsi_cmnd lookup table! | 267 | /* SCSI needs scsi_cmnd lookup table! |
269 | * (with size equal to req_depth*PtrSz!) | 268 | * (with size equal to req_depth*PtrSz!) |
270 | */ | 269 | */ |
271 | sz = ioc->req_depth * sizeof(void *); | 270 | hd->ScsiLookup = kcalloc(ioc->req_depth, sizeof(void *), GFP_ATOMIC); |
272 | mem = kmalloc(sz, GFP_ATOMIC); | 271 | if (!hd->ScsiLookup) { |
273 | if (mem == NULL) { | ||
274 | error = -ENOMEM; | 272 | error = -ENOMEM; |
275 | goto out_mptfc_probe; | 273 | goto out_mptfc_probe; |
276 | } | 274 | } |
277 | 275 | ||
278 | memset(mem, 0, sz); | 276 | dprintk((MYIOC_s_INFO_FMT "ScsiLookup @ %p\n", |
279 | hd->ScsiLookup = (struct scsi_cmnd **) mem; | 277 | ioc->name, hd->ScsiLookup)); |
280 | |||
281 | dprintk((MYIOC_s_INFO_FMT "ScsiLookup @ %p, sz=%d\n", | ||
282 | ioc->name, hd->ScsiLookup, sz)); | ||
283 | 278 | ||
284 | /* Allocate memory for the device structures. | 279 | /* Allocate memory for the device structures. |
285 | * A non-Null pointer at an offset | 280 | * A non-Null pointer at an offset |
286 | * indicates a device exists. | 281 | * indicates a device exists. |
287 | * max_id = 1 + maximum id (hosts.h) | 282 | * max_id = 1 + maximum id (hosts.h) |
288 | */ | 283 | */ |
289 | sz = sh->max_id * sizeof(void *); | 284 | hd->Targets = kcalloc(sh->max_id, sizeof(void *), GFP_ATOMIC); |
290 | mem = kmalloc(sz, GFP_ATOMIC); | 285 | if (!hd->Targets) { |
291 | if (mem == NULL) { | ||
292 | error = -ENOMEM; | 286 | error = -ENOMEM; |
293 | goto out_mptfc_probe; | 287 | goto out_mptfc_probe; |
294 | } | 288 | } |
295 | 289 | ||
296 | memset(mem, 0, sz); | 290 | dprintk((KERN_INFO " vdev @ %p\n", hd->Targets)); |
297 | hd->Targets = (VirtTarget **) mem; | ||
298 | |||
299 | dprintk((KERN_INFO | ||
300 | " vdev @ %p, sz=%d\n", hd->Targets, sz)); | ||
301 | 291 | ||
302 | /* Clear the TM flags | 292 | /* Clear the TM flags |
303 | */ | 293 | */ |
diff --git a/drivers/message/fusion/mptlan.c b/drivers/message/fusion/mptlan.c index 014085d8ec85..0b1b72825ae2 100644 --- a/drivers/message/fusion/mptlan.c +++ b/drivers/message/fusion/mptlan.c | |||
@@ -411,14 +411,12 @@ mpt_lan_open(struct net_device *dev) | |||
411 | goto out; | 411 | goto out; |
412 | priv->mpt_txfidx_tail = -1; | 412 | priv->mpt_txfidx_tail = -1; |
413 | 413 | ||
414 | priv->SendCtl = kmalloc(priv->tx_max_out * sizeof(struct BufferControl), | 414 | priv->SendCtl = kcalloc(priv->tx_max_out, sizeof(struct BufferControl), |
415 | GFP_KERNEL); | 415 | GFP_KERNEL); |
416 | if (priv->SendCtl == NULL) | 416 | if (priv->SendCtl == NULL) |
417 | goto out_mpt_txfidx; | 417 | goto out_mpt_txfidx; |
418 | for (i = 0; i < priv->tx_max_out; i++) { | 418 | for (i = 0; i < priv->tx_max_out; i++) |
419 | memset(&priv->SendCtl[i], 0, sizeof(struct BufferControl)); | ||
420 | priv->mpt_txfidx[++priv->mpt_txfidx_tail] = i; | 419 | priv->mpt_txfidx[++priv->mpt_txfidx_tail] = i; |
421 | } | ||
422 | 420 | ||
423 | dlprintk((KERN_INFO MYNAM "@lo: Finished initializing SendCtl\n")); | 421 | dlprintk((KERN_INFO MYNAM "@lo: Finished initializing SendCtl\n")); |
424 | 422 | ||
@@ -428,15 +426,13 @@ mpt_lan_open(struct net_device *dev) | |||
428 | goto out_SendCtl; | 426 | goto out_SendCtl; |
429 | priv->mpt_rxfidx_tail = -1; | 427 | priv->mpt_rxfidx_tail = -1; |
430 | 428 | ||
431 | priv->RcvCtl = kmalloc(priv->max_buckets_out * | 429 | priv->RcvCtl = kcalloc(priv->max_buckets_out, |
432 | sizeof(struct BufferControl), | 430 | sizeof(struct BufferControl), |
433 | GFP_KERNEL); | 431 | GFP_KERNEL); |
434 | if (priv->RcvCtl == NULL) | 432 | if (priv->RcvCtl == NULL) |
435 | goto out_mpt_rxfidx; | 433 | goto out_mpt_rxfidx; |
436 | for (i = 0; i < priv->max_buckets_out; i++) { | 434 | for (i = 0; i < priv->max_buckets_out; i++) |
437 | memset(&priv->RcvCtl[i], 0, sizeof(struct BufferControl)); | ||
438 | priv->mpt_rxfidx[++priv->mpt_rxfidx_tail] = i; | 435 | priv->mpt_rxfidx[++priv->mpt_rxfidx_tail] = i; |
439 | } | ||
440 | 436 | ||
441 | /**/ dlprintk((KERN_INFO MYNAM "/lo: txfidx contains - ")); | 437 | /**/ dlprintk((KERN_INFO MYNAM "/lo: txfidx contains - ")); |
442 | /**/ for (i = 0; i < priv->tx_max_out; i++) | 438 | /**/ for (i = 0; i < priv->tx_max_out; i++) |
diff --git a/drivers/message/fusion/mptsas.c b/drivers/message/fusion/mptsas.c index 19fc03ecdf60..668a101b89f0 100644 --- a/drivers/message/fusion/mptsas.c +++ b/drivers/message/fusion/mptsas.c | |||
@@ -258,13 +258,12 @@ mptsas_slave_alloc(struct scsi_device *sdev) | |||
258 | struct scsi_target *starget; | 258 | struct scsi_target *starget; |
259 | int i; | 259 | int i; |
260 | 260 | ||
261 | vdev = kmalloc(sizeof(VirtDevice), GFP_KERNEL); | 261 | vdev = kzalloc(sizeof(VirtDevice), GFP_KERNEL); |
262 | if (!vdev) { | 262 | if (!vdev) { |
263 | printk(MYIOC_s_ERR_FMT "slave_alloc kmalloc(%zd) FAILED!\n", | 263 | printk(MYIOC_s_ERR_FMT "slave_alloc kmalloc(%zd) FAILED!\n", |
264 | hd->ioc->name, sizeof(VirtDevice)); | 264 | hd->ioc->name, sizeof(VirtDevice)); |
265 | return -ENOMEM; | 265 | return -ENOMEM; |
266 | } | 266 | } |
267 | memset(vdev, 0, sizeof(VirtDevice)); | ||
268 | vdev->ioc_id = hd->ioc->id; | 267 | vdev->ioc_id = hd->ioc->id; |
269 | sdev->hostdata = vdev; | 268 | sdev->hostdata = vdev; |
270 | starget = scsi_target(sdev); | 269 | starget = scsi_target(sdev); |
@@ -1044,10 +1043,9 @@ mptsas_probe_hba_phys(MPT_ADAPTER *ioc, int *index) | |||
1044 | u32 handle = 0xFFFF; | 1043 | u32 handle = 0xFFFF; |
1045 | int error = -ENOMEM, i; | 1044 | int error = -ENOMEM, i; |
1046 | 1045 | ||
1047 | port_info = kmalloc(sizeof(*port_info), GFP_KERNEL); | 1046 | port_info = kzalloc(sizeof(*port_info), GFP_KERNEL); |
1048 | if (!port_info) | 1047 | if (!port_info) |
1049 | goto out; | 1048 | goto out; |
1050 | memset(port_info, 0, sizeof(*port_info)); | ||
1051 | 1049 | ||
1052 | error = mptsas_sas_io_unit_pg0(ioc, port_info); | 1050 | error = mptsas_sas_io_unit_pg0(ioc, port_info); |
1053 | if (error) | 1051 | if (error) |
@@ -1096,10 +1094,9 @@ mptsas_probe_expander_phys(MPT_ADAPTER *ioc, u32 *handle, int *index) | |||
1096 | struct mptsas_portinfo *port_info, *p; | 1094 | struct mptsas_portinfo *port_info, *p; |
1097 | int error = -ENOMEM, i, j; | 1095 | int error = -ENOMEM, i, j; |
1098 | 1096 | ||
1099 | port_info = kmalloc(sizeof(*port_info), GFP_KERNEL); | 1097 | port_info = kzalloc(sizeof(*port_info), GFP_KERNEL); |
1100 | if (!port_info) | 1098 | if (!port_info) |
1101 | goto out; | 1099 | goto out; |
1102 | memset(port_info, 0, sizeof(*port_info)); | ||
1103 | 1100 | ||
1104 | error = mptsas_sas_expander_pg0(ioc, port_info, | 1101 | error = mptsas_sas_expander_pg0(ioc, port_info, |
1105 | (MPI_SAS_EXPAND_PGAD_FORM_GET_NEXT_HANDLE << | 1102 | (MPI_SAS_EXPAND_PGAD_FORM_GET_NEXT_HANDLE << |
@@ -1390,11 +1387,10 @@ mptsas_probe(struct pci_dev *pdev, const struct pci_device_id *id) | |||
1390 | MPT_SCSI_HOST *hd; | 1387 | MPT_SCSI_HOST *hd; |
1391 | MPT_ADAPTER *ioc; | 1388 | MPT_ADAPTER *ioc; |
1392 | unsigned long flags; | 1389 | unsigned long flags; |
1393 | int sz, ii; | 1390 | int ii; |
1394 | int numSGE = 0; | 1391 | int numSGE = 0; |
1395 | int scale; | 1392 | int scale; |
1396 | int ioc_cap; | 1393 | int ioc_cap; |
1397 | u8 *mem; | ||
1398 | int error=0; | 1394 | int error=0; |
1399 | int r; | 1395 | int r; |
1400 | 1396 | ||
@@ -1518,36 +1514,27 @@ mptsas_probe(struct pci_dev *pdev, const struct pci_device_id *id) | |||
1518 | /* SCSI needs scsi_cmnd lookup table! | 1514 | /* SCSI needs scsi_cmnd lookup table! |
1519 | * (with size equal to req_depth*PtrSz!) | 1515 | * (with size equal to req_depth*PtrSz!) |
1520 | */ | 1516 | */ |
1521 | sz = ioc->req_depth * sizeof(void *); | 1517 | hd->ScsiLookup = kcalloc(ioc->req_depth, sizeof(void *), GFP_ATOMIC); |
1522 | mem = kmalloc(sz, GFP_ATOMIC); | 1518 | if (!hd->ScsiLookup) { |
1523 | if (mem == NULL) { | ||
1524 | error = -ENOMEM; | 1519 | error = -ENOMEM; |
1525 | goto out_mptsas_probe; | 1520 | goto out_mptsas_probe; |
1526 | } | 1521 | } |
1527 | 1522 | ||
1528 | memset(mem, 0, sz); | 1523 | dprintk((MYIOC_s_INFO_FMT "ScsiLookup @ %p\n", |
1529 | hd->ScsiLookup = (struct scsi_cmnd **) mem; | 1524 | ioc->name, hd->ScsiLookup)); |
1530 | |||
1531 | dprintk((MYIOC_s_INFO_FMT "ScsiLookup @ %p, sz=%d\n", | ||
1532 | ioc->name, hd->ScsiLookup, sz)); | ||
1533 | 1525 | ||
1534 | /* Allocate memory for the device structures. | 1526 | /* Allocate memory for the device structures. |
1535 | * A non-Null pointer at an offset | 1527 | * A non-Null pointer at an offset |
1536 | * indicates a device exists. | 1528 | * indicates a device exists. |
1537 | * max_id = 1 + maximum id (hosts.h) | 1529 | * max_id = 1 + maximum id (hosts.h) |
1538 | */ | 1530 | */ |
1539 | sz = sh->max_id * sizeof(void *); | 1531 | hd->Targets = kcalloc(sh->max_id, sizeof(void *), GFP_ATOMIC); |
1540 | mem = kmalloc(sz, GFP_ATOMIC); | 1532 | if (!hd->Targets) { |
1541 | if (mem == NULL) { | ||
1542 | error = -ENOMEM; | 1533 | error = -ENOMEM; |
1543 | goto out_mptsas_probe; | 1534 | goto out_mptsas_probe; |
1544 | } | 1535 | } |
1545 | 1536 | ||
1546 | memset(mem, 0, sz); | 1537 | dprintk((KERN_INFO " vtarget @ %p\n", hd->Targets)); |
1547 | hd->Targets = (VirtTarget **) mem; | ||
1548 | |||
1549 | dprintk((KERN_INFO | ||
1550 | " vtarget @ %p, sz=%d\n", hd->Targets, sz)); | ||
1551 | 1538 | ||
1552 | /* Clear the TM flags | 1539 | /* Clear the TM flags |
1553 | */ | 1540 | */ |
diff --git a/drivers/message/fusion/mptscsih.c b/drivers/message/fusion/mptscsih.c index 93a16fa3c4ba..525d9aea2012 100644 --- a/drivers/message/fusion/mptscsih.c +++ b/drivers/message/fusion/mptscsih.c | |||
@@ -2162,10 +2162,9 @@ mptscsih_target_alloc(struct scsi_target *starget) | |||
2162 | { | 2162 | { |
2163 | VirtTarget *vtarget; | 2163 | VirtTarget *vtarget; |
2164 | 2164 | ||
2165 | vtarget = kmalloc(sizeof(VirtTarget), GFP_KERNEL); | 2165 | vtarget = kzalloc(sizeof(VirtTarget), GFP_KERNEL); |
2166 | if (!vtarget) | 2166 | if (!vtarget) |
2167 | return -ENOMEM; | 2167 | return -ENOMEM; |
2168 | memset(vtarget, 0, sizeof(VirtTarget)); | ||
2169 | starget->hostdata = vtarget; | 2168 | starget->hostdata = vtarget; |
2170 | return 0; | 2169 | return 0; |
2171 | } | 2170 | } |
@@ -2185,14 +2184,13 @@ mptscsih_slave_alloc(struct scsi_device *sdev) | |||
2185 | VirtDevice *vdev; | 2184 | VirtDevice *vdev; |
2186 | struct scsi_target *starget; | 2185 | struct scsi_target *starget; |
2187 | 2186 | ||
2188 | vdev = kmalloc(sizeof(VirtDevice), GFP_KERNEL); | 2187 | vdev = kzalloc(sizeof(VirtDevice), GFP_KERNEL); |
2189 | if (!vdev) { | 2188 | if (!vdev) { |
2190 | printk(MYIOC_s_ERR_FMT "slave_alloc kmalloc(%zd) FAILED!\n", | 2189 | printk(MYIOC_s_ERR_FMT "slave_alloc kmalloc(%zd) FAILED!\n", |
2191 | hd->ioc->name, sizeof(VirtDevice)); | 2190 | hd->ioc->name, sizeof(VirtDevice)); |
2192 | return -ENOMEM; | 2191 | return -ENOMEM; |
2193 | } | 2192 | } |
2194 | 2193 | ||
2195 | memset(vdev, 0, sizeof(VirtDevice)); | ||
2196 | vdev->ioc_id = hd->ioc->id; | 2194 | vdev->ioc_id = hd->ioc->id; |
2197 | vdev->target_id = sdev->id; | 2195 | vdev->target_id = sdev->id; |
2198 | vdev->bus_id = sdev->channel; | 2196 | vdev->bus_id = sdev->channel; |
diff --git a/drivers/message/fusion/mptspi.c b/drivers/message/fusion/mptspi.c index ce332a6085e5..7dce29277cb7 100644 --- a/drivers/message/fusion/mptspi.c +++ b/drivers/message/fusion/mptspi.c | |||
@@ -158,11 +158,10 @@ mptspi_probe(struct pci_dev *pdev, const struct pci_device_id *id) | |||
158 | MPT_SCSI_HOST *hd; | 158 | MPT_SCSI_HOST *hd; |
159 | MPT_ADAPTER *ioc; | 159 | MPT_ADAPTER *ioc; |
160 | unsigned long flags; | 160 | unsigned long flags; |
161 | int sz, ii; | 161 | int ii; |
162 | int numSGE = 0; | 162 | int numSGE = 0; |
163 | int scale; | 163 | int scale; |
164 | int ioc_cap; | 164 | int ioc_cap; |
165 | u8 *mem; | ||
166 | int error=0; | 165 | int error=0; |
167 | int r; | 166 | int r; |
168 | 167 | ||
@@ -288,36 +287,27 @@ mptspi_probe(struct pci_dev *pdev, const struct pci_device_id *id) | |||
288 | /* SCSI needs scsi_cmnd lookup table! | 287 | /* SCSI needs scsi_cmnd lookup table! |
289 | * (with size equal to req_depth*PtrSz!) | 288 | * (with size equal to req_depth*PtrSz!) |
290 | */ | 289 | */ |
291 | sz = ioc->req_depth * sizeof(void *); | 290 | hd->ScsiLookup = kcalloc(ioc->req_depth, sizeof(void *), GFP_ATOMIC); |
292 | mem = kmalloc(sz, GFP_ATOMIC); | 291 | if (!hd->ScsiLookup) { |
293 | if (mem == NULL) { | ||
294 | error = -ENOMEM; | 292 | error = -ENOMEM; |
295 | goto out_mptspi_probe; | 293 | goto out_mptspi_probe; |
296 | } | 294 | } |
297 | 295 | ||
298 | memset(mem, 0, sz); | 296 | dprintk((MYIOC_s_INFO_FMT "ScsiLookup @ %p\n", |
299 | hd->ScsiLookup = (struct scsi_cmnd **) mem; | 297 | ioc->name, hd->ScsiLookup)); |
300 | |||
301 | dprintk((MYIOC_s_INFO_FMT "ScsiLookup @ %p, sz=%d\n", | ||
302 | ioc->name, hd->ScsiLookup, sz)); | ||
303 | 298 | ||
304 | /* Allocate memory for the device structures. | 299 | /* Allocate memory for the device structures. |
305 | * A non-Null pointer at an offset | 300 | * A non-Null pointer at an offset |
306 | * indicates a device exists. | 301 | * indicates a device exists. |
307 | * max_id = 1 + maximum id (hosts.h) | 302 | * max_id = 1 + maximum id (hosts.h) |
308 | */ | 303 | */ |
309 | sz = sh->max_id * sizeof(void *); | 304 | hd->Targets = kcalloc(sh->max_id, sizeof(void *), GFP_ATOMIC); |
310 | mem = kmalloc(sz, GFP_ATOMIC); | 305 | if (!hd->Targets) { |
311 | if (mem == NULL) { | ||
312 | error = -ENOMEM; | 306 | error = -ENOMEM; |
313 | goto out_mptspi_probe; | 307 | goto out_mptspi_probe; |
314 | } | 308 | } |
315 | 309 | ||
316 | memset(mem, 0, sz); | 310 | dprintk((KERN_INFO " vdev @ %p\n", hd->Targets)); |
317 | hd->Targets = (VirtTarget **) mem; | ||
318 | |||
319 | dprintk((KERN_INFO | ||
320 | " vdev @ %p, sz=%d\n", hd->Targets, sz)); | ||
321 | 311 | ||
322 | /* Clear the TM flags | 312 | /* Clear the TM flags |
323 | */ | 313 | */ |