diff options
-rw-r--r-- | arch/x86/platform/iris/iris.c | 67 |
1 files changed, 57 insertions, 10 deletions
diff --git a/arch/x86/platform/iris/iris.c b/arch/x86/platform/iris/iris.c index 5917eb56b313..e6cb80f620af 100644 --- a/arch/x86/platform/iris/iris.c +++ b/arch/x86/platform/iris/iris.c | |||
@@ -23,6 +23,7 @@ | |||
23 | 23 | ||
24 | #include <linux/moduleparam.h> | 24 | #include <linux/moduleparam.h> |
25 | #include <linux/module.h> | 25 | #include <linux/module.h> |
26 | #include <linux/platform_device.h> | ||
26 | #include <linux/kernel.h> | 27 | #include <linux/kernel.h> |
27 | #include <linux/errno.h> | 28 | #include <linux/errno.h> |
28 | #include <linux/delay.h> | 29 | #include <linux/delay.h> |
@@ -62,29 +63,75 @@ static void iris_power_off(void) | |||
62 | * by reading its input port and seeing whether the read value is | 63 | * by reading its input port and seeing whether the read value is |
63 | * meaningful. | 64 | * meaningful. |
64 | */ | 65 | */ |
65 | static int iris_init(void) | 66 | static int iris_probe(struct platform_device *pdev) |
66 | { | 67 | { |
67 | unsigned char status; | 68 | unsigned char status = inb(IRIS_GIO_INPUT); |
68 | if (force != 1) { | ||
69 | printk(KERN_ERR "The force parameter has not been set to 1 so the Iris poweroff handler will not be installed.\n"); | ||
70 | return -ENODEV; | ||
71 | } | ||
72 | status = inb(IRIS_GIO_INPUT); | ||
73 | if (status == IRIS_GIO_NODEV) { | 69 | if (status == IRIS_GIO_NODEV) { |
74 | printk(KERN_ERR "This machine does not seem to be an Iris. Power_off handler not installed.\n"); | 70 | printk(KERN_ERR "This machine does not seem to be an Iris. " |
71 | "Power off handler not installed.\n"); | ||
75 | return -ENODEV; | 72 | return -ENODEV; |
76 | } | 73 | } |
77 | old_pm_power_off = pm_power_off; | 74 | old_pm_power_off = pm_power_off; |
78 | pm_power_off = &iris_power_off; | 75 | pm_power_off = &iris_power_off; |
79 | printk(KERN_INFO "Iris power_off handler installed.\n"); | 76 | printk(KERN_INFO "Iris power_off handler installed.\n"); |
80 | |||
81 | return 0; | 77 | return 0; |
82 | } | 78 | } |
83 | 79 | ||
84 | static void iris_exit(void) | 80 | static int iris_remove(struct platform_device *pdev) |
85 | { | 81 | { |
86 | pm_power_off = old_pm_power_off; | 82 | pm_power_off = old_pm_power_off; |
87 | printk(KERN_INFO "Iris power_off handler uninstalled.\n"); | 83 | printk(KERN_INFO "Iris power_off handler uninstalled.\n"); |
84 | return 0; | ||
85 | } | ||
86 | |||
87 | static struct platform_driver iris_driver = { | ||
88 | .driver = { | ||
89 | .name = "iris", | ||
90 | .owner = THIS_MODULE, | ||
91 | }, | ||
92 | .probe = iris_probe, | ||
93 | .remove = iris_remove, | ||
94 | }; | ||
95 | |||
96 | static struct resource iris_resources[] = { | ||
97 | { | ||
98 | .start = IRIS_GIO_BASE, | ||
99 | .end = IRIS_GIO_OUTPUT, | ||
100 | .flags = IORESOURCE_IO, | ||
101 | .name = "address" | ||
102 | } | ||
103 | }; | ||
104 | |||
105 | static struct platform_device *iris_device; | ||
106 | |||
107 | static int iris_init(void) | ||
108 | { | ||
109 | int ret; | ||
110 | if (force != 1) { | ||
111 | printk(KERN_ERR "The force parameter has not been set to 1." | ||
112 | " The Iris poweroff handler will not be installed.\n"); | ||
113 | return -ENODEV; | ||
114 | } | ||
115 | ret = platform_driver_register(&iris_driver); | ||
116 | if (ret < 0) { | ||
117 | printk(KERN_ERR "Failed to register iris platform driver: %d\n", | ||
118 | ret); | ||
119 | return ret; | ||
120 | } | ||
121 | iris_device = platform_device_register_simple("iris", (-1), | ||
122 | iris_resources, ARRAY_SIZE(iris_resources)); | ||
123 | if (IS_ERR(iris_device)) { | ||
124 | printk(KERN_ERR "Failed to register iris platform device\n"); | ||
125 | platform_driver_unregister(&iris_driver); | ||
126 | return PTR_ERR(iris_device); | ||
127 | } | ||
128 | return 0; | ||
129 | } | ||
130 | |||
131 | static void iris_exit(void) | ||
132 | { | ||
133 | platform_device_unregister(iris_device); | ||
134 | platform_driver_unregister(&iris_driver); | ||
88 | } | 135 | } |
89 | 136 | ||
90 | module_init(iris_init); | 137 | module_init(iris_init); |