rtc: don't use __exit_p to wrap ds1302_rtc_remove
[safe/jmp/linux-2.6] / drivers / misc / ioc4.c
index 1c3c14a..60b0b1a 100644 (file)
@@ -32,6 +32,7 @@
 #include <linux/ktime.h>
 #include <linux/mutex.h>
 #include <linux/time.h>
+#include <asm/io.h>
 
 /***************
  * Definitions *
@@ -74,7 +75,7 @@ ioc4_register_submodule(struct ioc4_submodule *is)
                        printk(KERN_WARNING
                               "%s: IOC4 submodule %s probe failed "
                               "for pci_dev %s",
-                              __FUNCTION__, module_name(is->is_owner),
+                              __func__, module_name(is->is_owner),
                               pci_name(idd->idd_pdev));
                }
        }
@@ -101,7 +102,7 @@ ioc4_unregister_submodule(struct ioc4_submodule *is)
                        printk(KERN_WARNING
                               "%s: IOC4 submodule %s remove failed "
                               "for pci_dev %s.\n",
-                              __FUNCTION__, module_name(is->is_owner),
+                              __func__, module_name(is->is_owner),
                               pci_name(idd->idd_pdev));
                }
        }
@@ -209,8 +210,8 @@ ioc4_clock_calibrate(struct ioc4_driver_data *idd)
 
                do_div(ns, IOC4_EXTINT_COUNT_DIVISOR);
                printk(KERN_DEBUG
-                      "IOC4 %s: PCI clock is %lld ns.\n",
-                      pci_name(idd->idd_pdev), ns);
+                      "IOC4 %s: PCI clock is %llu ns.\n",
+                      pci_name(idd->idd_pdev), (unsigned long long)ns);
        }
 
        /* Remember results.  We store the extint clock period rather
@@ -243,10 +244,11 @@ ioc4_variant(struct ioc4_driver_data *idd)
                    idd->idd_pdev->bus->number == pdev->bus->number &&
                    3 == PCI_SLOT(pdev->devfn))
                        found = 1;
-               pci_dev_put(pdev);
        } while (pdev && !found);
-       if (NULL != pdev)
+       if (NULL != pdev) {
+               pci_dev_put(pdev);
                return IOC4_VARIANT_IO9;
+       }
 
        /* IO10: Look for a Vitesse VSC 7174 at the same bus and slot 3. */
        pdev = NULL;
@@ -257,15 +259,26 @@ ioc4_variant(struct ioc4_driver_data *idd)
                    idd->idd_pdev->bus->number == pdev->bus->number &&
                    3 == PCI_SLOT(pdev->devfn))
                        found = 1;
-               pci_dev_put(pdev);
        } while (pdev && !found);
-       if (NULL != pdev)
+       if (NULL != pdev) {
+               pci_dev_put(pdev);
                return IOC4_VARIANT_IO10;
+       }
 
        /* PCI-RT: No SCSI/SATA controller will be present */
        return IOC4_VARIANT_PCI_RT;
 }
 
+static void
+ioc4_load_modules(struct work_struct *work)
+{
+       /* arg just has to be freed */
+
+       request_module("sgiioc4");
+
+       kfree(work);
+}
+
 /* Adds a new instance of an IOC4 card */
 static int
 ioc4_probe(struct pci_dev *pdev, const struct pci_device_id *pci_id)
@@ -279,7 +292,7 @@ ioc4_probe(struct pci_dev *pdev, const struct pci_device_id *pci_id)
        if ((ret = pci_enable_device(pdev))) {
                printk(KERN_WARNING
                       "%s: Failed to enable IOC4 device for pci_dev %s.\n",
-                      __FUNCTION__, pci_name(pdev));
+                      __func__, pci_name(pdev));
                goto out;
        }
        pci_set_master(pdev);
@@ -289,7 +302,7 @@ ioc4_probe(struct pci_dev *pdev, const struct pci_device_id *pci_id)
        if (!idd) {
                printk(KERN_WARNING
                       "%s: Failed to allocate IOC4 data for pci_dev %s.\n",
-                      __FUNCTION__, pci_name(pdev));
+                      __func__, pci_name(pdev));
                ret = -ENODEV;
                goto out_idd;
        }
