[DRIVER MODEL] Convert platform drivers to use struct platform_driver
[deliverable/linux.git] / drivers / hwmon / hdaps.c
index 4c56411f399316c8bb11833beda296a351c34537..3bf05d5d0c82feab785e4c403481b083c8483c7d 100644 (file)
@@ -4,9 +4,9 @@
  * Copyright (C) 2005 Robert Love <rml@novell.com>
  * Copyright (C) 2005 Jesper Juhl <jesper.juhl@gmail.com>
  *
- * The HardDisk Active Protection System (hdaps) is present in the IBM ThinkPad
- * T41, T42, T43, R50, R50p, R51, and X40, at least.  It provides a basic
- * two-axis accelerometer and other data, such as the device's temperature.
+ * The HardDisk Active Protection System (hdaps) is present in IBM ThinkPads
+ * starting with the R40, T41, and X40.  It provides a basic two-axis
+ * accelerometer and other data, such as the device's temperature.
  *
  * This driver is based on the document by Mark A. Smith available at
  * http://www.almaden.ibm.com/cs/people/marksmith/tpaps.html and a lot of trial
@@ -27,7 +27,7 @@
  */
 
 #include <linux/delay.h>
-#include <linux/device.h>
+#include <linux/platform_device.h>
 #include <linux/input.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
@@ -284,7 +284,7 @@ out:
 
 /* Device model stuff */
 
-static int hdaps_probe(struct device *dev)
+static int hdaps_probe(struct platform_device *dev)
 {
        int ret;
 
@@ -296,19 +296,18 @@ static int hdaps_probe(struct device *dev)
        return 0;
 }
 
-static int hdaps_resume(struct device *dev, u32 level)
+static int hdaps_resume(struct platform_device *dev)
 {
-       if (level == RESUME_ENABLE)
-               return hdaps_device_init();
-       return 0;
+       return hdaps_device_init();
 }
 
-static struct device_driver hdaps_driver = {
-       .name = "hdaps",
-       .bus = &platform_bus_type,
-       .owner = THIS_MODULE,
+static struct platform_driver hdaps_driver = {
        .probe = hdaps_probe,
-       .resume = hdaps_resume
+       .resume = hdaps_resume,
+       .driver = {
+               .name = "hdaps",
+               .owner = THIS_MODULE,
+       },
 };
 
 /* Input class stuff */
@@ -487,24 +486,19 @@ static struct attribute_group hdaps_attribute_group = {
 
 /* Module stuff */
 
-/*
- * XXX: We should be able to return nonzero and halt the detection process.
- * But there is a bug in dmi_check_system() where a nonzero return from the
- * first match will result in a return of failure from dmi_check_system().
- * I fixed this; the patch is 2.6-git.  Once in a released tree, we can make
- * hdaps_dmi_match_invert() return hdaps_dmi_match(), which in turn returns 1.
- */
+/* hdaps_dmi_match - found a match.  return one, short-circuiting the hunt. */
 static int hdaps_dmi_match(struct dmi_system_id *id)
 {
        printk(KERN_INFO "hdaps: %s detected.\n", id->ident);
-       return 0;
+       return 1;
 }
 
+/* hdaps_dmi_match_invert - found an inverted match. */
 static int hdaps_dmi_match_invert(struct dmi_system_id *id)
 {
        hdaps_invert = 1;
        printk(KERN_INFO "hdaps: inverting axis readings.\n");
-       return 0;
+       return hdaps_dmi_match(id);
 }
 
 #define HDAPS_DMI_MATCH_NORMAL(model)  {               \
@@ -534,6 +528,7 @@ static int __init hdaps_init(void)
                HDAPS_DMI_MATCH_INVERT("ThinkPad R50p"),
                HDAPS_DMI_MATCH_NORMAL("ThinkPad R50"),
                HDAPS_DMI_MATCH_NORMAL("ThinkPad R51"),
+               HDAPS_DMI_MATCH_NORMAL("ThinkPad R52"),
                HDAPS_DMI_MATCH_INVERT("ThinkPad T41p"),
                HDAPS_DMI_MATCH_NORMAL("ThinkPad T41"),
                HDAPS_DMI_MATCH_INVERT("ThinkPad T42p"),
@@ -541,6 +536,7 @@ static int __init hdaps_init(void)
                HDAPS_DMI_MATCH_NORMAL("ThinkPad T43"),
                HDAPS_DMI_MATCH_NORMAL("ThinkPad X40"),
                HDAPS_DMI_MATCH_NORMAL("ThinkPad X41 Tablet"),
+               HDAPS_DMI_MATCH_NORMAL("ThinkPad X41"),
                { .ident = NULL }
        };
 
@@ -555,7 +551,7 @@ static int __init hdaps_init(void)
                goto out;
        }
 
-       ret = driver_register(&hdaps_driver);
+       ret = platform_driver_register(&hdaps_driver);
        if (ret)
                goto out_region;
 
@@ -588,7 +584,7 @@ static int __init hdaps_init(void)
 out_device:
        platform_device_unregister(pdev);
 out_driver:
-       driver_unregister(&hdaps_driver);
+       platform_driver_unregister(&hdaps_driver);
 out_region:
        release_region(HDAPS_LOW_PORT, HDAPS_NR_PORTS);
 out:
@@ -602,7 +598,7 @@ static void __exit hdaps_exit(void)
        input_unregister_device(&hdaps_idev);
        sysfs_remove_group(&pdev->dev.kobj, &hdaps_attribute_group);
        platform_device_unregister(pdev);
-       driver_unregister(&hdaps_driver);
+       platform_driver_unregister(&hdaps_driver);
        release_region(HDAPS_LOW_PORT, HDAPS_NR_PORTS);
 
        printk(KERN_INFO "hdaps: driver unloaded.\n");
This page took 0.025133 seconds and 5 git commands to generate.