[POWERPC] Fix windfarm platform device usage
authorBenjamin Herrenschmidt <benh@kernel.crashing.org>
Tue, 10 Oct 2006 01:47:31 +0000 (11:47 +1000)
committerPaul Mackerras <paulus@samba.org>
Tue, 10 Oct 2006 03:56:13 +0000 (13:56 +1000)
The windfarm code uses a struct device_driver instead of
platform_driver, which can cause crashes if any of the callbacks are
called (like on module removal). This fixes it.

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Paul Mackerras <paulus@samba.org>
drivers/macintosh/windfarm_pm112.c
drivers/macintosh/windfarm_pm81.c
drivers/macintosh/windfarm_pm91.c

index ef66bf2778ecab42565e2da225c368b8af056aee..fa4b13f89369031de1984f5c9be6d3875212df06 100644 (file)
@@ -650,24 +650,26 @@ static struct notifier_block pm112_events = {
        .notifier_call = pm112_wf_notify,
 };
 
-static int wf_pm112_probe(struct device *dev)
+static int wf_pm112_probe(struct platform_device *dev)
 {
        wf_register_client(&pm112_events);
        return 0;
 }
 
-static int wf_pm112_remove(struct device *dev)
+static int __devexit wf_pm112_remove(struct platform_device *dev)
 {
        wf_unregister_client(&pm112_events);
        /* should release all sensors and controls */
        return 0;
 }
 
-static struct device_driver wf_pm112_driver = {
-       .name = "windfarm",
-       .bus = &platform_bus_type,
+static struct platform_driver wf_pm112_driver = {
        .probe = wf_pm112_probe,
-       .remove = wf_pm112_remove,
+       .remove = __devexit_p(wf_pm112_remove),
+       .driver = {
+               .name = "windfarm",
+               .bus = &platform_bus_type,
+       },
 };
 
 static int __init wf_pm112_init(void)
@@ -683,13 +685,13 @@ static int __init wf_pm112_init(void)
                ++nr_cores;
 
        printk(KERN_INFO "windfarm: initializing for dual-core desktop G5\n");
-       driver_register(&wf_pm112_driver);
+       platform_driver_register(&wf_pm112_driver);
        return 0;
 }
 
 static void __exit wf_pm112_exit(void)
 {
-       driver_unregister(&wf_pm112_driver);
+       platform_driver_unregister(&wf_pm112_driver);
 }
 
 module_init(wf_pm112_init);
index 2ff546e4c92f789ad6921c911cbb61f63abe7d61..2a944851b8e10193090f85f4db01c03f820e2207 100644 (file)
 
 static int wf_smu_mach_model;  /* machine model id */
 
-static struct device *wf_smu_dev;
-
 /* Controls & sensors */
 static struct wf_sensor        *sensor_cpu_power;
 static struct wf_sensor        *sensor_cpu_temp;
@@ -717,16 +715,14 @@ static int wf_init_pm(void)
        return 0;
 }
 
-static int wf_smu_probe(struct device *ddev)
+static int wf_smu_probe(struct platform_device *ddev)
 {
-       wf_smu_dev = ddev;
-
        wf_register_client(&wf_smu_events);
 
        return 0;
 }
 
-static int wf_smu_remove(struct device *ddev)
+static int __devexit wf_smu_remove(struct platform_device *ddev)
 {
        wf_unregister_client(&wf_smu_events);
 
@@ -766,16 +762,16 @@ static int wf_smu_remove(struct device *ddev)
        if (wf_smu_cpu_fans)
                kfree(wf_smu_cpu_fans);
 
-       wf_smu_dev = NULL;
-
        return 0;
 }
 
-static struct device_driver wf_smu_driver = {
-        .name = "windfarm",
-        .bus = &platform_bus_type,
+static struct platform_driver wf_smu_driver = {
         .probe = wf_smu_probe,
-        .remove = wf_smu_remove,
+        .remove = __devexit_p(wf_smu_remove),
+       .driver = {
+               .name = "windfarm",
+               .bus = &platform_bus_type,
+       },
 };
 
 
@@ -794,7 +790,7 @@ static int __init wf_smu_init(void)
                request_module("windfarm_lm75_sensor");
 
 #endif /* MODULE */
-               driver_register(&wf_smu_driver);
+               platform_driver_register(&wf_smu_driver);
        }
 
        return rc;
@@ -803,7 +799,7 @@ static int __init wf_smu_init(void)
 static void __exit wf_smu_exit(void)
 {
 
-       driver_unregister(&wf_smu_driver);
+       platform_driver_unregister(&wf_smu_driver);
 }
 
 
index 59e9ffe37c395a57429904399f3c4a930acebb3a..9961a67b4f851333b9c00f952ed60c2e8f881642 100644 (file)
@@ -63,8 +63,6 @@
  */
 #undef HACKED_OVERTEMP
 
-static struct device *wf_smu_dev;
-
 /* Controls & sensors */
 static struct wf_sensor        *sensor_cpu_power;
 static struct wf_sensor        *sensor_cpu_temp;
@@ -641,16 +639,14 @@ static int wf_init_pm(void)
        return 0;
 }
 
-static int wf_smu_probe(struct device *ddev)
+static int wf_smu_probe(struct platform_device *ddev)
 {
-       wf_smu_dev = ddev;
-
        wf_register_client(&wf_smu_events);
 
        return 0;
 }
 
-static int wf_smu_remove(struct device *ddev)
+static int __devexit wf_smu_remove(struct platform_device *ddev)
 {
        wf_unregister_client(&wf_smu_events);
 
@@ -698,16 +694,16 @@ static int wf_smu_remove(struct device *ddev)
        if (wf_smu_cpu_fans)
                kfree(wf_smu_cpu_fans);
 
-       wf_smu_dev = NULL;
-
        return 0;
 }
 
-static struct device_driver wf_smu_driver = {
-        .name = "windfarm",
-        .bus = &platform_bus_type,
+static struct platform_driver wf_smu_driver = {
         .probe = wf_smu_probe,
-        .remove = wf_smu_remove,
+        .remove = __devexit_p(wf_smu_remove),
+       .driver = {
+               .name = "windfarm",
+               .bus = &platform_bus_type,
+       },
 };
 
 
@@ -725,7 +721,7 @@ static int __init wf_smu_init(void)
                request_module("windfarm_lm75_sensor");
 
 #endif /* MODULE */
-               driver_register(&wf_smu_driver);
+               platform_driver_register(&wf_smu_driver);
        }
 
        return rc;
@@ -734,7 +730,7 @@ static int __init wf_smu_init(void)
 static void __exit wf_smu_exit(void)
 {
 
-       driver_unregister(&wf_smu_driver);
+       platform_driver_unregister(&wf_smu_driver);
 }