]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/ide/ide.c
NR_CPUS: Replace per_cpu(..., smp_processor_id()) with __get_cpu_var
[linux-2.6-omap-h63xx.git] / drivers / ide / ide.c
index e8c88ff2f6b6391406f01c175ec6c32c8181d39d..d4a6b102a77227d29b4052281704f4053700156d 100644 (file)
 #include <linux/types.h>
 #include <linux/string.h>
 #include <linux/kernel.h>
-#include <linux/timer.h>
-#include <linux/mm.h>
 #include <linux/interrupt.h>
 #include <linux/major.h>
 #include <linux/errno.h>
 #include <linux/genhd.h>
-#include <linux/blkpg.h>
 #include <linux/slab.h>
 #include <linux/init.h>
 #include <linux/pci.h>
-#include <linux/delay.h>
 #include <linux/ide.h>
 #include <linux/completion.h>
-#include <linux/reboot.h>
-#include <linux/cdrom.h>
-#include <linux/seq_file.h>
 #include <linux/device.h>
-#include <linux/bitops.h>
-
-#include <asm/byteorder.h>
-#include <asm/irq.h>
-#include <asm/uaccess.h>
-#include <asm/io.h>
 
 
 /* default maximum number of failures */
@@ -87,11 +74,9 @@ static const u8 ide_hwif_to_major[] = { IDE0_MAJOR, IDE1_MAJOR,
                                        IDE8_MAJOR, IDE9_MAJOR };
 
 DEFINE_MUTEX(ide_cfg_mtx);
- __cacheline_aligned_in_smp DEFINE_SPINLOCK(ide_lock);
-
-int noautodma = 0;
 
-ide_hwif_t ide_hwifs[MAX_HWIFS];       /* master data repository */
+__cacheline_aligned_in_smp DEFINE_SPINLOCK(ide_lock);
+EXPORT_SYMBOL(ide_lock);
 
 static void ide_port_init_devices_data(ide_hwif_t *);
 
@@ -121,7 +106,6 @@ void ide_init_port_data(ide_hwif_t *hwif, unsigned int index)
 
        ide_port_init_devices_data(hwif);
 }
-EXPORT_SYMBOL_GPL(ide_init_port_data);
 
 static void ide_port_init_devices_data(ide_hwif_t *hwif)
 {
@@ -136,7 +120,6 @@ static void ide_port_init_devices_data(ide_hwif_t *hwif)
                drive->media                    = ide_disk;
                drive->select.all               = (unit<<4)|0xa0;
                drive->hwif                     = hwif;
-               drive->ctl                      = 0x08;
                drive->ready_stat               = READY_STAT;
                drive->bad_wstat                = BAD_W_STAT;
                drive->special.b.recalibrate    = 1;
@@ -151,18 +134,6 @@ static void ide_port_init_devices_data(ide_hwif_t *hwif)
        }
 }
 
-static void __init init_ide_data (void)
-{
-       unsigned int index;
-
-       /* Initialise all interface structures */
-       for (index = 0; index < MAX_HWIFS; ++index) {
-               ide_hwif_t *hwif = &ide_hwifs[index];
-
-               ide_init_port_data(hwif, index);
-       }
-}
-
 void ide_remove_port_from_hwgroup(ide_hwif_t *hwif)
 {
        ide_hwgroup_t *hwgroup = hwif->hwgroup;
@@ -313,7 +284,8 @@ void ide_init_port_hw(ide_hwif_t *hwif, hw_regs_t *hw)
        memcpy(&hwif->io_ports, &hw->io_ports, sizeof(hwif->io_ports));
        hwif->irq = hw->irq;
        hwif->chipset = hw->chipset;
-       hwif->gendev.parent = hw->dev;
+       hwif->dev = hw->dev;
+       hwif->gendev.parent = hw->parent ? hw->parent : hw->dev;
        hwif->ack_intr = hw->ack_intr;
 }
 EXPORT_SYMBOL_GPL(ide_init_port_hw);
@@ -557,6 +529,22 @@ static int generic_ide_resume(struct device *dev)
        return err;
 }
 
