EDAC, mpc85xx: Implement remove method for the platform driver
authorYanjiang Jin <yanjiang.jin@windriver.com>
Thu, 17 Nov 2016 02:56:20 +0000 (10:56 +0800)
committerBorislav Petkov <bp@suse.de>
Thu, 17 Nov 2016 10:19:50 +0000 (11:19 +0100)
If we execute the below steps without this patch:

  modprobe mpc85xx_edac [The first insmod, everything is well.]
  modprobe -r mpc85xx_edac
  modprobe mpc85xx_edac [insmod again, error happens.]

We would get the error messages as below:

  BUG: recent printk recursion!
  Oops: Kernel access of bad area, sig: 11 [#48]
  Modules linked in: mpc85xx_edac edac_core softdog [last unloaded: mpc85xx_edac]
  CPU: 5 PID: 14773 Comm: modprobe Tainted: G D C 4.8.3-rt2
   .vsnprintf
   .vscnprintf
   .vprintk_emit
   .printk
   .edac_pci_add_device
   .mpc85xx_pci_err_probe
   .platform_drv_probe
   .driver_probe_device
   .__driver_attach
   .bus_for_each_dev
   .driver_attach
   .bus_add_driver
   .driver_register
   .__platform_register_drivers
   .mpc85xx_mc_init
   .do_one_initcall
   .do_init_module
   .load_module
   .SyS_finit_module
   system_call

Address this by cleaning up properly when removing the platform driver.

Tested on a T4240QDS board.

Signed-off-by: Yanjiang Jin <yanjiang.jin@windriver.com>
Acked-by: Johannes Thumshirn <jthumshirn@suse.de>
Cc: linux-edac <linux-edac@vger.kernel.org>
Cc: york.sun@nxp.com
Link: http://lkml.kernel.org/r/1479351380-17109-2-git-send-email-yanjiang.jin@windriver.com
[ Boris: massage commit message. ]
Signed-off-by: Borislav Petkov <bp@suse.de>
drivers/edac/mpc85xx_edac.c

index ff0567526ee3763740bd50e1df86ab80da1fb41b..c62602141f956a6d4afc25bb0714dd82c4b0475c 100644 (file)
@@ -300,6 +300,22 @@ err:
        return res;
 }
 
+static int mpc85xx_pci_err_remove(struct platform_device *op)
+{
+       struct edac_pci_ctl_info *pci = dev_get_drvdata(&op->dev);
+       struct mpc85xx_pci_pdata *pdata = pci->pvt_info;
+
+       edac_dbg(0, "\n");
+
+       out_be32(pdata->pci_vbase + MPC85XX_PCI_ERR_ADDR, orig_pci_err_cap_dr);
+       out_be32(pdata->pci_vbase + MPC85XX_PCI_ERR_EN, orig_pci_err_en);
+
+       edac_pci_del_device(&op->dev);
+       edac_pci_free_ctl_info(pci);
+
+       return 0;
+}
+
 static const struct platform_device_id mpc85xx_pci_err_match[] = {
        {
                .name = "mpc85xx-pci-edac"
@@ -309,6 +325,7 @@ static const struct platform_device_id mpc85xx_pci_err_match[] = {
 
 static struct platform_driver mpc85xx_pci_err_driver = {
        .probe = mpc85xx_pci_err_probe,
+       .remove = mpc85xx_pci_err_remove,
        .id_table = mpc85xx_pci_err_match,
        .driver = {
                .name = "mpc85xx_pci_err",