aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/platform
diff options
context:
space:
mode:
authorShérab <Sebastien.Hinderer@ens-lyon.org>2012-12-18 17:21:21 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2012-12-18 18:02:11 -0500
commit88d67ee3ec52d19e52ae58ef4303464720215d3a (patch)
tree8191ae1ca066f431be1c79141c0502bebddbb367 /arch/x86/platform
parentc24bf9b4cc6a0f330ea355d73bfdf1dae7e63a05 (diff)
arch/x86/platform/iris/iris.c: register a platform device and a platform driver
This makes the iris driver use the platform API, so it is properly exposed in /sys. [akpm@linux-foundation.org: remove commented-out code, add missing space to printk, clean up code layout] Signed-off-by: Shérab <Sebastien.Hinderer@ens-lyon.org> Cc: Len Brown <lenb@kernel.org> Cc: Matthew Garrett <mjg@redhat.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'arch/x86/platform')
-rw-r--r--arch/x86/platform/iris/iris.c67
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 */
65static int iris_init(void) 66static 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
84static void iris_exit(void) 80static 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
87static 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
96static 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
105static struct platform_device *iris_device;
106
107static 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
131static void iris_exit(void)
132{
133 platform_device_unregister(iris_device);
134 platform_driver_unregister(&iris_driver);
88} 135}
89 136
90module_init(iris_init); 137module_init(iris_init);