Patch fixing rmmod -> kernel panic for Peak CAN driver for MPC5200B

Mattias Boström mattias.bostroem at gmail.com
Wed Feb 20 02:18:01 EST 2008


Here is a patch that solves the problem with kernel panic when
removing the peak-linux-driver-3.17 on a MPC5200B. If someone else
apart from us have experienced that.
The patches to peak-linux-driver-3.17 needed to run on MPC5200B are:
peak-linux-driver-3.17-mpc5200.patch (DENX)
peak-linux-driver-3.17-mpc5200-platform_driver.patch (Sylvain Munaut &
MontaVista)

Mattias

diff --exclude CVS -uNr
peak-linux-driver-3.17/driver/src/pcan_mpc5200.c
peak-linux-driver-3.17.modified/driver/src/pcan_mpc5200.c
--- peak-linux-driver-3.17/driver/src/pcan_mpc5200.c    2008-02-19
16:06:54.000000000 +0100
+++ peak-linux-driver-3.17.modified/driver/src/pcan_mpc5200.c
2008-02-19 16:06:46.000000000 +0100
@@ -752,7 +752,16 @@
 {
        DPRINTK(KERN_DEBUG "%s: mgt_mscan_cleanup()\n", DEVICE_NAME);

-       platform_driver_unregister(&mscan_driver);
+       /* In mgt_mscan_init platform_driver_register is called only once
+        * for module 1.
+        * We should only call platform_driver_unregister once and we do it
+        * for module 1 since it is the last module to cleanup.
+        */
+       if (!(dev->port.mscan.module_num-1)) {
+          DPRINTK(KERN_DEBUG "platform_driver_unregister(&mscan_driver)\n");
+          (void) platform_driver_unregister(&mscan_driver);
+       }
+

 #if 0  /* seems like it's been freed already */
        mgt_mscan_free_irq(dev);



More information about the Linuxppc-dev mailing list