IDE: Report errors during drive reset back to user space
[pandora-kernel.git] / drivers / ide / ide.c
index 9240888..d4a6b10 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 */
@@ -542,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)
 {
@@ -616,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");
+                       return generic_drive_reset(drive);
 
-                       BUG_ON(HWGROUP(drive)->handler);
-
-                       /* 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;