Commit | Line | Data |
---|---|---|
1da177e4 | 1 | /* |
1da177e4 LT |
2 | * Base infrastructure for Linux-z/VM Monitor Stream, Stage 1. |
3 | * Exports appldata_register_ops() and appldata_unregister_ops() for the | |
4 | * data gathering modules. | |
5 | * | |
524dbcda | 6 | * Copyright IBM Corp. 2003, 2009 |
1da177e4 | 7 | * |
5b5dd21a | 8 | * Author: Gerald Schaefer <gerald.schaefer@de.ibm.com> |
1da177e4 LT |
9 | */ |
10 | ||
e7534b0e GS |
11 | #define KMSG_COMPONENT "appldata" |
12 | #define pr_fmt(fmt) KMSG_COMPONENT ": " fmt | |
13 | ||
1da177e4 LT |
14 | #include <linux/module.h> |
15 | #include <linux/init.h> | |
16 | #include <linux/slab.h> | |
17 | #include <linux/errno.h> | |
1da177e4 LT |
18 | #include <linux/interrupt.h> |
19 | #include <linux/proc_fs.h> | |
2dcea57a | 20 | #include <linux/mm.h> |
1da177e4 LT |
21 | #include <linux/swap.h> |
22 | #include <linux/pagemap.h> | |
23 | #include <linux/sysctl.h> | |
1da177e4 LT |
24 | #include <linux/notifier.h> |
25 | #include <linux/cpu.h> | |
f26d583e | 26 | #include <linux/workqueue.h> |
524dbcda GS |
27 | #include <linux/suspend.h> |
28 | #include <linux/platform_device.h> | |
1f38d613 | 29 | #include <asm/appldata.h> |
27f6b416 | 30 | #include <asm/vtimer.h> |
7c0f6ba6 | 31 | #include <linux/uaccess.h> |
1f38d613 GS |
32 | #include <asm/io.h> |
33 | #include <asm/smp.h> | |
1da177e4 LT |
34 | |
35 | #include "appldata.h" | |
36 | ||
37 | ||
1da177e4 LT |
38 | #define APPLDATA_CPU_INTERVAL 10000 /* default (CPU) time for |
39 | sampling interval in | |
40 | milliseconds */ | |
41 | ||
42 | #define TOD_MICRO 0x01000 /* nr. of TOD clock units | |
43 | for 1 microsecond */ | |
524dbcda GS |
44 | |
45 | static struct platform_device *appldata_pdev; | |
46 | ||
1da177e4 LT |
47 | /* |
48 | * /proc entries (sysctl) | |
49 | */ | |
50 | static const char appldata_proc_name[APPLDATA_PROC_NAME_LENGTH] = "appldata"; | |
302bfe20 | 51 | static int appldata_timer_handler(struct ctl_table *ctl, int write, |
1da177e4 | 52 | void __user *buffer, size_t *lenp, loff_t *ppos); |
302bfe20 | 53 | static int appldata_interval_handler(struct ctl_table *ctl, int write, |
1da177e4 LT |
54 | void __user *buffer, |
55 | size_t *lenp, loff_t *ppos); | |
56 | ||
57 | static struct ctl_table_header *appldata_sysctl_header; | |
58 | static struct ctl_table appldata_table[] = { | |
59 | { | |
1da177e4 LT |
60 | .procname = "timer", |
61 | .mode = S_IRUGO | S_IWUSR, | |
6d456111 | 62 | .proc_handler = appldata_timer_handler, |
1da177e4 LT |
63 | }, |
64 | { | |
1da177e4 LT |
65 | .procname = "interval", |
66 | .mode = S_IRUGO | S_IWUSR, | |
6d456111 | 67 | .proc_handler = appldata_interval_handler, |
1da177e4 | 68 | }, |
37e3a6ac | 69 | { }, |
1da177e4 LT |
70 | }; |
71 | ||
72 | static struct ctl_table appldata_dir_table[] = { | |
73 | { | |
1da177e4 LT |
74 | .procname = appldata_proc_name, |
75 | .maxlen = 0, | |
76 | .mode = S_IRUGO | S_IXUGO, | |
77 | .child = appldata_table, | |
78 | }, | |
37e3a6ac | 79 | { }, |
1da177e4 LT |
80 | }; |
81 | ||
82 | /* | |
83 | * Timer | |
84 | */ | |
27f6b416 | 85 | static struct vtimer_list appldata_timer; |
1da177e4 LT |
86 | |
87 | static DEFINE_SPINLOCK(appldata_timer_lock); | |
88 | static int appldata_interval = APPLDATA_CPU_INTERVAL; | |
89 | static int appldata_timer_active; | |
524dbcda | 90 | static int appldata_timer_suspended = 0; |
1da177e4 LT |
91 | |
92 | /* | |
f26d583e | 93 | * Work queue |
1da177e4 | 94 | */ |
f26d583e | 95 | static struct workqueue_struct *appldata_wq; |
6d5aefb8 DH |
96 | static void appldata_work_fn(struct work_struct *work); |
97 | static DECLARE_WORK(appldata_work, appldata_work_fn); | |
f26d583e | 98 | |
1da177e4 LT |
99 | |
100 | /* | |
101 | * Ops list | |
102 | */ | |
b1ad171e | 103 | static DEFINE_MUTEX(appldata_ops_mutex); |
1da177e4 LT |
104 | static LIST_HEAD(appldata_ops_list); |
105 | ||
106 | ||
f26d583e | 107 | /*************************** timer, work, DIAG *******************************/ |
1da177e4 LT |
108 | /* |
109 | * appldata_timer_function() | |
110 | * | |
f26d583e | 111 | * schedule work and reschedule timer |
1da177e4 | 112 | */ |
9d0a57cb | 113 | static void appldata_timer_function(unsigned long data) |
1da177e4 | 114 | { |
27f6b416 | 115 | queue_work(appldata_wq, (struct work_struct *) data); |
1da177e4 LT |
116 | } |
117 | ||
118 | /* | |
f26d583e | 119 | * appldata_work_fn() |
1da177e4 LT |
120 | * |
121 | * call data gathering function for each (active) module | |
122 | */ | |
6d5aefb8 | 123 | static void appldata_work_fn(struct work_struct *work) |
1da177e4 LT |
124 | { |
125 | struct list_head *lh; | |
126 | struct appldata_ops *ops; | |
1da177e4 | 127 | |
b1ad171e | 128 | mutex_lock(&appldata_ops_mutex); |
1da177e4 LT |
129 | list_for_each(lh, &appldata_ops_list) { |
130 | ops = list_entry(lh, struct appldata_ops, list); | |
1da177e4 LT |
131 | if (ops->active == 1) { |
132 | ops->callback(ops->data); | |
133 | } | |
134 | } | |
b1ad171e | 135 | mutex_unlock(&appldata_ops_mutex); |
1da177e4 LT |
136 | } |
137 | ||
138 | /* | |
139 | * appldata_diag() | |
140 | * | |
141 | * prepare parameter list, issue DIAG 0xDC | |
142 | */ | |
5b5dd21a GS |
143 | int appldata_diag(char record_nr, u16 function, unsigned long buffer, |
144 | u16 length, char *mod_lvl) | |
1da177e4 | 145 | { |
1f38d613 | 146 | struct appldata_product_id id = { |
1da177e4 | 147 | .prod_nr = {0xD3, 0xC9, 0xD5, 0xE4, |
1f38d613 GS |
148 | 0xE7, 0xD2, 0xD9}, /* "LINUXKR" */ |
149 | .prod_fn = 0xD5D3, /* "NL" */ | |
1f38d613 GS |
150 | .version_nr = 0xF2F6, /* "26" */ |
151 | .release_nr = 0xF0F1, /* "01" */ | |
1da177e4 LT |
152 | }; |
153 | ||
925afbd6 GS |
154 | id.record_nr = record_nr; |
155 | id.mod_lvl = (mod_lvl[0]) << 8 | mod_lvl[1]; | |
1f38d613 | 156 | return appldata_asm(&id, function, (void *) buffer, length); |
1da177e4 | 157 | } |
f26d583e | 158 | /************************ timer, work, DIAG <END> ****************************/ |
1da177e4 LT |
159 | |
160 | ||
161 | /****************************** /proc stuff **********************************/ | |
162 | ||
1da177e4 LT |
163 | #define APPLDATA_ADD_TIMER 0 |
164 | #define APPLDATA_DEL_TIMER 1 | |
165 | #define APPLDATA_MOD_TIMER 2 | |
166 | ||
167 | /* | |
168 | * __appldata_vtimer_setup() | |
169 | * | |
170 | * Add, delete or modify virtual timers on all online cpus. | |
171 | * The caller needs to get the appldata_timer_lock spinlock. | |
172 | */ | |
27f6b416 | 173 | static void __appldata_vtimer_setup(int cmd) |
1da177e4 | 174 | { |
27f6b416 | 175 | u64 timer_interval = (u64) appldata_interval * 1000 * TOD_MICRO; |
1da177e4 LT |
176 | |
177 | switch (cmd) { | |
178 | case APPLDATA_ADD_TIMER: | |
179 | if (appldata_timer_active) | |
180 | break; | |
27f6b416 MS |
181 | appldata_timer.expires = timer_interval; |
182 | add_virt_timer_periodic(&appldata_timer); | |
1da177e4 | 183 | appldata_timer_active = 1; |
1da177e4 LT |
184 | break; |
185 | case APPLDATA_DEL_TIMER: | |
27f6b416 | 186 | del_virt_timer(&appldata_timer); |
1da177e4 LT |
187 | if (!appldata_timer_active) |
188 | break; | |
189 | appldata_timer_active = 0; | |
1da177e4 LT |
190 | break; |
191 | case APPLDATA_MOD_TIMER: | |
1da177e4 LT |
192 | if (!appldata_timer_active) |
193 | break; | |
27f6b416 | 194 | mod_virt_timer_periodic(&appldata_timer, timer_interval); |
1da177e4 LT |
195 | } |
196 | } | |
197 | ||
198 | /* | |
199 | * appldata_timer_handler() | |
200 | * | |
201 | * Start/Stop timer, show status of timer (0 = not active, 1 = active) | |
202 | */ | |
203 | static int | |
302bfe20 | 204 | appldata_timer_handler(struct ctl_table *ctl, int write, |
1da177e4 LT |
205 | void __user *buffer, size_t *lenp, loff_t *ppos) |
206 | { | |
57f47ba0 | 207 | unsigned int len; |
1da177e4 LT |
208 | char buf[2]; |
209 | ||
210 | if (!*lenp || *ppos) { | |
211 | *lenp = 0; | |
212 | return 0; | |
213 | } | |
214 | if (!write) { | |
d5b4c2f4 CG |
215 | strncpy(buf, appldata_timer_active ? "1\n" : "0\n", |
216 | ARRAY_SIZE(buf)); | |
217 | len = strnlen(buf, ARRAY_SIZE(buf)); | |
1da177e4 LT |
218 | if (len > *lenp) |
219 | len = *lenp; | |
220 | if (copy_to_user(buffer, buf, len)) | |
221 | return -EFAULT; | |
222 | goto out; | |
223 | } | |
224 | len = *lenp; | |
225 | if (copy_from_user(buf, buffer, len > sizeof(buf) ? sizeof(buf) : len)) | |
226 | return -EFAULT; | |
227 | spin_lock(&appldata_timer_lock); | |
228 | if (buf[0] == '1') | |
229 | __appldata_vtimer_setup(APPLDATA_ADD_TIMER); | |
230 | else if (buf[0] == '0') | |
231 | __appldata_vtimer_setup(APPLDATA_DEL_TIMER); | |
232 | spin_unlock(&appldata_timer_lock); | |
233 | out: | |
234 | *lenp = len; | |
235 | *ppos += len; | |
236 | return 0; | |
237 | } | |
238 | ||
239 | /* | |
240 | * appldata_interval_handler() | |
241 | * | |
242 | * Set (CPU) timer interval for collection of data (in milliseconds), show | |
243 | * current timer interval. | |
244 | */ | |
245 | static int | |
302bfe20 | 246 | appldata_interval_handler(struct ctl_table *ctl, int write, |
1da177e4 LT |
247 | void __user *buffer, size_t *lenp, loff_t *ppos) |
248 | { | |
57f47ba0 HC |
249 | unsigned int len; |
250 | int interval; | |
1da177e4 LT |
251 | char buf[16]; |
252 | ||
253 | if (!*lenp || *ppos) { | |
254 | *lenp = 0; | |
255 | return 0; | |
256 | } | |
257 | if (!write) { | |
258 | len = sprintf(buf, "%i\n", appldata_interval); | |
259 | if (len > *lenp) | |
260 | len = *lenp; | |
261 | if (copy_to_user(buffer, buf, len)) | |
262 | return -EFAULT; | |
263 | goto out; | |
264 | } | |
265 | len = *lenp; | |
27f6b416 | 266 | if (copy_from_user(buf, buffer, len > sizeof(buf) ? sizeof(buf) : len)) |
1da177e4 | 267 | return -EFAULT; |
95425f19 | 268 | interval = 0; |
1da177e4 | 269 | sscanf(buf, "%i", &interval); |
d3ae942d | 270 | if (interval <= 0) |
1da177e4 | 271 | return -EINVAL; |
1da177e4 LT |
272 | |
273 | spin_lock(&appldata_timer_lock); | |
274 | appldata_interval = interval; | |
275 | __appldata_vtimer_setup(APPLDATA_MOD_TIMER); | |
276 | spin_unlock(&appldata_timer_lock); | |
1da177e4 LT |
277 | out: |
278 | *lenp = len; | |
279 | *ppos += len; | |
280 | return 0; | |
281 | } | |
282 | ||
283 | /* | |
284 | * appldata_generic_handler() | |
285 | * | |
286 | * Generic start/stop monitoring and DIAG, show status of | |
287 | * monitoring (0 = not in process, 1 = in process) | |
288 | */ | |
289 | static int | |
302bfe20 | 290 | appldata_generic_handler(struct ctl_table *ctl, int write, |
1da177e4 LT |
291 | void __user *buffer, size_t *lenp, loff_t *ppos) |
292 | { | |
293 | struct appldata_ops *ops = NULL, *tmp_ops; | |
57f47ba0 HC |
294 | unsigned int len; |
295 | int rc, found; | |
1da177e4 LT |
296 | char buf[2]; |
297 | struct list_head *lh; | |
298 | ||
299 | found = 0; | |
b1ad171e | 300 | mutex_lock(&appldata_ops_mutex); |
1da177e4 LT |
301 | list_for_each(lh, &appldata_ops_list) { |
302 | tmp_ops = list_entry(lh, struct appldata_ops, list); | |
303 | if (&tmp_ops->ctl_table[2] == ctl) { | |
304 | found = 1; | |
305 | } | |
306 | } | |
307 | if (!found) { | |
b1ad171e | 308 | mutex_unlock(&appldata_ops_mutex); |
1da177e4 LT |
309 | return -ENODEV; |
310 | } | |
311 | ops = ctl->data; | |
312 | if (!try_module_get(ops->owner)) { // protect this function | |
b1ad171e | 313 | mutex_unlock(&appldata_ops_mutex); |
1da177e4 LT |
314 | return -ENODEV; |
315 | } | |
b1ad171e | 316 | mutex_unlock(&appldata_ops_mutex); |
1da177e4 LT |
317 | |
318 | if (!*lenp || *ppos) { | |
319 | *lenp = 0; | |
320 | module_put(ops->owner); | |
321 | return 0; | |
322 | } | |
323 | if (!write) { | |
d5b4c2f4 CG |
324 | strncpy(buf, ops->active ? "1\n" : "0\n", ARRAY_SIZE(buf)); |
325 | len = strnlen(buf, ARRAY_SIZE(buf)); | |
1da177e4 LT |
326 | if (len > *lenp) |
327 | len = *lenp; | |
328 | if (copy_to_user(buffer, buf, len)) { | |
329 | module_put(ops->owner); | |
330 | return -EFAULT; | |
331 | } | |
332 | goto out; | |
333 | } | |
334 | len = *lenp; | |
335 | if (copy_from_user(buf, buffer, | |
336 | len > sizeof(buf) ? sizeof(buf) : len)) { | |
337 | module_put(ops->owner); | |
338 | return -EFAULT; | |
339 | } | |
340 | ||
b1ad171e | 341 | mutex_lock(&appldata_ops_mutex); |
1da177e4 | 342 | if ((buf[0] == '1') && (ops->active == 0)) { |
f26d583e GS |
343 | // protect work queue callback |
344 | if (!try_module_get(ops->owner)) { | |
b1ad171e | 345 | mutex_unlock(&appldata_ops_mutex); |
1da177e4 LT |
346 | module_put(ops->owner); |
347 | return -ENODEV; | |
348 | } | |
1da177e4 LT |
349 | ops->callback(ops->data); // init record |
350 | rc = appldata_diag(ops->record_nr, | |
351 | APPLDATA_START_INTERVAL_REC, | |
5b5dd21a GS |
352 | (unsigned long) ops->data, ops->size, |
353 | ops->mod_lvl); | |
1da177e4 | 354 | if (rc != 0) { |
e7534b0e GS |
355 | pr_err("Starting the data collection for %s " |
356 | "failed with rc=%d\n", ops->name, rc); | |
1da177e4 | 357 | module_put(ops->owner); |
d3ae942d | 358 | } else |
5b5dd21a | 359 | ops->active = 1; |
1da177e4 LT |
360 | } else if ((buf[0] == '0') && (ops->active == 1)) { |
361 | ops->active = 0; | |
362 | rc = appldata_diag(ops->record_nr, APPLDATA_STOP_REC, | |
5b5dd21a GS |
363 | (unsigned long) ops->data, ops->size, |
364 | ops->mod_lvl); | |
d3ae942d | 365 | if (rc != 0) |
e7534b0e GS |
366 | pr_err("Stopping the data collection for %s " |
367 | "failed with rc=%d\n", ops->name, rc); | |
1da177e4 LT |
368 | module_put(ops->owner); |
369 | } | |
b1ad171e | 370 | mutex_unlock(&appldata_ops_mutex); |
1da177e4 LT |
371 | out: |
372 | *lenp = len; | |
373 | *ppos += len; | |
374 | module_put(ops->owner); | |
375 | return 0; | |
376 | } | |
377 | ||
378 | /*************************** /proc stuff <END> *******************************/ | |
379 | ||
380 | ||
381 | /************************* module-ops management *****************************/ | |
382 | /* | |
383 | * appldata_register_ops() | |
384 | * | |
385 | * update ops list, register /proc/sys entries | |
386 | */ | |
387 | int appldata_register_ops(struct appldata_ops *ops) | |
388 | { | |
13f8b7c5 | 389 | if (ops->size > APPLDATA_MAX_REC_SIZE) |
37e3a6ac | 390 | return -EINVAL; |
1da177e4 | 391 | |
37e3a6ac HC |
392 | ops->ctl_table = kzalloc(4 * sizeof(struct ctl_table), GFP_KERNEL); |
393 | if (!ops->ctl_table) | |
1da177e4 | 394 | return -ENOMEM; |
1da177e4 | 395 | |
b1ad171e | 396 | mutex_lock(&appldata_ops_mutex); |
1da177e4 | 397 | list_add(&ops->list, &appldata_ops_list); |
b1ad171e | 398 | mutex_unlock(&appldata_ops_mutex); |
1da177e4 | 399 | |
1da177e4 LT |
400 | ops->ctl_table[0].procname = appldata_proc_name; |
401 | ops->ctl_table[0].maxlen = 0; | |
402 | ops->ctl_table[0].mode = S_IRUGO | S_IXUGO; | |
403 | ops->ctl_table[0].child = &ops->ctl_table[2]; | |
404 | ||
1da177e4 LT |
405 | ops->ctl_table[2].procname = ops->name; |
406 | ops->ctl_table[2].mode = S_IRUGO | S_IWUSR; | |
407 | ops->ctl_table[2].proc_handler = appldata_generic_handler; | |
408 | ops->ctl_table[2].data = ops; | |
409 | ||
0b4d4147 | 410 | ops->sysctl_header = register_sysctl_table(ops->ctl_table); |
37e3a6ac HC |
411 | if (!ops->sysctl_header) |
412 | goto out; | |
1da177e4 | 413 | return 0; |
37e3a6ac | 414 | out: |
b1ad171e | 415 | mutex_lock(&appldata_ops_mutex); |
37e3a6ac | 416 | list_del(&ops->list); |
b1ad171e | 417 | mutex_unlock(&appldata_ops_mutex); |
37e3a6ac HC |
418 | kfree(ops->ctl_table); |
419 | return -ENOMEM; | |
1da177e4 LT |
420 | } |
421 | ||
422 | /* | |
423 | * appldata_unregister_ops() | |
424 | * | |
425 | * update ops list, unregister /proc entries, stop DIAG if necessary | |
426 | */ | |
427 | void appldata_unregister_ops(struct appldata_ops *ops) | |
428 | { | |
b1ad171e | 429 | mutex_lock(&appldata_ops_mutex); |
1da177e4 | 430 | list_del(&ops->list); |
b1ad171e | 431 | mutex_unlock(&appldata_ops_mutex); |
330d57fb | 432 | unregister_sysctl_table(ops->sysctl_header); |
37e3a6ac | 433 | kfree(ops->ctl_table); |
1da177e4 LT |
434 | } |
435 | /********************** module-ops management <END> **************************/ | |
436 | ||
437 | ||
524dbcda GS |
438 | /**************************** suspend / resume *******************************/ |
439 | static int appldata_freeze(struct device *dev) | |
440 | { | |
441 | struct appldata_ops *ops; | |
442 | int rc; | |
443 | struct list_head *lh; | |
444 | ||
524dbcda GS |
445 | spin_lock(&appldata_timer_lock); |
446 | if (appldata_timer_active) { | |
447 | __appldata_vtimer_setup(APPLDATA_DEL_TIMER); | |
448 | appldata_timer_suspended = 1; | |
449 | } | |
450 | spin_unlock(&appldata_timer_lock); | |
524dbcda GS |
451 | |
452 | mutex_lock(&appldata_ops_mutex); | |
453 | list_for_each(lh, &appldata_ops_list) { | |
454 | ops = list_entry(lh, struct appldata_ops, list); | |
455 | if (ops->active == 1) { | |
456 | rc = appldata_diag(ops->record_nr, APPLDATA_STOP_REC, | |
457 | (unsigned long) ops->data, ops->size, | |
458 | ops->mod_lvl); | |
459 | if (rc != 0) | |
460 | pr_err("Stopping the data collection for %s " | |
461 | "failed with rc=%d\n", ops->name, rc); | |
462 | } | |
463 | } | |
464 | mutex_unlock(&appldata_ops_mutex); | |
465 | return 0; | |
466 | } | |
467 | ||
468 | static int appldata_restore(struct device *dev) | |
469 | { | |
470 | struct appldata_ops *ops; | |
471 | int rc; | |
472 | struct list_head *lh; | |
473 | ||
524dbcda GS |
474 | spin_lock(&appldata_timer_lock); |
475 | if (appldata_timer_suspended) { | |
476 | __appldata_vtimer_setup(APPLDATA_ADD_TIMER); | |
477 | appldata_timer_suspended = 0; | |
478 | } | |
479 | spin_unlock(&appldata_timer_lock); | |
524dbcda GS |
480 | |
481 | mutex_lock(&appldata_ops_mutex); | |
482 | list_for_each(lh, &appldata_ops_list) { | |
483 | ops = list_entry(lh, struct appldata_ops, list); | |
484 | if (ops->active == 1) { | |
485 | ops->callback(ops->data); // init record | |
486 | rc = appldata_diag(ops->record_nr, | |
487 | APPLDATA_START_INTERVAL_REC, | |
488 | (unsigned long) ops->data, ops->size, | |
489 | ops->mod_lvl); | |
490 | if (rc != 0) { | |
491 | pr_err("Starting the data collection for %s " | |
492 | "failed with rc=%d\n", ops->name, rc); | |
493 | } | |
494 | } | |
495 | } | |
496 | mutex_unlock(&appldata_ops_mutex); | |
497 | return 0; | |
498 | } | |
499 | ||
500 | static int appldata_thaw(struct device *dev) | |
501 | { | |
502 | return appldata_restore(dev); | |
503 | } | |
504 | ||
47145210 | 505 | static const struct dev_pm_ops appldata_pm_ops = { |
524dbcda GS |
506 | .freeze = appldata_freeze, |
507 | .thaw = appldata_thaw, | |
508 | .restore = appldata_restore, | |
509 | }; | |
510 | ||
511 | static struct platform_driver appldata_pdrv = { | |
512 | .driver = { | |
513 | .name = "appldata", | |
524dbcda GS |
514 | .pm = &appldata_pm_ops, |
515 | }, | |
516 | }; | |
517 | /************************* suspend / resume <END> ****************************/ | |
518 | ||
519 | ||
1da177e4 LT |
520 | /******************************* init / exit *********************************/ |
521 | ||
1da177e4 LT |
522 | /* |
523 | * appldata_init() | |
524 | * | |
f26d583e | 525 | * init timer, register /proc entries |
1da177e4 LT |
526 | */ |
527 | static int __init appldata_init(void) | |
528 | { | |
27f6b416 MS |
529 | int rc; |
530 | ||
b7c5b1aa | 531 | init_virt_timer(&appldata_timer); |
27f6b416 MS |
532 | appldata_timer.function = appldata_timer_function; |
533 | appldata_timer.data = (unsigned long) &appldata_work; | |
524dbcda GS |
534 | |
535 | rc = platform_driver_register(&appldata_pdrv); | |
536 | if (rc) | |
537 | return rc; | |
1da177e4 | 538 | |
524dbcda GS |
539 | appldata_pdev = platform_device_register_simple("appldata", -1, NULL, |
540 | 0); | |
541 | if (IS_ERR(appldata_pdev)) { | |
542 | rc = PTR_ERR(appldata_pdev); | |
543 | goto out_driver; | |
544 | } | |
e68f1d4c | 545 | appldata_wq = alloc_ordered_workqueue("appldata", 0); |
524dbcda GS |
546 | if (!appldata_wq) { |
547 | rc = -ENOMEM; | |
548 | goto out_device; | |
549 | } | |
f26d583e | 550 | |
0b4d4147 | 551 | appldata_sysctl_header = register_sysctl_table(appldata_dir_table); |
1da177e4 | 552 | return 0; |
524dbcda GS |
553 | |
554 | out_device: | |
555 | platform_device_unregister(appldata_pdev); | |
556 | out_driver: | |
557 | platform_driver_unregister(&appldata_pdrv); | |
558 | return rc; | |
1da177e4 LT |
559 | } |
560 | ||
076fc808 | 561 | __initcall(appldata_init); |
1da177e4 | 562 | |
1da177e4 LT |
563 | /**************************** init / exit <END> ******************************/ |
564 | ||
1da177e4 LT |
565 | EXPORT_SYMBOL_GPL(appldata_register_ops); |
566 | EXPORT_SYMBOL_GPL(appldata_unregister_ops); | |
5b5dd21a | 567 | EXPORT_SYMBOL_GPL(appldata_diag); |
1da177e4 | 568 | |
0c3252d5 | 569 | #ifdef CONFIG_SWAP |
1da177e4 | 570 | EXPORT_SYMBOL_GPL(si_swapinfo); |
0c3252d5 | 571 | #endif |
1da177e4 | 572 | EXPORT_SYMBOL_GPL(nr_threads); |
1da177e4 LT |
573 | EXPORT_SYMBOL_GPL(nr_running); |
574 | EXPORT_SYMBOL_GPL(nr_iowait); |