diff options
author | Stefan Richter <stefanr@s5r6.in-berlin.de> | 2005-11-07 06:31:45 -0500 |
---|---|---|
committer | Jody McIntyre <scjody@modernduck.com> | 2005-11-07 06:31:45 -0500 |
commit | 8551158abc8ef45a7f473a87e69624d05ebfd684 (patch) | |
tree | 47cd79c5f5444c7cac812d797764f203207345a7 /drivers/ieee1394/raw1394.c | |
parent | 7afa1467761f06bd9649efd66a4a6b3ff9f29a1f (diff) |
kmalloc/kzalloc changes:
dv1394, eth1394, ieee1394, ohci1394, pcilynx, raw1394, sbp2c, video1394:
- use kzalloc
- provide safer size arguments to kmalloc and kzalloc
- omit some casts
Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
Signed-off-by: Jody McIntyre <scjody@modernduck.com>
Diffstat (limited to 'drivers/ieee1394/raw1394.c')
-rw-r--r-- | drivers/ieee1394/raw1394.c | 38 |
1 files changed, 16 insertions, 22 deletions
diff --git a/drivers/ieee1394/raw1394.c b/drivers/ieee1394/raw1394.c index 24411e666b21..0278dc5d5ef9 100644 --- a/drivers/ieee1394/raw1394.c +++ b/drivers/ieee1394/raw1394.c | |||
@@ -102,12 +102,9 @@ static struct pending_request *__alloc_pending_request(gfp_t flags) | |||
102 | { | 102 | { |
103 | struct pending_request *req; | 103 | struct pending_request *req; |
104 | 104 | ||
105 | req = (struct pending_request *)kmalloc(sizeof(struct pending_request), | 105 | req = kzalloc(sizeof(*req), flags); |
106 | flags); | 106 | if (req) |
107 | if (req != NULL) { | ||
108 | memset(req, 0, sizeof(struct pending_request)); | ||
109 | INIT_LIST_HEAD(&req->list); | 107 | INIT_LIST_HEAD(&req->list); |
110 | } | ||
111 | 108 | ||
112 | return req; | 109 | return req; |
113 | } | 110 | } |
@@ -192,9 +189,9 @@ static void add_host(struct hpsb_host *host) | |||
192 | struct host_info *hi; | 189 | struct host_info *hi; |
193 | unsigned long flags; | 190 | unsigned long flags; |
194 | 191 | ||
195 | hi = (struct host_info *)kmalloc(sizeof(struct host_info), GFP_KERNEL); | 192 | hi = kmalloc(sizeof(*hi), GFP_KERNEL); |
196 | 193 | ||
197 | if (hi != NULL) { | 194 | if (hi) { |
198 | INIT_LIST_HEAD(&hi->list); | 195 | INIT_LIST_HEAD(&hi->list); |
199 | hi->host = host; | 196 | hi->host = host; |
200 | INIT_LIST_HEAD(&hi->file_info_list); | 197 | INIT_LIST_HEAD(&hi->file_info_list); |
@@ -315,8 +312,8 @@ static void iso_receive(struct hpsb_host *host, int channel, quadlet_t * data, | |||
315 | break; | 312 | break; |
316 | 313 | ||
317 | if (!ibs) { | 314 | if (!ibs) { |
318 | ibs = kmalloc(sizeof(struct iso_block_store) | 315 | ibs = kmalloc(sizeof(*ibs) + length, |
319 | + length, SLAB_ATOMIC); | 316 | SLAB_ATOMIC); |
320 | if (!ibs) { | 317 | if (!ibs) { |
321 | kfree(req); | 318 | kfree(req); |
322 | break; | 319 | break; |
@@ -376,8 +373,8 @@ static void fcp_request(struct hpsb_host *host, int nodeid, int direction, | |||
376 | break; | 373 | break; |
377 | 374 | ||
378 | if (!ibs) { | 375 | if (!ibs) { |
379 | ibs = kmalloc(sizeof(struct iso_block_store) | 376 | ibs = kmalloc(sizeof(*ibs) + length, |
380 | + length, SLAB_ATOMIC); | 377 | SLAB_ATOMIC); |
381 | if (!ibs) { | 378 | if (!ibs) { |
382 | kfree(req); | 379 | kfree(req); |
383 | break; | 380 | break; |
@@ -502,10 +499,9 @@ static int state_initialized(struct file_info *fi, struct pending_request *req) | |||
502 | switch (req->req.type) { | 499 | switch (req->req.type) { |
503 | case RAW1394_REQ_LIST_CARDS: | 500 | case RAW1394_REQ_LIST_CARDS: |
504 | spin_lock_irqsave(&host_info_lock, flags); | 501 | spin_lock_irqsave(&host_info_lock, flags); |
505 | khl = kmalloc(sizeof(struct raw1394_khost_list) * host_count, | 502 | khl = kmalloc(sizeof(*khl) * host_count, SLAB_ATOMIC); |
506 | SLAB_ATOMIC); | ||
507 | 503 | ||
508 | if (khl != NULL) { | 504 | if (khl) { |
509 | req->req.misc = host_count; | 505 | req->req.misc = host_count; |
510 | req->data = (quadlet_t *) khl; | 506 | req->data = (quadlet_t *) khl; |
511 | 507 | ||
@@ -517,7 +513,7 @@ static int state_initialized(struct file_info *fi, struct pending_request *req) | |||
517 | } | 513 | } |
518 | spin_unlock_irqrestore(&host_info_lock, flags); | 514 | spin_unlock_irqrestore(&host_info_lock, flags); |
519 | 515 | ||
520 | if (khl != NULL) { | 516 | if (khl) { |
521 | req->req.error = RAW1394_ERROR_NONE; | 517 | req->req.error = RAW1394_ERROR_NONE; |
522 | req->req.length = min(req->req.length, | 518 | req->req.length = min(req->req.length, |
523 | (u32) (sizeof | 519 | (u32) (sizeof |
@@ -1647,13 +1643,13 @@ static int arm_register(struct file_info *fi, struct pending_request *req) | |||
1647 | return (-EINVAL); | 1643 | return (-EINVAL); |
1648 | } | 1644 | } |
1649 | /* addr-list-entry for fileinfo */ | 1645 | /* addr-list-entry for fileinfo */ |
1650 | addr = (struct arm_addr *)kmalloc(sizeof(struct arm_addr), SLAB_KERNEL); | 1646 | addr = kmalloc(sizeof(*addr), SLAB_KERNEL); |
1651 | if (!addr) { | 1647 | if (!addr) { |
1652 | req->req.length = 0; | 1648 | req->req.length = 0; |
1653 | return (-ENOMEM); | 1649 | return (-ENOMEM); |
1654 | } | 1650 | } |
1655 | /* allocation of addr_space_buffer */ | 1651 | /* allocation of addr_space_buffer */ |
1656 | addr->addr_space_buffer = (u8 *) vmalloc(req->req.length); | 1652 | addr->addr_space_buffer = vmalloc(req->req.length); |
1657 | if (!(addr->addr_space_buffer)) { | 1653 | if (!(addr->addr_space_buffer)) { |
1658 | kfree(addr); | 1654 | kfree(addr); |
1659 | req->req.length = 0; | 1655 | req->req.length = 0; |
@@ -2122,8 +2118,7 @@ static int modify_config_rom(struct file_info *fi, struct pending_request *req) | |||
2122 | return -ENOMEM; | 2118 | return -ENOMEM; |
2123 | } | 2119 | } |
2124 | 2120 | ||
2125 | cache->filled_head = | 2121 | cache->filled_head = kmalloc(sizeof(*cache->filled_head), GFP_KERNEL); |
2126 | kmalloc(sizeof(struct csr1212_cache_region), GFP_KERNEL); | ||
2127 | if (!cache->filled_head) { | 2122 | if (!cache->filled_head) { |
2128 | csr1212_release_keyval(fi->csr1212_dirs[dr]); | 2123 | csr1212_release_keyval(fi->csr1212_dirs[dr]); |
2129 | fi->csr1212_dirs[dr] = NULL; | 2124 | fi->csr1212_dirs[dr] = NULL; |
@@ -2684,11 +2679,10 @@ static int raw1394_open(struct inode *inode, struct file *file) | |||
2684 | { | 2679 | { |
2685 | struct file_info *fi; | 2680 | struct file_info *fi; |
2686 | 2681 | ||
2687 | fi = kmalloc(sizeof(struct file_info), SLAB_KERNEL); | 2682 | fi = kzalloc(sizeof(*fi), SLAB_KERNEL); |
2688 | if (fi == NULL) | 2683 | if (!fi) |
2689 | return -ENOMEM; | 2684 | return -ENOMEM; |
2690 | 2685 | ||
2691 | memset(fi, 0, sizeof(struct file_info)); | ||
2692 | fi->notification = (u8) RAW1394_NOTIFY_ON; /* busreset notification */ | 2686 | fi->notification = (u8) RAW1394_NOTIFY_ON; /* busreset notification */ |
2693 | 2687 | ||
2694 | INIT_LIST_HEAD(&fi->list); | 2688 | INIT_LIST_HEAD(&fi->list); |