+static int generic_drive_reset(ide_drive_t *drive)
+{
+       struct request *rq;
+       int ret = 0;
+
+       rq = blk_get_request(drive->queue, READ, __GFP_WAIT);
+       rq->cmd_type = REQ_TYPE_SPECIAL;
+       rq->cmd_len = 1;
+       rq->cmd[0] = REQ_DRIVE_RESET;
+       rq->cmd_flags |= REQ_SOFTBARRIER;
+       if (blk_execute_rq(drive->queue, NULL, rq, 1))
+               ret = rq->errors;
+       blk_put_request(rq);
+       return ret;
+}
+
 int generic_ide_ioctl(ide_drive_t *drive, struct file *file, struct block_device *bdev,
                        unsigned int cmd, unsigned long arg)
 {
@@ -631,33 +619,8 @@ int generic_ide_ioctl(ide_drive_t *drive, struct file *file, struct block_device
                        if (!capable(CAP_SYS_ADMIN))
                                return -EACCES;
 
-                       /*
-                        *      Abort the current command on the
-                        *      group if there is one, taking
-                        *      care not to allow anything else
-                        *      to be queued and to die on the
-                        *      spot if we miss one somehow
-                        */
-
-                       spin_lock_irqsave(&ide_lock, flags);
-
-                       if (HWGROUP(drive)->resetting) {
-                               spin_unlock_irqrestore(&ide_lock, flags);
-                               return -EBUSY;
-                       }
-
-                       ide_abort(drive, "drive reset");
-
-                       BUG_ON(HWGROUP(drive)->handler);
+                       return generic_drive_reset(drive);
 
-                       /* Ensure nothing gets queued after we
-                          drop the lock. Reset will clear the busy */
-
-                       HWGROUP(drive)->busy = 1;
-                       spin_unlock_irqrestore(&ide_lock, flags);
-                       (void) ide_do_reset(drive);
-
-                       return 0;
                case HDIO_GET_BUSSTATE:
                        if (!capable(CAP_SYS_ADMIN))
                                return -EACCES;
@@ -698,59 +661,6 @@ set_val:
 
 EXPORT_SYMBOL(generic_ide_ioctl);
 
-/*
- * ide_setup() gets called VERY EARLY during initialization,
- * to handle kernel "command line" strings beginning with "ide".
- *
- * Remember to update Documentation/ide/ide.txt if you change something here.
- */
-static int __init ide_setup(char *s)
-{
-       printk(KERN_INFO "ide_setup: %s", s);
-
-#ifdef CONFIG_BLK_DEV_IDEDOUBLER
-       if (!strcmp(s, "ide=doubler")) {
-               extern int ide_doubler;
-
-               printk(" : Enabled support for IDE doublers\n");
-               ide_doubler = 1;
-               goto obsolete_option;
-       }
-#endif /* CONFIG_BLK_DEV_IDEDOUBLER */
-
-       if (!strcmp(s, "ide=nodma")) {
-               printk(" : Prevented DMA\n");
-               noautodma = 1;
-               goto obsolete_option;
-       }
-
-#ifdef CONFIG_BLK_DEV_IDEACPI
-       if (!strcmp(s, "ide=noacpi")) {
-               //printk(" : Disable IDE ACPI support.\n");
-               ide_noacpi = 1;
-               goto obsolete_option;
-       }
-       if (!strcmp(s, "ide=acpigtf")) {
-               //printk(" : Enable IDE ACPI _GTF support.\n");
-               ide_acpigtf = 1;
-               goto obsolete_option;
-       }
-       if (!strcmp(s, "ide=acpionboot")) {
-               //printk(" : Call IDE ACPI methods on boot.\n");
-               ide_acpionboot = 1;
-               goto obsolete_option;
-       }
-#endif /* CONFIG_BLK_DEV_IDEACPI */
-
-       printk(" -- BAD OPTION\n");
-       return 1;
-obsolete_option:
-       printk(" -- OBSOLETE OPTION, WILL BE REMOVED SOON!\n");
-       return 1;
-}
-
-EXPORT_SYMBOL(ide_lock);
-
 static int ide_bus_match(struct device *dev, struct device_driver *drv)
 {
        return 1;
@@ -1075,8 +985,6 @@ static int __init ide_init(void)
                goto out_port_class;
        }
 
-       init_ide_data();
-
        proc_ide_create();
 
        return 0;
@@ -1087,32 +995,7 @@ out_port_class:
        return ret;
 }
 
-#ifdef MODULE
-static char *options = NULL;
-module_param(options, charp, 0);
-MODULE_LICENSE("GPL");
-
-static void __init parse_options (char *line)
-{
-       char *next = line;
-
-       if (line == NULL || !*line)
-               return;
-       while ((line = next) != NULL) {
-               if ((next = strchr(line,' ')) != NULL)
-                       *next++ = 0;
-               if (!ide_setup(line))
-                       printk (KERN_INFO "Unknown option '%s'\n", line);
-       }
-}
-
-int __init init_module (void)
-{
-       parse_options(options);
-       return ide_init();
-}
-
-void __exit cleanup_module (void)
+static void __exit ide_exit(void)
 {
        proc_ide_destroy();
 
@@ -1121,10 +1004,7 @@ void __exit cleanup_module (void)
        bus_unregister(&ide_bus_type);
 }
 
-#else /* !MODULE */
-
-__setup("", ide_setup);
-
 module_init(ide_init);
+module_exit(ide_exit);
 
-#endif /* MODULE */
+MODULE_LICENSE("GPL");