]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
This makes the iris driver use the platform API, so it is properly exposed
authorShérab <Sebastien.Hinderer@ens-lyon.org>
Tue, 26 Jul 2011 10:14:37 +0000 (20:14 +1000)
committerStephen Rothwell <sfr@canb.auug.org.au>
Tue, 2 Aug 2011 05:14:17 +0000 (15:14 +1000)
in /sys.

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>
arch/x86/platform/iris/iris.c

index 1ba7f5ed8c9b9e0675b612d358659be9d57dd82a..65f29daa4bf546d72d776abda914acb7344b12b7 100644 (file)
@@ -23,6 +23,7 @@
 
 #include <linux/moduleparam.h>
 #include <linux/module.h>
+#include <linux/platform_device.h>
 #include <linux/kernel.h>
 #include <linux/errno.h>
 #include <linux/delay.h>
@@ -62,29 +63,77 @@ static void iris_power_off(void)
  * by reading its input port and seeing whether the read value is
  * meaningful.
  */
-static int iris_init(void)
+static int iris_probe(struct platform_device *pdev)
 {
-       unsigned char status;
-       if (force != 1) {
-               printk(KERN_ERR "The force parameter has not been set to 1 so the Iris poweroff handler will not be installed.\n");
-               return -ENODEV;
-       }
-       status = inb(IRIS_GIO_INPUT);
+/*
+       unsigned char status = inb(IRIS_GIO_INPUT);
        if (status == IRIS_GIO_NODEV) {
-               printk(KERN_ERR "This machine does not seem to be an Iris. Power_off handler not installed.\n");
+               printk(KERN_ERR "This machine does not seem to be an Iris. "
+                       "Power off handler not installed.\n");
                return -ENODEV;
        }
+*/
        old_pm_power_off = pm_power_off;
        pm_power_off = &iris_power_off;
        printk(KERN_INFO "Iris power_off handler installed.\n");
-
        return 0;
 }
 
-static void iris_exit(void)
+static int iris_remove(struct platform_device *pdev)
 {
        pm_power_off = old_pm_power_off;
        printk(KERN_INFO "Iris power_off handler uninstalled.\n");
+       return 0;
+}
+
+static struct platform_driver iris_driver = {
+       .driver         = {
+               .name   = "iris",
+               .owner  = THIS_MODULE,
+       },
+       .probe          = iris_probe,
+       .remove         = iris_remove,
+};
+
+static struct resource iris_resources[] = {
+       {
+               .start  = IRIS_GIO_BASE,
+               .end    = IRIS_GIO_OUTPUT,
+               .flags  = IORESOURCE_IO,
+               .name   = "address"
+       }
+};
+
+static struct platform_device *iris_device;
+
+static int iris_init(void)
+{
+       int ret;
+       if (force != 1) {
+               printk(KERN_ERR "The force parameter has not been set to 1."
+                       "The Iris poweroff handler will not be installed.\n");
+               return -ENODEV;
+       }
+       ret = platform_driver_register(&iris_driver);
+       if (ret < 0) {
+               printk(KERN_ERR "Failed to register iris platform driver: "
+                       "%d\n", ret);
+               return ret;
+       }
+       iris_device = platform_device_register_simple(
+               "iris", (-1), iris_resources, ARRAY_SIZE(iris_resources));
+       if (IS_ERR(iris_device)) {
+               printk(KERN_ERR "Failed to register iris platform device\n");
+               platform_driver_unregister(&iris_driver);
+               return PTR_ERR(iris_device);
+       }
+       return 0;
+}
+
+static void iris_exit(void)
+{
+       platform_device_unregister(iris_device);
+       platform_driver_unregister(&iris_driver);
 }
 
 module_init(iris_init);