aboutsummaryrefslogtreecommitdiffstats
path: root/init/dyn_array.c
diff options
context:
space:
mode:
Diffstat (limited to 'init/dyn_array.c')
-rw-r--r--init/dyn_array.c120
1 files changed, 0 insertions, 120 deletions
diff --git a/init/dyn_array.c b/init/dyn_array.c
deleted file mode 100644
index c8d5e2a18588..000000000000
--- a/init/dyn_array.c
+++ /dev/null
@@ -1,120 +0,0 @@
1#include <linux/types.h>
2#include <linux/kernel.h>
3#include <linux/kallsyms.h>
4#include <linux/init.h>
5#include <linux/bootmem.h>
6#include <linux/irq.h>
7
8void __init pre_alloc_dyn_array(void)
9{
10#ifdef CONFIG_HAVE_DYN_ARRAY
11 unsigned long total_size = 0, size, phys;
12 unsigned long max_align = 1;
13 struct dyn_array **daa;
14 char *ptr;
15
16 /* get the total size at first */
17 for (daa = __dyn_array_start ; daa < __dyn_array_end; daa++) {
18 struct dyn_array *da = *daa;
19
20 printk(KERN_DEBUG "dyn_array %pF size:%#lx nr:%d align:%#lx\n",
21 da->name, da->size, *da->nr, da->align);
22 size = da->size * (*da->nr);
23 total_size += roundup(size, da->align);
24 if (da->align > max_align)
25 max_align = da->align;
26 }
27 if (total_size)
28 printk(KERN_DEBUG "dyn_array total_size: %#lx\n",
29 total_size);
30 else
31 return;
32
33 /* allocate them all together */
34 max_align = max_t(unsigned long, max_align, PAGE_SIZE);
35 ptr = __alloc_bootmem(total_size, max_align, 0);
36 phys = virt_to_phys(ptr);
37
38 for (daa = __dyn_array_start ; daa < __dyn_array_end; daa++) {
39 struct dyn_array *da = *daa;
40
41 size = da->size * (*da->nr);
42 phys = roundup(phys, da->align);
43 printk(KERN_DEBUG "dyn_array %pF ==> [%#lx - %#lx]\n",
44 da->name, phys, phys + size);
45 *da->name = phys_to_virt(phys);
46
47 phys += size;
48
49 if (da->init_work)
50 da->init_work(da);
51 }
52#else
53#ifdef CONFIG_GENERIC_HARDIRQS
54 unsigned int i;
55
56 for (i = 0; i < NR_IRQS; i++)
57 irq_desc[i].irq = i;
58#endif
59#endif
60}
61
62unsigned long __init per_cpu_dyn_array_size(unsigned long *align)
63{
64 unsigned long total_size = 0;
65#ifdef CONFIG_HAVE_DYN_ARRAY
66 unsigned long size;
67 struct dyn_array **daa;
68 unsigned max_align = 1;
69
70 for (daa = __per_cpu_dyn_array_start ; daa < __per_cpu_dyn_array_end; daa++) {
71 struct dyn_array *da = *daa;
72
73 printk(KERN_DEBUG "per_cpu_dyn_array %pF size:%#lx nr:%d align:%#lx\n",
74 da->name, da->size, *da->nr, da->align);
75 size = da->size * (*da->nr);
76 total_size += roundup(size, da->align);
77 if (da->align > max_align)
78 max_align = da->align;
79 }
80 if (total_size) {
81 printk(KERN_DEBUG "per_cpu_dyn_array total_size: %#lx\n",
82 total_size);
83 *align = max_align;
84 }
85#endif
86 return total_size;
87}
88
89#ifdef CONFIG_SMP
90void __init per_cpu_alloc_dyn_array(int cpu, char *ptr)
91{
92#ifdef CONFIG_HAVE_DYN_ARRAY
93 unsigned long size, phys;
94 struct dyn_array **daa;
95 unsigned long addr;
96 void **array;
97
98 phys = virt_to_phys(ptr);
99 for (daa = __per_cpu_dyn_array_start ; daa < __per_cpu_dyn_array_end; daa++) {
100 struct dyn_array *da = *daa;
101
102 size = da->size * (*da->nr);
103 phys = roundup(phys, da->align);
104 printk(KERN_DEBUG "per_cpu_dyn_array %pF ==> [%#lx - %#lx]\n",
105 da->name, phys, phys + size);
106
107 addr = (unsigned long)da->name;
108 addr += per_cpu_offset(cpu);
109 array = (void **)addr;
110 *array = phys_to_virt(phys);
111 *da->name = *array; /* so init_work could use it directly */
112
113 phys += size;
114
115 if (da->init_work)
116 da->init_work(da);
117 }
118#endif
119}
120#endif