aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char
diff options
context:
space:
mode:
authorDave Jones <davej@redhat.com>2005-10-20 18:12:16 -0400
committerDave Jones <davej@redhat.com>2005-10-20 18:12:16 -0400
commit0ea27d9f2fb5b998063323bff47ab87891ced9e2 (patch)
tree1776e5eb03fb87184fc0e423da12acf5eb0540b7 /drivers/char
parent0ff541dafdcb9bc8933e7e4881e5924a408b5335 (diff)
[AGPGART] Replace kmalloc+memset's with kzalloc's
Signed-off-by: Dave Jones <davej@redhat.com>
Diffstat (limited to 'drivers/char')
-rw-r--r--drivers/char/agp/amd-k7-agp.c7
-rw-r--r--drivers/char/agp/ati-agp.c7
-rw-r--r--drivers/char/agp/backend.c6
-rw-r--r--drivers/char/agp/frontend.c15
-rw-r--r--drivers/char/agp/generic.c4
-rw-r--r--drivers/char/agp/i460-agp.c6
-rw-r--r--drivers/char/agp/sworks-agp.c10
7 files changed, 18 insertions, 37 deletions
diff --git a/drivers/char/agp/amd-k7-agp.c b/drivers/char/agp/amd-k7-agp.c
index 3a41672e4d66..1f776651ac64 100644
--- a/drivers/char/agp/amd-k7-agp.c
+++ b/drivers/char/agp/amd-k7-agp.c
@@ -94,19 +94,16 @@ static int amd_create_gatt_pages(int nr_tables)
94 int retval = 0; 94 int retval = 0;
95 int i; 95 int i;
96 96
97 tables = kmalloc((nr_tables + 1) * sizeof(struct amd_page_map *), 97 tables = kzalloc((nr_tables + 1) * sizeof(struct amd_page_map *),GFP_KERNEL);
98 GFP_KERNEL);
99 if (tables == NULL) 98 if (tables == NULL)
100 return -ENOMEM; 99 return -ENOMEM;
101 100
102 memset (tables, 0, sizeof(struct amd_page_map *) * (nr_tables + 1));
103 for (i = 0; i < nr_tables; i++) { 101 for (i = 0; i < nr_tables; i++) {
104 entry = kmalloc(sizeof(struct amd_page_map), GFP_KERNEL); 102 entry = kzalloc(sizeof(struct amd_page_map), GFP_KERNEL);
105 if (entry == NULL) { 103 if (entry == NULL) {
106 retval = -ENOMEM; 104 retval = -ENOMEM;
107 break; 105 break;
108 } 106 }
109 memset (entry, 0, sizeof(struct amd_page_map));
110 tables[i] = entry; 107 tables[i] = entry;
111 retval = amd_create_page_map(entry); 108 retval = amd_create_page_map(entry);
112 if (retval != 0) 109 if (retval != 0)
diff --git a/drivers/char/agp/ati-agp.c b/drivers/char/agp/ati-agp.c
index e572ced9100a..109582ab3704 100644
--- a/drivers/char/agp/ati-agp.c
+++ b/drivers/char/agp/ati-agp.c
@@ -116,14 +116,12 @@ static int ati_create_gatt_pages(int nr_tables)
116 int retval = 0; 116 int retval = 0;
117 int i; 117 int i;
118 118
119 tables = kmalloc((nr_tables + 1) * sizeof(ati_page_map *), 119 tables = kzalloc((nr_tables + 1) * sizeof(ati_page_map *),GFP_KERNEL);
120 GFP_KERNEL);
121 if (tables == NULL) 120 if (tables == NULL)
122 return -ENOMEM; 121 return -ENOMEM;
123 122
124 memset(tables, 0, sizeof(ati_page_map *) * (nr_tables + 1));
125 for (i = 0; i < nr_tables; i++) { 123 for (i = 0; i < nr_tables; i++) {
126 entry = kmalloc(sizeof(ati_page_map), GFP_KERNEL); 124 entry = kzalloc(sizeof(ati_page_map), GFP_KERNEL);
127 if (entry == NULL) { 125 if (entry == NULL) {
128 while (i>0) { 126 while (i>0) {
129 kfree (tables[i-1]); 127 kfree (tables[i-1]);
@@ -134,7 +132,6 @@ static int ati_create_gatt_pages(int nr_tables)
134 retval = -ENOMEM; 132 retval = -ENOMEM;
135 break; 133 break;
136 } 134 }
137 memset(entry, 0, sizeof(ati_page_map));
138 tables[i] = entry; 135 tables[i] = entry;
139 retval = ati_create_page_map(entry); 136 retval = ati_create_page_map(entry);
140 if (retval != 0) break; 137 if (retval != 0) break;
diff --git a/drivers/char/agp/backend.c b/drivers/char/agp/backend.c
index 82b43c541c8d..73f333f491bd 100644
--- a/drivers/char/agp/backend.c
+++ b/drivers/char/agp/backend.c
@@ -222,12 +222,12 @@ static void agp_backend_cleanup(struct agp_bridge_data *bridge)
222 222
223struct agp_bridge_data *agp_alloc_bridge(void) 223struct agp_bridge_data *agp_alloc_bridge(void)
224{ 224{
225 struct agp_bridge_data *bridge = kmalloc(sizeof(*bridge), GFP_KERNEL); 225 struct agp_bridge_data *bridge;
226 226
227 bridge = kzalloc(sizeof(*bridge), GFP_KERNEL);
227 if (!bridge) 228 if (!bridge)
228 return NULL; 229 return NULL;
229 230
230 memset(bridge, 0, sizeof(*bridge));
231 atomic_set(&bridge->agp_in_use, 0); 231 atomic_set(&bridge->agp_in_use, 0);
232 atomic_set(&bridge->current_memory_agp, 0); 232 atomic_set(&bridge->current_memory_agp, 0);
233 233
diff --git a/drivers/char/agp/frontend.c b/drivers/char/agp/frontend.c
index 3dfb6648547b..17f520c9d471 100644
--- a/drivers/char/agp/frontend.c
+++ b/drivers/char/agp/frontend.c
@@ -189,13 +189,12 @@ static int agp_create_segment(struct agp_client *client, struct agp_region *regi
189 struct agp_segment *user_seg; 189 struct agp_segment *user_seg;
190 size_t i; 190 size_t i;
191 191
192 seg = kmalloc((sizeof(struct agp_segment_priv) * region->seg_count), GFP_KERNEL); 192 seg = kzalloc((sizeof(struct agp_segment_priv) * region->seg_count), GFP_KERNEL);
193 if (seg == NULL) { 193 if (seg == NULL) {
194 kfree(region->seg_list); 194 kfree(region->seg_list);
195 region->seg_list = NULL; 195 region->seg_list = NULL;
196 return -ENOMEM; 196 return -ENOMEM;
197 } 197 }
198 memset(seg, 0, (sizeof(struct agp_segment_priv) * region->seg_count));
199 user_seg = region->seg_list; 198 user_seg = region->seg_list;
200 199
201 for (i = 0; i < region->seg_count; i++) { 200 for (i = 0; i < region->seg_count; i++) {
@@ -332,14 +331,11 @@ static struct agp_controller *agp_create_controller(pid_t id)
332{ 331{
333 struct agp_controller *controller; 332 struct agp_controller *controller;
334 333
335 controller = kmalloc(sizeof(struct agp_controller), GFP_KERNEL); 334 controller = kzalloc(sizeof(struct agp_controller), GFP_KERNEL);
336
337 if (controller == NULL) 335 if (controller == NULL)
338 return NULL; 336 return NULL;
339 337
340 memset(controller, 0, sizeof(struct agp_controller));
341 controller->pid = id; 338 controller->pid = id;
342
343 return controller; 339 return controller;
344} 340}
345 341
@@ -540,12 +536,10 @@ static struct agp_client *agp_create_client(pid_t id)
540{ 536{
541 struct agp_client *new_client; 537 struct agp_client *new_client;
542 538
543 new_client = kmalloc(sizeof(struct agp_client), GFP_KERNEL); 539 new_client = kzalloc(sizeof(struct agp_client), GFP_KERNEL);
544
545 if (new_client == NULL) 540 if (new_client == NULL)
546 return NULL; 541 return NULL;
547 542
548 memset(new_client, 0, sizeof(struct agp_client));
549 new_client->pid = id; 543 new_client->pid = id;
550 agp_insert_client(new_client); 544 agp_insert_client(new_client);
551 return new_client; 545 return new_client;
@@ -709,11 +703,10 @@ static int agp_open(struct inode *inode, struct file *file)
709 if (minor != AGPGART_MINOR) 703 if (minor != AGPGART_MINOR)
710 goto err_out; 704 goto err_out;
711 705
712 priv = kmalloc(sizeof(struct agp_file_private), GFP_KERNEL); 706 priv = kzalloc(sizeof(struct agp_file_private), GFP_KERNEL);
713 if (priv == NULL) 707 if (priv == NULL)
714 goto err_out_nomem; 708 goto err_out_nomem;
715 709
716 memset(priv, 0, sizeof(struct agp_file_private));
717 set_bit(AGP_FF_ALLOW_CLIENT, &priv->access_flags); 710 set_bit(AGP_FF_ALLOW_CLIENT, &priv->access_flags);
718 priv->my_pid = current->pid; 711 priv->my_pid = current->pid;
719 712
diff --git a/drivers/char/agp/generic.c b/drivers/char/agp/generic.c
index ac9da0ca36b7..b0f2a6faf676 100644
--- a/drivers/char/agp/generic.c
+++ b/drivers/char/agp/generic.c
@@ -105,12 +105,10 @@ struct agp_memory *agp_create_memory(int scratch_pages)
105{ 105{
106 struct agp_memory *new; 106 struct agp_memory *new;
107 107
108 new = kmalloc(sizeof(struct agp_memory), GFP_KERNEL); 108 new = kzalloc(sizeof(struct agp_memory), GFP_KERNEL);
109
110 if (new == NULL) 109 if (new == NULL)
111 return NULL; 110 return NULL;
112 111
113 memset(new, 0, sizeof(struct agp_memory));
114 new->key = agp_get_key(); 112 new->key = agp_get_key();
115 113
116 if (new->key < 0) { 114 if (new->key < 0) {
diff --git a/drivers/char/agp/i460-agp.c b/drivers/char/agp/i460-agp.c
index 94943298c03e..75acb960558f 100644
--- a/drivers/char/agp/i460-agp.c
+++ b/drivers/char/agp/i460-agp.c
@@ -225,10 +225,9 @@ static int i460_configure (void)
225 */ 225 */
226 if (I460_IO_PAGE_SHIFT > PAGE_SHIFT) { 226 if (I460_IO_PAGE_SHIFT > PAGE_SHIFT) {
227 size = current_size->num_entries * sizeof(i460.lp_desc[0]); 227 size = current_size->num_entries * sizeof(i460.lp_desc[0]);
228 i460.lp_desc = kmalloc(size, GFP_KERNEL); 228 i460.lp_desc = kzalloc(size, GFP_KERNEL);
229 if (!i460.lp_desc) 229 if (!i460.lp_desc)
230 return -ENOMEM; 230 return -ENOMEM;
231 memset(i460.lp_desc, 0, size);
232 } 231 }
233 return 0; 232 return 0;
234} 233}
@@ -364,13 +363,12 @@ static int i460_alloc_large_page (struct lp_desc *lp)
364 } 363 }
365 364
366 map_size = ((I460_KPAGES_PER_IOPAGE + BITS_PER_LONG - 1) & -BITS_PER_LONG)/8; 365 map_size = ((I460_KPAGES_PER_IOPAGE + BITS_PER_LONG - 1) & -BITS_PER_LONG)/8;
367 lp->alloced_map = kmalloc(map_size, GFP_KERNEL); 366 lp->alloced_map = kzalloc(map_size, GFP_KERNEL);
368 if (!lp->alloced_map) { 367 if (!lp->alloced_map) {
369 free_pages((unsigned long) lpage, order); 368 free_pages((unsigned long) lpage, order);
370 printk(KERN_ERR PFX "Out of memory, we're in trouble...\n"); 369 printk(KERN_ERR PFX "Out of memory, we're in trouble...\n");
371 return -ENOMEM; 370 return -ENOMEM;
372 } 371 }
373 memset(lp->alloced_map, 0, map_size);
374 372
375 lp->paddr = virt_to_gart(lpage); 373 lp->paddr = virt_to_gart(lpage);
376 lp->refcount = 0; 374 lp->refcount = 0;
diff --git a/drivers/char/agp/sworks-agp.c b/drivers/char/agp/sworks-agp.c
index 53968973f890..161d22b67fa3 100644
--- a/drivers/char/agp/sworks-agp.c
+++ b/drivers/char/agp/sworks-agp.c
@@ -100,19 +100,17 @@ static int serverworks_create_gatt_pages(int nr_tables)
100 int retval = 0; 100 int retval = 0;
101 int i; 101 int i;
102 102
103 tables = kmalloc((nr_tables + 1) * sizeof(struct serverworks_page_map *), 103 tables = kzalloc((nr_tables + 1) * sizeof(struct serverworks_page_map *),
104 GFP_KERNEL); 104 GFP_KERNEL);
105 if (tables == NULL) { 105 if (tables == NULL)
106 return -ENOMEM; 106 return -ENOMEM;
107 } 107
108 memset(tables, 0, sizeof(struct serverworks_page_map *) * (nr_tables + 1));
109 for (i = 0; i < nr_tables; i++) { 108 for (i = 0; i < nr_tables; i++) {
110 entry = kmalloc(sizeof(struct serverworks_page_map), GFP_KERNEL); 109 entry = kzalloc(sizeof(struct serverworks_page_map), GFP_KERNEL);
111 if (entry == NULL) { 110 if (entry == NULL) {
112 retval = -ENOMEM; 111 retval = -ENOMEM;
113 break; 112 break;
114 } 113 }
115 memset(entry, 0, sizeof(struct serverworks_page_map));
116 tables[i] = entry; 114 tables[i] = entry;
117 retval = serverworks_create_page_map(entry); 115 retval = serverworks_create_page_map(entry);
118 if (retval != 0) break; 116 if (retval != 0) break;