aboutsummaryrefslogtreecommitdiff
path: root/drivers/misc/msm_migrate_pages.c
blob: c4aa1f8bf4348ab0b84e6359f3797d550c6931da (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
/*
 * Copyright (c) 2010, The Linux Foundation. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
 * only version 2 as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 */

#include <linux/platform_device.h>
#include <linux/memory.h>
#include <linux/memory_hotplug.h>
#include <linux/module.h>
#include <mach/msm_migrate_pages.h>

static unsigned long unstable_memory_state;

unsigned long get_msm_migrate_pages_status(void)
{
	return unstable_memory_state;
}
EXPORT_SYMBOL(get_msm_migrate_pages_status);

#ifdef CONFIG_MEMORY_HOTPLUG
static int migrate_pages_callback(struct notifier_block *self,
				unsigned long action, void *arg)
{
	int ret = 0;

	switch (action) {
	case MEM_ONLINE:
		unstable_memory_state = action;
		break;
	case MEM_OFFLINE:
		unstable_memory_state = action;
		break;
	case MEM_GOING_OFFLINE:
	case MEM_GOING_ONLINE:
	case MEM_CANCEL_ONLINE:
	case MEM_CANCEL_OFFLINE:
		break;
	}
	return ret;
}
#endif

static int __devinit msm_migrate_pages_probe(struct platform_device *pdev)
{
#ifdef CONFIG_MEMORY_HOTPLUG
	hotplug_memory_notifier(migrate_pages_callback, 0);
#endif
	unstable_memory_state = 0;
	return 0;
}

static struct platform_driver msm_migrate_pages_driver = {
	.probe = msm_migrate_pages_probe,
	.driver = {
		.name = "msm_migrate_pages",
	},
};

static int __init msm_migrate_pages_init(void)
{
	return platform_driver_register(&msm_migrate_pages_driver);
}

static void __exit msm_migrate_pages_exit(void)
{
	platform_driver_unregister(&msm_migrate_pages_driver);
}

module_init(msm_migrate_pages_init);
module_exit(msm_migrate_pages_exit);

MODULE_LICENSE("GPL v2");
MODULE_DESCRIPTION("Get Status of Unstable Memory Region");