@@ -304,16 +317,16 @@ ioc4_probe(struct pci_dev *pdev, const struct pci_device_id *pci_id)
                printk(KERN_WARNING
                       "%s: Unable to find IOC4 misc resource "
                       "for pci_dev %s.\n",
-                      __FUNCTION__, pci_name(idd->idd_pdev));
+                      __func__, pci_name(idd->idd_pdev));
                ret = -ENODEV;
                goto out_pci;
        }
-       if (!request_region(idd->idd_bar0, sizeof(struct ioc4_misc_regs),
+       if (!request_mem_region(idd->idd_bar0, sizeof(struct ioc4_misc_regs),
                            "ioc4_misc")) {
                printk(KERN_WARNING
                       "%s: Unable to request IOC4 misc region "
                       "for pci_dev %s.\n",
-                      __FUNCTION__, pci_name(idd->idd_pdev));
+                      __func__, pci_name(idd->idd_pdev));
                ret = -ENODEV;
                goto out_pci;
        }
@@ -323,7 +336,7 @@ ioc4_probe(struct pci_dev *pdev, const struct pci_device_id *pci_id)
                printk(KERN_WARNING
                       "%s: Unable to remap IOC4 misc region "
                       "for pci_dev %s.\n",
-                      __FUNCTION__, pci_name(idd->idd_pdev));
+                      __func__, pci_name(idd->idd_pdev));
                ret = -ENODEV;
                goto out_misc_region;
        }
@@ -369,16 +382,40 @@ ioc4_probe(struct pci_dev *pdev, const struct pci_device_id *pci_id)
                        printk(KERN_WARNING
                               "%s: IOC4 submodule 0x%s probe failed "
                               "for pci_dev %s.\n",
-                              __FUNCTION__, module_name(is->is_owner),
+                              __func__, module_name(is->is_owner),
                               pci_name(idd->idd_pdev));
                }
        }
        mutex_unlock(&ioc4_mutex);
 
+       /* Request sgiioc4 IDE driver on boards that bring that functionality
+        * off of IOC4.  The root filesystem may be hosted on a drive connected
+        * to IOC4, so we need to make sure the sgiioc4 driver is loaded as it
+        * won't be picked up by modprobes due to the ioc4 module owning the
+        * PCI device.
+        */
+       if (idd->idd_variant != IOC4_VARIANT_PCI_RT) {
+               struct work_struct *work;
+               work = kzalloc(sizeof(struct work_struct), GFP_KERNEL);
+               if (!work) {
+                       printk(KERN_WARNING
+                              "%s: IOC4 unable to allocate memory for "
+                              "load of sub-modules.\n", __func__);
+               } else {
+                       /* Request the module from a work procedure as the
+                        * modprobe goes out to a userland helper and that
+                        * will hang if done directly from ioc4_probe().
+                        */
+                       printk(KERN_INFO "IOC4 loading sgiioc4 submodule\n");
+                       INIT_WORK(work, ioc4_load_modules);
+                       schedule_work(work);
+               }
+       }
+
        return 0;
 
 out_misc_region:
-       release_region(idd->idd_bar0, sizeof(struct ioc4_misc_regs));
+       release_mem_region(idd->idd_bar0, sizeof(struct ioc4_misc_regs));
 out_pci:
        kfree(idd);
 out_idd:
@@ -403,7 +440,7 @@ ioc4_remove(struct pci_dev *pdev)
                        printk(KERN_WARNING
                               "%s: IOC4 submodule 0x%s remove failed "
                               "for pci_dev %s.\n",
-                              __FUNCTION__, module_name(is->is_owner),
+                              __func__, module_name(is->is_owner),
                               pci_name(idd->idd_pdev));
                }
        }
@@ -415,9 +452,9 @@ ioc4_remove(struct pci_dev *pdev)
                printk(KERN_WARNING
                       "%s: Unable to get IOC4 misc mapping for pci_dev %s. "
                       "Device removal may be incomplete.\n",
-                      __FUNCTION__, pci_name(idd->idd_pdev));
+                      __func__, pci_name(idd->idd_pdev));
        }
-       release_region(idd->idd_bar0, sizeof(struct ioc4_misc_regs));
+       release_mem_region(idd->idd_bar0, sizeof(struct ioc4_misc_regs));
 
        /* Disable IOC4 and relinquish */
        pci_disable_device(pdev);
@@ -459,6 +496,8 @@ ioc4_init(void)
 static void __devexit
 ioc4_exit(void)
 {
+       /* Ensure ioc4_load_modules() has completed before exiting */
+       flush_scheduled_work();
        pci_unregister_driver(&ioc4_driver);
 }