diff options
Diffstat (limited to 'drivers/ide/ide.c')
-rw-r--r-- | drivers/ide/ide.c | 76 |
1 files changed, 19 insertions, 57 deletions
diff --git a/drivers/ide/ide.c b/drivers/ide/ide.c index 2b8453510e09..d4a6b102a772 100644 --- a/drivers/ide/ide.c +++ b/drivers/ide/ide.c | |||
@@ -50,29 +50,16 @@ | |||
50 | #include <linux/types.h> | 50 | #include <linux/types.h> |
51 | #include <linux/string.h> | 51 | #include <linux/string.h> |
52 | #include <linux/kernel.h> | 52 | #include <linux/kernel.h> |
53 | #include <linux/timer.h> | ||
54 | #include <linux/mm.h> | ||
55 | #include <linux/interrupt.h> | 53 | #include <linux/interrupt.h> |
56 | #include <linux/major.h> | 54 | #include <linux/major.h> |
57 | #include <linux/errno.h> | 55 | #include <linux/errno.h> |
58 | #include <linux/genhd.h> | 56 | #include <linux/genhd.h> |
59 | #include <linux/blkpg.h> | ||
60 | #include <linux/slab.h> | 57 | #include <linux/slab.h> |
61 | #include <linux/init.h> | 58 | #include <linux/init.h> |
62 | #include <linux/pci.h> | 59 | #include <linux/pci.h> |
63 | #include <linux/delay.h> | ||
64 | #include <linux/ide.h> | 60 | #include <linux/ide.h> |
65 | #include <linux/completion.h> | 61 | #include <linux/completion.h> |
66 | #include <linux/reboot.h> | ||
67 | #include <linux/cdrom.h> | ||
68 | #include <linux/seq_file.h> | ||
69 | #include <linux/device.h> | 62 | #include <linux/device.h> |
70 | #include <linux/bitops.h> | ||
71 | |||
72 | #include <asm/byteorder.h> | ||
73 | #include <asm/irq.h> | ||
74 | #include <asm/uaccess.h> | ||
75 | #include <asm/io.h> | ||
76 | 63 | ||
77 | 64 | ||
78 | /* default maximum number of failures */ | 65 | /* default maximum number of failures */ |
@@ -91,8 +78,6 @@ DEFINE_MUTEX(ide_cfg_mtx); | |||
91 | __cacheline_aligned_in_smp DEFINE_SPINLOCK(ide_lock); | 78 | __cacheline_aligned_in_smp DEFINE_SPINLOCK(ide_lock); |
92 | EXPORT_SYMBOL(ide_lock); | 79 | EXPORT_SYMBOL(ide_lock); |
93 | 80 | ||
94 | ide_hwif_t ide_hwifs[MAX_HWIFS]; /* master data repository */ | ||
95 | |||
96 | static void ide_port_init_devices_data(ide_hwif_t *); | 81 | static void ide_port_init_devices_data(ide_hwif_t *); |
97 | 82 | ||
98 | /* | 83 | /* |
@@ -121,7 +106,6 @@ void ide_init_port_data(ide_hwif_t *hwif, unsigned int index) | |||
121 | 106 | ||
122 | ide_port_init_devices_data(hwif); | 107 | ide_port_init_devices_data(hwif); |
123 | } | 108 | } |
124 | EXPORT_SYMBOL_GPL(ide_init_port_data); | ||
125 | 109 | ||
126 | static void ide_port_init_devices_data(ide_hwif_t *hwif) | 110 | static void ide_port_init_devices_data(ide_hwif_t *hwif) |
127 | { | 111 | { |
@@ -150,18 +134,6 @@ static void ide_port_init_devices_data(ide_hwif_t *hwif) | |||
150 | } | 134 | } |
151 | } | 135 | } |
152 | 136 | ||
153 | static void __init init_ide_data (void) | ||
154 | { | ||
155 | unsigned int index; | ||
156 | |||
157 | /* Initialise all interface structures */ | ||
158 | for (index = 0; index < MAX_HWIFS; ++index) { | ||
159 | ide_hwif_t *hwif = &ide_hwifs[index]; | ||
160 | |||
161 | ide_init_port_data(hwif, index); | ||
162 | } | ||
163 | } | ||
164 | |||
165 | void ide_remove_port_from_hwgroup(ide_hwif_t *hwif) | 137 | void ide_remove_port_from_hwgroup(ide_hwif_t *hwif) |
166 | { | 138 | { |
167 | ide_hwgroup_t *hwgroup = hwif->hwgroup; | 139 | ide_hwgroup_t *hwgroup = hwif->hwgroup; |
@@ -312,7 +284,8 @@ void ide_init_port_hw(ide_hwif_t *hwif, hw_regs_t *hw) | |||
312 | memcpy(&hwif->io_ports, &hw->io_ports, sizeof(hwif->io_ports)); | 284 | memcpy(&hwif->io_ports, &hw->io_ports, sizeof(hwif->io_ports)); |
313 | hwif->irq = hw->irq; | 285 | hwif->irq = hw->irq; |
314 | hwif->chipset = hw->chipset; | 286 | hwif->chipset = hw->chipset; |
315 | hwif->gendev.parent = hw->dev; | 287 | hwif->dev = hw->dev; |
288 | hwif->gendev.parent = hw->parent ? hw->parent : hw->dev; | ||
316 | hwif->ack_intr = hw->ack_intr; | 289 | hwif->ack_intr = hw->ack_intr; |
317 | } | 290 | } |
318 | EXPORT_SYMBOL_GPL(ide_init_port_hw); | 291 | EXPORT_SYMBOL_GPL(ide_init_port_hw); |
@@ -556,6 +529,22 @@ static int generic_ide_resume(struct device *dev) | |||
556 | return err; | 529 | return err; |
557 | } | 530 | } |
558 | 531 | ||
532 | static int generic_drive_reset(ide_drive_t *drive) | ||
533 | { | ||
534 | struct request *rq; | ||
535 | int ret = 0; | ||
536 | |||
537 | rq = blk_get_request(drive->queue, READ, __GFP_WAIT); | ||
538 | rq->cmd_type = REQ_TYPE_SPECIAL; | ||
539 | rq->cmd_len = 1; | ||
540 | rq->cmd[0] = REQ_DRIVE_RESET; | ||
541 | rq->cmd_flags |= REQ_SOFTBARRIER; | ||
542 | if (blk_execute_rq(drive->queue, NULL, rq, 1)) | ||
543 | ret = rq->errors; | ||
544 | blk_put_request(rq); | ||
545 | return ret; | ||
546 | } | ||
547 | |||
559 | int generic_ide_ioctl(ide_drive_t *drive, struct file *file, struct block_device *bdev, | 548 | int generic_ide_ioctl(ide_drive_t *drive, struct file *file, struct block_device *bdev, |
560 | unsigned int cmd, unsigned long arg) | 549 | unsigned int cmd, unsigned long arg) |
561 | { | 550 | { |
@@ -630,33 +619,8 @@ int generic_ide_ioctl(ide_drive_t *drive, struct file *file, struct block_device | |||
630 | if (!capable(CAP_SYS_ADMIN)) | 619 | if (!capable(CAP_SYS_ADMIN)) |
631 | return -EACCES; | 620 | return -EACCES; |
632 | 621 | ||
633 | /* | 622 | return generic_drive_reset(drive); |
634 | * Abort the current command on the | ||
635 | * group if there is one, taking | ||
636 | * care not to allow anything else | ||
637 | * to be queued and to die on the | ||
638 | * spot if we miss one somehow | ||
639 | */ | ||
640 | |||
641 | spin_lock_irqsave(&ide_lock, flags); | ||
642 | |||
643 | if (HWGROUP(drive)->resetting) { | ||
644 | spin_unlock_irqrestore(&ide_lock, flags); | ||
645 | return -EBUSY; | ||
646 | } | ||
647 | 623 | ||
648 | ide_abort(drive, "drive reset"); | ||
649 | |||
650 | BUG_ON(HWGROUP(drive)->handler); | ||
651 | |||
652 | /* Ensure nothing gets queued after we | ||
653 | drop the lock. Reset will clear the busy */ | ||
654 | |||
655 | HWGROUP(drive)->busy = 1; | ||
656 | spin_unlock_irqrestore(&ide_lock, flags); | ||
657 | (void) ide_do_reset(drive); | ||
658 | |||
659 | return 0; | ||
660 | case HDIO_GET_BUSSTATE: | 624 | case HDIO_GET_BUSSTATE: |
661 | if (!capable(CAP_SYS_ADMIN)) | 625 | if (!capable(CAP_SYS_ADMIN)) |
662 | return -EACCES; | 626 | return -EACCES; |
@@ -1021,8 +985,6 @@ static int __init ide_init(void) | |||
1021 | goto out_port_class; | 985 | goto out_port_class; |
1022 | } | 986 | } |
1023 | 987 | ||
1024 | init_ide_data(); | ||
1025 | |||
1026 | proc_ide_create(); | 988 | proc_ide_create(); |
1027 | 989 | ||
1028 | return 0; | 990 | return 0; |