blob: df7af5f7d9c9d359439c3903219b8cd237b5c710 [file] [log] [blame]
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001/*
2 * Copyright (c) 2010, Code Aurora Forum. All rights reserved.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 and
6 * only version 2 as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 */
13
14#include <linux/platform_device.h>
15#include <linux/memory.h>
16#include <linux/memory_hotplug.h>
17#include <mach/msm_migrate_pages.h>
18
19static unsigned long unstable_memory_state;
20
21unsigned long get_msm_migrate_pages_status(void)
22{
23 return unstable_memory_state;
24}
25EXPORT_SYMBOL(get_msm_migrate_pages_status);
26
27#ifdef CONFIG_MEMORY_HOTPLUG
28static int migrate_pages_callback(struct notifier_block *self,
29 unsigned long action, void *arg)
30{
31 int ret = 0;
32
33 switch (action) {
34 case MEM_ONLINE:
35 unstable_memory_state = action;
36 break;
37 case MEM_OFFLINE:
38 unstable_memory_state = action;
39 break;
40 case MEM_GOING_OFFLINE:
41 case MEM_GOING_ONLINE:
42 case MEM_CANCEL_ONLINE:
43 case MEM_CANCEL_OFFLINE:
44 break;
45 }
46 return ret;
47}
48#endif
49
50static int __devinit msm_migrate_pages_probe(struct platform_device *pdev)
51{
52#ifdef CONFIG_MEMORY_HOTPLUG
53 hotplug_memory_notifier(migrate_pages_callback, 0);
54#endif
55 unstable_memory_state = 0;
56 return 0;
57}
58
59static struct platform_driver msm_migrate_pages_driver = {
60 .probe = msm_migrate_pages_probe,
61 .driver = {
62 .name = "msm_migrate_pages",
63 },
64};
65
66static int __init msm_migrate_pages_init(void)
67{
68 return platform_driver_register(&msm_migrate_pages_driver);
69}
70
71static void __exit msm_migrate_pages_exit(void)
72{
73 platform_driver_unregister(&msm_migrate_pages_driver);
74}
75
76module_init(msm_migrate_pages_init);
77module_exit(msm_migrate_pages_exit);
78
79MODULE_LICENSE("GPL v2");
80MODULE_DESCRIPTION("Get Status of Unstable Memory Region");