[PATCH] make bio->bi_end_io() optional
[linux-2.6/history.git] / kernel / platform.c
blob66eb41af168dcfa924953fa06f5bd04a68b1d83e
1 /*
2 * platform driver support
3 */
5 #include <linux/platform.h>
6 #include <linux/module.h>
7 #include <linux/errno.h>
10 void default_reboot(char * cmd)
12 /* nothing */
15 void default_halt(void)
17 /* nothing */
20 int default_suspend(int state, int flags)
22 return -ENOSYS;
25 static struct platform_t default_platform = {
26 .name = "Default Platform",
27 .suspend_states = 0,
28 .reboot = default_reboot,
29 .halt = default_halt,
30 .power_off = default_halt,
31 .suspend = default_suspend,
32 .idle = default_idle,
35 struct platform_t * platform = &default_platform;
36 static spinlock_t platform_lock = SPIN_LOCK_UNLOCKED;
38 /**
39 * set_platform_driver - set the platform driver.
40 * @pf: driver to set it to
42 * Return -EEXIST if someone else already owns it.
44 int set_platform_driver(struct platform_t * pf)
46 if (!pf)
47 return -EINVAL;
48 spin_lock(&platform_lock);
49 if (platform != &default_platform) {
50 spin_unlock(&platform_lock);
51 return -EEXIST;
53 platform = pf;
54 spin_unlock(&platform_lock);
55 return 0;
58 void remove_platform_driver(struct platform_t * pf)
60 spin_lock(&platform_lock);
61 if (platform == pf)
62 platform = &default_platform;
63 spin_unlock(&platform_lock);
66 EXPORT_SYMBOL(default_reboot);
67 EXPORT_SYMBOL(default_halt);
68 EXPORT_SYMBOL(default_suspend);
70 EXPORT_SYMBOL(platform);
71 EXPORT_SYMBOL(set_platform_driver);
72 EXPORT_SYMBOL(remove_platform_driver);