blob: 6dcdd02efe9d9ebf20dc2a2a5b9437fe9559da2a [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>
Steve Mucklef132c6c2012-06-06 18:30:57 -070017#include <linux/module.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070018#include <mach/msm_migrate_pages.h>
19
20static unsigned long unstable_memory_state;
21
22unsigned long get_msm_migrate_pages_status(void)
23{
24 return unstable_memory_state;
25}
26EXPORT_SYMBOL(get_msm_migrate_pages_status);
27
28#ifdef CONFIG_MEMORY_HOTPLUG
29static int migrate_pages_callback(struct notifier_block *self,
30 unsigned long action, void *arg)
31{
32 int ret = 0;
33
34 switch (action) {
35 case MEM_ONLINE:
36 unstable_memory_state = action;
37 break;
38 case MEM_OFFLINE:
39 unstable_memory_state = action;
40 break;
41 case MEM_GOING_OFFLINE:
42 case MEM_GOING_ONLINE:
43 case MEM_CANCEL_ONLINE:
44 case MEM_CANCEL_OFFLINE:
45 break;
46 }
47 return ret;
48}
49#endif
50
51static int __devinit msm_migrate_pages_probe(struct platform_device *pdev)
52{
53#ifdef CONFIG_MEMORY_HOTPLUG
54 hotplug_memory_notifier(migrate_pages_callback, 0);
55#endif
56 unstable_memory_state = 0;
57 return 0;
58}
59
60static struct platform_driver msm_migrate_pages_driver = {
61 .probe = msm_migrate_pages_probe,
62 .driver = {
63 .name = "msm_migrate_pages",
64 },
65};
66
67static int __init msm_migrate_pages_init(void)
68{
69 return platform_driver_register(&msm_migrate_pages_driver);
70}
71
72static void __exit msm_migrate_pages_exit(void)
73{
74 platform_driver_unregister(&msm_migrate_pages_driver);
75}
76
77module_init(msm_migrate_pages_init);
78module_exit(msm_migrate_pages_exit);
79
80MODULE_LICENSE("GPL v2");
81MODULE_DESCRIPTION("Get Status of Unstable Memory Region");