aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ieee1394/raw1394.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/ieee1394/raw1394.c')
-rw-r--r--drivers/ieee1394/raw1394.c79
1 files changed, 37 insertions, 42 deletions
diff --git a/drivers/ieee1394/raw1394.c b/drivers/ieee1394/raw1394.c
index 24411e666b21..b05235639918 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;
@@ -2136,7 +2131,6 @@ static int modify_config_rom(struct file_info *fi, struct pending_request *req)
2136 req->req.length)) { 2131 req->req.length)) {
2137 csr1212_release_keyval(fi->csr1212_dirs[dr]); 2132 csr1212_release_keyval(fi->csr1212_dirs[dr]);
2138 fi->csr1212_dirs[dr] = NULL; 2133 fi->csr1212_dirs[dr] = NULL;
2139 CSR1212_FREE(cache);
2140 ret = -EFAULT; 2134 ret = -EFAULT;
2141 } else { 2135 } else {
2142 cache->len = req->req.length; 2136 cache->len = req->req.length;
@@ -2172,7 +2166,7 @@ static int modify_config_rom(struct file_info *fi, struct pending_request *req)
2172 } 2166 }
2173 } 2167 }
2174 kfree(cache->filled_head); 2168 kfree(cache->filled_head);
2175 kfree(cache); 2169 CSR1212_FREE(cache);
2176 2170
2177 if (ret >= 0) { 2171 if (ret >= 0) {
2178 /* we have to free the request, because we queue no response, 2172 /* we have to free the request, because we queue no response,
@@ -2488,8 +2482,8 @@ static int raw1394_iso_recv_packets(struct file_info *fi, void __user * uaddr)
2488 2482
2489 /* ensure user-supplied buffer is accessible and big enough */ 2483 /* ensure user-supplied buffer is accessible and big enough */
2490 if (!access_ok(VERIFY_WRITE, upackets.infos, 2484 if (!access_ok(VERIFY_WRITE, upackets.infos,
2491 upackets.n_packets * 2485 upackets.n_packets *
2492 sizeof(struct raw1394_iso_packet_info))) 2486 sizeof(struct raw1394_iso_packet_info)))
2493 return -EFAULT; 2487 return -EFAULT;
2494 2488
2495 /* copy the packet_infos out */ 2489 /* copy the packet_infos out */
@@ -2522,8 +2516,8 @@ static int raw1394_iso_send_packets(struct file_info *fi, void __user * uaddr)
2522 2516
2523 /* ensure user-supplied buffer is accessible and big enough */ 2517 /* ensure user-supplied buffer is accessible and big enough */
2524 if (!access_ok(VERIFY_READ, upackets.infos, 2518 if (!access_ok(VERIFY_READ, upackets.infos,
2525 upackets.n_packets * 2519 upackets.n_packets *
2526 sizeof(struct raw1394_iso_packet_info))) 2520 sizeof(struct raw1394_iso_packet_info)))
2527 return -EFAULT; 2521 return -EFAULT;
2528 2522
2529 /* copy the infos structs in and queue the packets */ 2523 /* copy the infos structs in and queue the packets */
@@ -2684,11 +2678,10 @@ static int raw1394_open(struct inode *inode, struct file *file)
2684{ 2678{
2685 struct file_info *fi; 2679 struct file_info *fi;
2686 2680
2687 fi = kmalloc(sizeof(struct file_info), SLAB_KERNEL); 2681 fi = kzalloc(sizeof(*fi), SLAB_KERNEL);
2688 if (fi == NULL) 2682 if (!fi)
2689 return -ENOMEM; 2683 return -ENOMEM;
2690 2684
2691 memset(fi, 0, sizeof(struct file_info));
2692 fi->notification = (u8) RAW1394_NOTIFY_ON; /* busreset notification */ 2685 fi->notification = (u8) RAW1394_NOTIFY_ON; /* busreset notification */
2693 2686
2694 INIT_LIST_HEAD(&fi->list); 2687 INIT_LIST_HEAD(&fi->list);
@@ -2748,8 +2741,7 @@ static int raw1394_release(struct inode *inode, struct file *file)
2748 list) { 2741 list) {
2749 entry = fi_hlp->addr_list.next; 2742 entry = fi_hlp->addr_list.next;
2750 while (entry != &(fi_hlp->addr_list)) { 2743 while (entry != &(fi_hlp->addr_list)) {
2751 arm_addr = list_entry(entry, 2744 arm_addr = list_entry(entry, struct
2752 struct
2753 arm_addr, 2745 arm_addr,
2754 addr_list); 2746 addr_list);
2755 if (arm_addr->start == 2747 if (arm_addr->start ==
@@ -2912,16 +2904,17 @@ static int __init init_raw1394(void)
2912 2904
2913 hpsb_register_highlevel(&raw1394_highlevel); 2905 hpsb_register_highlevel(&raw1394_highlevel);
2914 2906
2915 if (IS_ERR(class_device_create(hpsb_protocol_class, NULL, MKDEV( 2907 if (IS_ERR
2916 IEEE1394_MAJOR, IEEE1394_MINOR_BLOCK_RAW1394 * 16), 2908 (class_device_create
2917 NULL, RAW1394_DEVICE_NAME))) { 2909 (hpsb_protocol_class, NULL,
2910 MKDEV(IEEE1394_MAJOR, IEEE1394_MINOR_BLOCK_RAW1394 * 16), NULL,
2911 RAW1394_DEVICE_NAME))) {
2918 ret = -EFAULT; 2912 ret = -EFAULT;
2919 goto out_unreg; 2913 goto out_unreg;
2920 } 2914 }
2921 2915
2922 devfs_mk_cdev(MKDEV( 2916 devfs_mk_cdev(MKDEV(IEEE1394_MAJOR, IEEE1394_MINOR_BLOCK_RAW1394 * 16),
2923 IEEE1394_MAJOR, IEEE1394_MINOR_BLOCK_RAW1394 * 16), 2917 S_IFCHR | S_IRUSR | S_IWUSR, RAW1394_DEVICE_NAME);
2924 S_IFCHR | S_IRUSR | S_IWUSR, RAW1394_DEVICE_NAME);
2925 2918
2926 cdev_init(&raw1394_cdev, &raw1394_fops); 2919 cdev_init(&raw1394_cdev, &raw1394_fops);
2927 raw1394_cdev.owner = THIS_MODULE; 2920 raw1394_cdev.owner = THIS_MODULE;
@@ -2943,20 +2936,22 @@ static int __init init_raw1394(void)
2943 2936
2944 goto out; 2937 goto out;
2945 2938
2946out_dev: 2939 out_dev:
2947 devfs_remove(RAW1394_DEVICE_NAME); 2940 devfs_remove(RAW1394_DEVICE_NAME);
2948 class_device_destroy(hpsb_protocol_class, 2941 class_device_destroy(hpsb_protocol_class,
2949 MKDEV(IEEE1394_MAJOR, IEEE1394_MINOR_BLOCK_RAW1394 * 16)); 2942 MKDEV(IEEE1394_MAJOR,
2950out_unreg: 2943 IEEE1394_MINOR_BLOCK_RAW1394 * 16));
2944 out_unreg:
2951 hpsb_unregister_highlevel(&raw1394_highlevel); 2945 hpsb_unregister_highlevel(&raw1394_highlevel);
2952out: 2946 out:
2953 return ret; 2947 return ret;
2954} 2948}
2955 2949
2956static void __exit cleanup_raw1394(void) 2950static void __exit cleanup_raw1394(void)
2957{ 2951{
2958 class_device_destroy(hpsb_protocol_class, 2952 class_device_destroy(hpsb_protocol_class,
2959 MKDEV(IEEE1394_MAJOR, IEEE1394_MINOR_BLOCK_RAW1394 * 16)); 2953 MKDEV(IEEE1394_MAJOR,
2954 IEEE1394_MINOR_BLOCK_RAW1394 * 16));
2960 cdev_del(&raw1394_cdev); 2955 cdev_del(&raw1394_cdev);
2961 devfs_remove(RAW1394_DEVICE_NAME); 2956 devfs_remove(RAW1394_DEVICE_NAME);
2962 hpsb_unregister_highlevel(&raw1394_highlevel); 2957 hpsb_unregister_highlevel(&raw1394_highlevel);