aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2009-01-06 11:20:50 -0500
committerBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2009-01-06 11:20:50 -0500
commitb65fac32cfe3b2f98cd472fef400bd1c1340de23 (patch)
tree493a7e30e23e5413a9e5ad6102b8e91ebc02c069 /drivers
parent5b31f855f10d0053e738baa6d91fb6a3fad35119 (diff)
ide: merge ide_hwgroup_t with ide_hwif_t (v2)
* Merge ide_hwgroup_t with ide_hwif_t. * Cleanup init_irq() accordingly, then remove no longer needed ide_remove_port_from_hwgroup() and ide_ports[]. * Remove now unused HWGROUP() macro. While at it: * ide_dump_ata_error() fixups v2: * Fix ->quirk_list check in do_ide_request() (s/hwif->cur_dev/prev_port->cur_dev). Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/ide/alim15x3.c2
-rw-r--r--drivers/ide/au1xxx-ide.c6
-rw-r--r--drivers/ide/icside.c2
-rw-r--r--drivers/ide/ide-atapi.c8
-rw-r--r--drivers/ide/ide-cd.c16
-rw-r--r--drivers/ide/ide-dma-sff.c4
-rw-r--r--drivers/ide/ide-dma.c2
-rw-r--r--drivers/ide/ide-floppy.c2
-rw-r--r--drivers/ide/ide-io.c117
-rw-r--r--drivers/ide/ide-iops.c69
-rw-r--r--drivers/ide/ide-lib.c9
-rw-r--r--drivers/ide/ide-park.c16
-rw-r--r--drivers/ide/ide-pm.c2
-rw-r--r--drivers/ide/ide-probe.c87
-rw-r--r--drivers/ide/ide-tape.c9
-rw-r--r--drivers/ide/ide-taskfile.c4
-rw-r--r--drivers/ide/ide.c7
-rw-r--r--drivers/ide/pdc202xx_old.c2
-rw-r--r--drivers/ide/pmac.c2
-rw-r--r--drivers/ide/scc_pata.c4
-rw-r--r--drivers/ide/sgiioc4.c2
-rw-r--r--drivers/ide/tc86c001.c10
-rw-r--r--drivers/ide/trm290.c2
-rw-r--r--drivers/ide/tx4939ide.c2
-rw-r--r--drivers/ide/umc8672.c13
25 files changed, 164 insertions, 235 deletions
diff --git a/drivers/ide/alim15x3.c b/drivers/ide/alim15x3.c
index 45d2356bb725..290204e89eaf 100644
--- a/drivers/ide/alim15x3.c
+++ b/drivers/ide/alim15x3.c
@@ -198,7 +198,7 @@ static void ali_set_dma_mode(ide_drive_t *drive, const u8 speed)
198static int ali15x3_dma_setup(ide_drive_t *drive) 198static int ali15x3_dma_setup(ide_drive_t *drive)
199{ 199{
200 if (m5229_revision < 0xC2 && drive->media != ide_disk) { 200 if (m5229_revision < 0xC2 && drive->media != ide_disk) {
201 if (rq_data_dir(drive->hwif->hwgroup->rq)) 201 if (rq_data_dir(drive->hwif->rq))
202 return 1; /* try PIO instead of DMA */ 202 return 1; /* try PIO instead of DMA */
203 } 203 }
204 return ide_dma_setup(drive); 204 return ide_dma_setup(drive);
diff --git a/drivers/ide/au1xxx-ide.c b/drivers/ide/au1xxx-ide.c
index 0ec8fd1e4dcb..db412bc772d1 100644
--- a/drivers/ide/au1xxx-ide.c
+++ b/drivers/ide/au1xxx-ide.c
@@ -213,7 +213,7 @@ static int auide_build_dmatable(ide_drive_t *drive)
213{ 213{
214 int i, iswrite, count = 0; 214 int i, iswrite, count = 0;
215 ide_hwif_t *hwif = HWIF(drive); 215 ide_hwif_t *hwif = HWIF(drive);
216 struct request *rq = HWGROUP(drive)->rq; 216 struct request *rq = hwif->rq;
217 _auide_hwif *ahwif = &auide_hwif; 217 _auide_hwif *ahwif = &auide_hwif;
218 struct scatterlist *sg; 218 struct scatterlist *sg;
219 219
@@ -309,8 +309,8 @@ static void auide_dma_exec_cmd(ide_drive_t *drive, u8 command)
309} 309}
310 310
311static int auide_dma_setup(ide_drive_t *drive) 311static int auide_dma_setup(ide_drive_t *drive)
312{ 312{
313 struct request *rq = HWGROUP(drive)->rq; 313 struct request *rq = drive->hwif->rq;
314 314
315 if (!auide_build_dmatable(drive)) { 315 if (!auide_build_dmatable(drive)) {
316 ide_map_sg(drive, rq); 316 ide_map_sg(drive, rq);
diff --git a/drivers/ide/icside.c b/drivers/ide/icside.c
index 81f70caeb40f..72d95c99f147 100644
--- a/drivers/ide/icside.c
+++ b/drivers/ide/icside.c
@@ -312,7 +312,7 @@ static int icside_dma_setup(ide_drive_t *drive)
312 ide_hwif_t *hwif = HWIF(drive); 312 ide_hwif_t *hwif = HWIF(drive);
313 struct expansion_card *ec = ECARD_DEV(hwif->dev); 313 struct expansion_card *ec = ECARD_DEV(hwif->dev);
314 struct icside_state *state = ecard_get_drvdata(ec); 314 struct icside_state *state = ecard_get_drvdata(ec);
315 struct request *rq = hwif->hwgroup->rq; 315 struct request *rq = hwif->rq;
316 unsigned int dma_mode; 316 unsigned int dma_mode;
317 317
318 if (rq_data_dir(rq)) 318 if (rq_data_dir(rq))
diff --git a/drivers/ide/ide-atapi.c b/drivers/ide/ide-atapi.c
index e8688c0f8645..d6a50d67b7db 100644
--- a/drivers/ide/ide-atapi.c
+++ b/drivers/ide/ide-atapi.c
@@ -243,7 +243,7 @@ EXPORT_SYMBOL_GPL(ide_retry_pc);
243 243
244int ide_cd_expiry(ide_drive_t *drive) 244int ide_cd_expiry(ide_drive_t *drive)
245{ 245{
246 struct request *rq = HWGROUP(drive)->rq; 246 struct request *rq = drive->hwif->rq;
247 unsigned long wait = 0; 247 unsigned long wait = 0;
248 248
249 debug_log("%s: rq->cmd[0]: 0x%x\n", __func__, rq->cmd[0]); 249 debug_log("%s: rq->cmd[0]: 0x%x\n", __func__, rq->cmd[0]);
@@ -294,7 +294,7 @@ static ide_startstop_t ide_pc_intr(ide_drive_t *drive)
294{ 294{
295 struct ide_atapi_pc *pc = drive->pc; 295 struct ide_atapi_pc *pc = drive->pc;
296 ide_hwif_t *hwif = drive->hwif; 296 ide_hwif_t *hwif = drive->hwif;
297 struct request *rq = hwif->hwgroup->rq; 297 struct request *rq = hwif->rq;
298 const struct ide_tp_ops *tp_ops = hwif->tp_ops; 298 const struct ide_tp_ops *tp_ops = hwif->tp_ops;
299 xfer_func_t *xferfunc; 299 xfer_func_t *xferfunc;
300 unsigned int timeout, temp; 300 unsigned int timeout, temp;
@@ -491,7 +491,7 @@ static ide_startstop_t ide_transfer_pc(ide_drive_t *drive)
491{ 491{
492 struct ide_atapi_pc *uninitialized_var(pc); 492 struct ide_atapi_pc *uninitialized_var(pc);
493 ide_hwif_t *hwif = drive->hwif; 493 ide_hwif_t *hwif = drive->hwif;
494 struct request *rq = hwif->hwgroup->rq; 494 struct request *rq = hwif->rq;
495 ide_expiry_t *expiry; 495 ide_expiry_t *expiry;
496 unsigned int timeout; 496 unsigned int timeout;
497 int cmd_len; 497 int cmd_len;
@@ -580,7 +580,7 @@ ide_startstop_t ide_issue_pc(ide_drive_t *drive)
580 580
581 if (dev_is_idecd(drive)) { 581 if (dev_is_idecd(drive)) {
582 tf_flags = IDE_TFLAG_OUT_NSECT | IDE_TFLAG_OUT_LBAL; 582 tf_flags = IDE_TFLAG_OUT_NSECT | IDE_TFLAG_OUT_LBAL;
583 bcount = ide_cd_get_xferlen(hwif->hwgroup->rq); 583 bcount = ide_cd_get_xferlen(hwif->rq);
584 expiry = ide_cd_expiry; 584 expiry = ide_cd_expiry;
585 timeout = ATAPI_WAIT_PC; 585 timeout = ATAPI_WAIT_PC;
586 586
diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c
index 1a7410f88249..c35b64d495f5 100644
--- a/drivers/ide/ide-cd.c
+++ b/drivers/ide/ide-cd.c
@@ -239,7 +239,7 @@ static void cdrom_queue_request_sense(ide_drive_t *drive, void *sense,
239 239
240static void cdrom_end_request(ide_drive_t *drive, int uptodate) 240static void cdrom_end_request(ide_drive_t *drive, int uptodate)
241{ 241{
242 struct request *rq = HWGROUP(drive)->rq; 242 struct request *rq = drive->hwif->rq;
243 int nsectors = rq->hard_cur_sectors; 243 int nsectors = rq->hard_cur_sectors;
244 244
245 ide_debug_log(IDE_DBG_FUNC, "Call %s, cmd: 0x%x, uptodate: 0x%x, " 245 ide_debug_log(IDE_DBG_FUNC, "Call %s, cmd: 0x%x, uptodate: 0x%x, "
@@ -306,8 +306,7 @@ static void ide_dump_status_no_sense(ide_drive_t *drive, const char *msg, u8 st)
306static int cdrom_decode_status(ide_drive_t *drive, int good_stat, int *stat_ret) 306static int cdrom_decode_status(ide_drive_t *drive, int good_stat, int *stat_ret)
307{ 307{
308 ide_hwif_t *hwif = drive->hwif; 308 ide_hwif_t *hwif = drive->hwif;
309 ide_hwgroup_t *hwgroup = hwif->hwgroup; 309 struct request *rq = hwif->rq;
310 struct request *rq = hwgroup->rq;
311 int stat, err, sense_key; 310 int stat, err, sense_key;
312 311
313 /* check for errors */ 312 /* check for errors */
@@ -502,7 +501,7 @@ end_request:
502 blkdev_dequeue_request(rq); 501 blkdev_dequeue_request(rq);
503 spin_unlock_irqrestore(q->queue_lock, flags); 502 spin_unlock_irqrestore(q->queue_lock, flags);
504 503
505 hwgroup->rq = NULL; 504 hwif->rq = NULL;
506 505
507 cdrom_queue_request_sense(drive, rq->sense, rq); 506 cdrom_queue_request_sense(drive, rq->sense, rq);
508 } else 507 } else
@@ -525,7 +524,7 @@ static ide_startstop_t cdrom_newpc_intr(ide_drive_t *);
525static ide_startstop_t cdrom_start_packet_command(ide_drive_t *drive) 524static ide_startstop_t cdrom_start_packet_command(ide_drive_t *drive)
526{ 525{
527 ide_hwif_t *hwif = drive->hwif; 526 ide_hwif_t *hwif = drive->hwif;
528 struct request *rq = hwif->hwgroup->rq; 527 struct request *rq = hwif->rq;
529 int xferlen; 528 int xferlen;
530 529
531 xferlen = ide_cd_get_xferlen(rq); 530 xferlen = ide_cd_get_xferlen(rq);
@@ -567,7 +566,7 @@ static ide_startstop_t cdrom_start_packet_command(ide_drive_t *drive)
567static ide_startstop_t cdrom_transfer_packet_command(ide_drive_t *drive) 566static ide_startstop_t cdrom_transfer_packet_command(ide_drive_t *drive)
568{ 567{
569 ide_hwif_t *hwif = drive->hwif; 568 ide_hwif_t *hwif = drive->hwif;
570 struct request *rq = hwif->hwgroup->rq; 569 struct request *rq = hwif->rq;
571 int cmd_len; 570 int cmd_len;
572 ide_startstop_t startstop; 571 ide_startstop_t startstop;
573 572
@@ -854,8 +853,7 @@ static int cdrom_newpc_intr_dummy_cb(struct request *rq)
854static ide_startstop_t cdrom_newpc_intr(ide_drive_t *drive) 853static ide_startstop_t cdrom_newpc_intr(ide_drive_t *drive)
855{ 854{
856 ide_hwif_t *hwif = drive->hwif; 855 ide_hwif_t *hwif = drive->hwif;
857 ide_hwgroup_t *hwgroup = hwif->hwgroup; 856 struct request *rq = hwif->rq;
858 struct request *rq = hwgroup->rq;
859 xfer_func_t *xferfunc; 857 xfer_func_t *xferfunc;
860 ide_expiry_t *expiry = NULL; 858 ide_expiry_t *expiry = NULL;
861 int dma_error = 0, dma, stat, thislen, uptodate = 0; 859 int dma_error = 0, dma, stat, thislen, uptodate = 0;
@@ -1061,7 +1059,7 @@ end_request:
1061 if (blk_end_request(rq, 0, dlen)) 1059 if (blk_end_request(rq, 0, dlen))
1062 BUG(); 1060 BUG();
1063 1061
1064 hwgroup->rq = NULL; 1062 hwif->rq = NULL;
1065 } else { 1063 } else {
1066 if (!uptodate) 1064 if (!uptodate)
1067 rq->cmd_flags |= REQ_FAILED; 1065 rq->cmd_flags |= REQ_FAILED;
diff --git a/drivers/ide/ide-dma-sff.c b/drivers/ide/ide-dma-sff.c
index f6d2d44d8a9a..623a82d1535d 100644
--- a/drivers/ide/ide-dma-sff.c
+++ b/drivers/ide/ide-dma-sff.c
@@ -175,7 +175,7 @@ EXPORT_SYMBOL_GPL(ide_build_dmatable);
175int ide_dma_setup(ide_drive_t *drive) 175int ide_dma_setup(ide_drive_t *drive)
176{ 176{
177 ide_hwif_t *hwif = drive->hwif; 177 ide_hwif_t *hwif = drive->hwif;
178 struct request *rq = hwif->hwgroup->rq; 178 struct request *rq = hwif->rq;
179 unsigned int reading = rq_data_dir(rq) ? 0 : ATA_DMA_WR; 179 unsigned int reading = rq_data_dir(rq) ? 0 : ATA_DMA_WR;
180 u8 mmio = (hwif->host_flags & IDE_HFLAG_MMIO) ? 1 : 0; 180 u8 mmio = (hwif->host_flags & IDE_HFLAG_MMIO) ? 1 : 0;
181 u8 dma_stat; 181 u8 dma_stat;
@@ -240,7 +240,7 @@ static int dma_timer_expiry(ide_drive_t *drive)
240 if ((dma_stat & 0x18) == 0x18) /* BUSY Stupid Early Timer !! */ 240 if ((dma_stat & 0x18) == 0x18) /* BUSY Stupid Early Timer !! */
241 return WAIT_CMD; 241 return WAIT_CMD;
242 242
243 hwif->hwgroup->expiry = NULL; /* one free ride for now */ 243 hwif->expiry = NULL; /* one free ride for now */
244 244
245 if (dma_stat & ATA_DMA_ERR) /* ERROR */ 245 if (dma_stat & ATA_DMA_ERR) /* ERROR */
246 return -1; 246 return -1;
diff --git a/drivers/ide/ide-dma.c b/drivers/ide/ide-dma.c
index fffd11717b2d..72ebab0bc755 100644
--- a/drivers/ide/ide-dma.c
+++ b/drivers/ide/ide-dma.c
@@ -96,7 +96,7 @@ ide_startstop_t ide_dma_intr(ide_drive_t *drive)
96 96
97 if (OK_STAT(stat, DRIVE_READY, drive->bad_wstat | ATA_DRQ)) { 97 if (OK_STAT(stat, DRIVE_READY, drive->bad_wstat | ATA_DRQ)) {
98 if (!dma_stat) { 98 if (!dma_stat) {
99 struct request *rq = hwif->hwgroup->rq; 99 struct request *rq = hwif->rq;
100 100
101 task_end_request(drive, rq, stat); 101 task_end_request(drive, rq, stat);
102 return ide_stopped; 102 return ide_stopped;
diff --git a/drivers/ide/ide-floppy.c b/drivers/ide/ide-floppy.c
index 0a48e2dc53a2..3eab1c6c9b31 100644
--- a/drivers/ide/ide-floppy.c
+++ b/drivers/ide/ide-floppy.c
@@ -71,7 +71,7 @@
71static int ide_floppy_end_request(ide_drive_t *drive, int uptodate, int nsecs) 71static int ide_floppy_end_request(ide_drive_t *drive, int uptodate, int nsecs)
72{ 72{
73 struct ide_disk_obj *floppy = drive->driver_data; 73 struct ide_disk_obj *floppy = drive->driver_data;
74 struct request *rq = HWGROUP(drive)->rq; 74 struct request *rq = drive->hwif->rq;
75 int error; 75 int error;
76 76
77 ide_debug_log(IDE_DBG_FUNC, "Call %s\n", __func__); 77 ide_debug_log(IDE_DBG_FUNC, "Call %s\n", __func__);
diff --git a/drivers/ide/ide-io.c b/drivers/ide/ide-io.c
index 8f371821c614..6ff82d7055b9 100644
--- a/drivers/ide/ide-io.c
+++ b/drivers/ide/ide-io.c
@@ -88,7 +88,7 @@ static int __ide_end_request(ide_drive_t *drive, struct request *rq,
88 ret = 0; 88 ret = 0;
89 89
90 if (ret == 0 && dequeue) 90 if (ret == 0 && dequeue)
91 drive->hwif->hwgroup->rq = NULL; 91 drive->hwif->rq = NULL;
92 92
93 return ret; 93 return ret;
94} 94}
@@ -107,7 +107,7 @@ static int __ide_end_request(ide_drive_t *drive, struct request *rq,
107int ide_end_request (ide_drive_t *drive, int uptodate, int nr_sectors) 107int ide_end_request (ide_drive_t *drive, int uptodate, int nr_sectors)
108{ 108{
109 unsigned int nr_bytes = nr_sectors << 9; 109 unsigned int nr_bytes = nr_sectors << 9;
110 struct request *rq = drive->hwif->hwgroup->rq; 110 struct request *rq = drive->hwif->rq;
111 111
112 if (!nr_bytes) { 112 if (!nr_bytes) {
113 if (blk_pc_request(rq)) 113 if (blk_pc_request(rq))
@@ -160,8 +160,8 @@ EXPORT_SYMBOL_GPL(ide_end_dequeued_request);
160 160
161void ide_end_drive_cmd (ide_drive_t *drive, u8 stat, u8 err) 161void ide_end_drive_cmd (ide_drive_t *drive, u8 stat, u8 err)
162{ 162{
163 ide_hwgroup_t *hwgroup = drive->hwif->hwgroup; 163 ide_hwif_t *hwif = drive->hwif;
164 struct request *rq = hwgroup->rq; 164 struct request *rq = hwif->rq;
165 165
166 if (rq->cmd_type == REQ_TYPE_ATA_TASKFILE) { 166 if (rq->cmd_type == REQ_TYPE_ATA_TASKFILE) {
167 ide_task_t *task = (ide_task_t *)rq->special; 167 ide_task_t *task = (ide_task_t *)rq->special;
@@ -186,7 +186,7 @@ void ide_end_drive_cmd (ide_drive_t *drive, u8 stat, u8 err)
186 return; 186 return;
187 } 187 }
188 188
189 hwgroup->rq = NULL; 189 hwif->rq = NULL;
190 190
191 rq->errors = err; 191 rq->errors = err;
192 192
@@ -321,7 +321,8 @@ ide_startstop_t ide_error (ide_drive_t *drive, const char *msg, u8 stat)
321 321
322 err = ide_dump_status(drive, msg, stat); 322 err = ide_dump_status(drive, msg, stat);
323 323
324 if ((rq = HWGROUP(drive)->rq) == NULL) 324 rq = drive->hwif->rq;
325 if (rq == NULL)
325 return ide_stopped; 326 return ide_stopped;
326 327
327 /* retry only "normal" I/O: */ 328 /* retry only "normal" I/O: */
@@ -654,7 +655,7 @@ kill_rq:
654 * @timeout: time to stall for (jiffies) 655 * @timeout: time to stall for (jiffies)
655 * 656 *
656 * ide_stall_queue() can be used by a drive to give excess bandwidth back 657 * ide_stall_queue() can be used by a drive to give excess bandwidth back
657 * to the hwgroup by sleeping for timeout jiffies. 658 * to the port by sleeping for timeout jiffies.
658 */ 659 */
659 660
660void ide_stall_queue (ide_drive_t *drive, unsigned long timeout) 661void ide_stall_queue (ide_drive_t *drive, unsigned long timeout)
@@ -705,14 +706,13 @@ static inline void ide_unlock_host(struct ide_host *host)
705} 706}
706 707
707/* 708/*
708 * Issue a new request to a drive from hwgroup 709 * Issue a new request to a device.
709 */ 710 */
710void do_ide_request(struct request_queue *q) 711void do_ide_request(struct request_queue *q)
711{ 712{
712 ide_drive_t *drive = q->queuedata; 713 ide_drive_t *drive = q->queuedata;
713 ide_hwif_t *hwif = drive->hwif; 714 ide_hwif_t *hwif = drive->hwif;
714 struct ide_host *host = hwif->host; 715 struct ide_host *host = hwif->host;
715 ide_hwgroup_t *hwgroup = hwif->hwgroup;
716 struct request *rq = NULL; 716 struct request *rq = NULL;
717 ide_startstop_t startstop; 717 ide_startstop_t startstop;
718 718
@@ -734,13 +734,13 @@ void do_ide_request(struct request_queue *q)
734 if (ide_lock_host(host, hwif)) 734 if (ide_lock_host(host, hwif))
735 goto plug_device_2; 735 goto plug_device_2;
736 736
737 spin_lock_irq(&hwgroup->lock); 737 spin_lock_irq(&hwif->lock);
738 738
739 if (!ide_lock_port(hwif)) { 739 if (!ide_lock_port(hwif)) {
740 ide_hwif_t *prev_port; 740 ide_hwif_t *prev_port;
741repeat: 741repeat:
742 prev_port = hwif->host->cur_port; 742 prev_port = hwif->host->cur_port;
743 hwgroup->rq = NULL; 743 hwif->rq = NULL;
744 744
745 if (drive->dev_flags & IDE_DFLAG_SLEEPING) { 745 if (drive->dev_flags & IDE_DFLAG_SLEEPING) {
746 if (time_before(drive->sleep, jiffies)) { 746 if (time_before(drive->sleep, jiffies)) {
@@ -755,15 +755,15 @@ repeat:
755 * set nIEN for previous port, drives in the 755 * set nIEN for previous port, drives in the
756 * quirk_list may not like intr setups/cleanups 756 * quirk_list may not like intr setups/cleanups
757 */ 757 */
758 if (prev_port && hwgroup->cur_dev->quirk_list == 0) 758 if (prev_port && prev_port->cur_dev->quirk_list == 0)
759 prev_port->tp_ops->set_irq(prev_port, 0); 759 prev_port->tp_ops->set_irq(prev_port, 0);
760 760
761 hwif->host->cur_port = hwif; 761 hwif->host->cur_port = hwif;
762 } 762 }
763 hwgroup->cur_dev = drive; 763 hwif->cur_dev = drive;
764 drive->dev_flags &= ~(IDE_DFLAG_SLEEPING | IDE_DFLAG_PARKED); 764 drive->dev_flags &= ~(IDE_DFLAG_SLEEPING | IDE_DFLAG_PARKED);
765 765
766 spin_unlock_irq(&hwgroup->lock); 766 spin_unlock_irq(&hwif->lock);
767 spin_lock_irq(q->queue_lock); 767 spin_lock_irq(q->queue_lock);
768 /* 768 /*
769 * we know that the queue isn't empty, but this can happen 769 * we know that the queue isn't empty, but this can happen
@@ -771,7 +771,7 @@ repeat:
771 */ 771 */
772 rq = elv_next_request(drive->queue); 772 rq = elv_next_request(drive->queue);
773 spin_unlock_irq(q->queue_lock); 773 spin_unlock_irq(q->queue_lock);
774 spin_lock_irq(&hwgroup->lock); 774 spin_lock_irq(&hwif->lock);
775 775
776 if (!rq) { 776 if (!rq) {
777 ide_unlock_port(hwif); 777 ide_unlock_port(hwif);
@@ -799,25 +799,25 @@ repeat:
799 goto plug_device; 799 goto plug_device;
800 } 800 }
801 801
802 hwgroup->rq = rq; 802 hwif->rq = rq;
803 803
804 spin_unlock_irq(&hwgroup->lock); 804 spin_unlock_irq(&hwif->lock);
805 startstop = start_request(drive, rq); 805 startstop = start_request(drive, rq);
806 spin_lock_irq(&hwgroup->lock); 806 spin_lock_irq(&hwif->lock);
807 807
808 if (startstop == ide_stopped) 808 if (startstop == ide_stopped)
809 goto repeat; 809 goto repeat;
810 } else 810 } else
811 goto plug_device; 811 goto plug_device;
812out: 812out:
813 spin_unlock_irq(&hwgroup->lock); 813 spin_unlock_irq(&hwif->lock);
814 if (rq == NULL) 814 if (rq == NULL)
815 ide_unlock_host(host); 815 ide_unlock_host(host);
816 spin_lock_irq(q->queue_lock); 816 spin_lock_irq(q->queue_lock);
817 return; 817 return;
818 818
819plug_device: 819plug_device:
820 spin_unlock_irq(&hwgroup->lock); 820 spin_unlock_irq(&hwif->lock);
821 ide_unlock_host(host); 821 ide_unlock_host(host);
822plug_device_2: 822plug_device_2:
823 spin_lock_irq(q->queue_lock); 823 spin_lock_irq(q->queue_lock);
@@ -827,7 +827,7 @@ plug_device_2:
827} 827}
828 828
829/* 829/*
830 * un-busy the hwgroup etc, and clear any pending DMA status. we want to 830 * un-busy the port etc, and clear any pending DMA status. we want to
831 * retry the current request in pio mode instead of risking tossing it 831 * retry the current request in pio mode instead of risking tossing it
832 * all away 832 * all away
833 */ 833 */
@@ -864,12 +864,11 @@ static ide_startstop_t ide_dma_timeout_retry(ide_drive_t *drive, int error)
864 * un-busy drive etc and make sure request is sane 864 * un-busy drive etc and make sure request is sane
865 */ 865 */
866 866
867 rq = HWGROUP(drive)->rq; 867 rq = hwif->rq;
868
869 if (!rq) 868 if (!rq)
870 goto out; 869 goto out;
871 870
872 HWGROUP(drive)->rq = NULL; 871 hwif->rq = NULL;
873 872
874 rq->errors = 0; 873 rq->errors = 0;
875 874
@@ -897,7 +896,7 @@ static void ide_plug_device(ide_drive_t *drive)
897 896
898/** 897/**
899 * ide_timer_expiry - handle lack of an IDE interrupt 898 * ide_timer_expiry - handle lack of an IDE interrupt
900 * @data: timer callback magic (hwgroup) 899 * @data: timer callback magic (hwif)
901 * 900 *
902 * An IDE command has timed out before the expected drive return 901 * An IDE command has timed out before the expected drive return
903 * occurred. At this point we attempt to clean up the current 902 * occurred. At this point we attempt to clean up the current
@@ -911,19 +910,18 @@ static void ide_plug_device(ide_drive_t *drive)
911 910
912void ide_timer_expiry (unsigned long data) 911void ide_timer_expiry (unsigned long data)
913{ 912{
914 ide_hwgroup_t *hwgroup = (ide_hwgroup_t *) data; 913 ide_hwif_t *hwif = (ide_hwif_t *)data;
915 ide_hwif_t *uninitialized_var(hwif);
916 ide_drive_t *uninitialized_var(drive); 914 ide_drive_t *uninitialized_var(drive);
917 ide_handler_t *handler; 915 ide_handler_t *handler;
918 ide_expiry_t *expiry;
919 unsigned long flags; 916 unsigned long flags;
920 unsigned long wait = -1; 917 unsigned long wait = -1;
921 int plug_device = 0; 918 int plug_device = 0;
922 919
923 spin_lock_irqsave(&hwgroup->lock, flags); 920 spin_lock_irqsave(&hwif->lock, flags);
921
922 handler = hwif->handler;
924 923
925 if (((handler = hwgroup->handler) == NULL) || 924 if (handler == NULL || hwif->req_gen != hwif->req_gen_timer) {
926 (hwgroup->req_gen != hwgroup->req_gen_timer)) {
927 /* 925 /*
928 * Either a marginal timeout occurred 926 * Either a marginal timeout occurred
929 * (got the interrupt just as timer expired), 927 * (got the interrupt just as timer expired),
@@ -931,38 +929,39 @@ void ide_timer_expiry (unsigned long data)
931 * Either way, we don't really want to complain about anything. 929 * Either way, we don't really want to complain about anything.
932 */ 930 */
933 } else { 931 } else {
934 drive = hwgroup->cur_dev; 932 drive = hwif->cur_dev;
935 if (!drive) { 933 if (!drive) {
936 printk(KERN_ERR "%s: ->cur_dev was NULL\n", __func__); 934 printk(KERN_ERR "%s: ->cur_dev was NULL\n", __func__);
937 hwgroup->handler = NULL; 935 hwif->handler = NULL;
938 } else { 936 } else {
937 ide_expiry_t *expiry = hwif->expiry;
939 ide_startstop_t startstop = ide_stopped; 938 ide_startstop_t startstop = ide_stopped;
940 939
941 if ((expiry = hwgroup->expiry) != NULL) { 940 if (expiry) {
942 /* continue */ 941 /* continue */
943 if ((wait = expiry(drive)) > 0) { 942 if ((wait = expiry(drive)) > 0) {
944 /* reset timer */ 943 /* reset timer */
945 hwgroup->timer.expires = jiffies + wait; 944 hwif->timer.expires = jiffies + wait;
946 hwgroup->req_gen_timer = hwgroup->req_gen; 945 hwif->req_gen_timer = hwif->req_gen;
947 add_timer(&hwgroup->timer); 946 add_timer(&hwif->timer);
948 spin_unlock_irqrestore(&hwgroup->lock, flags); 947 spin_unlock_irqrestore(&hwif->lock, flags);
949 return; 948 return;
950 } 949 }
951 } 950 }
952 hwgroup->handler = NULL; 951 hwif->handler = NULL;
953 /* 952 /*
954 * We need to simulate a real interrupt when invoking 953 * We need to simulate a real interrupt when invoking
955 * the handler() function, which means we need to 954 * the handler() function, which means we need to
956 * globally mask the specific IRQ: 955 * globally mask the specific IRQ:
957 */ 956 */
958 spin_unlock(&hwgroup->lock); 957 spin_unlock(&hwif->lock);
959 hwif = HWIF(drive); 958 hwif = HWIF(drive);
960 /* disable_irq_nosync ?? */ 959 /* disable_irq_nosync ?? */
961 disable_irq(hwif->irq); 960 disable_irq(hwif->irq);
962 /* local CPU only, 961 /* local CPU only,
963 * as if we were handling an interrupt */ 962 * as if we were handling an interrupt */
964 local_irq_disable(); 963 local_irq_disable();
965 if (hwgroup->polling) { 964 if (hwif->polling) {
966 startstop = handler(drive); 965 startstop = handler(drive);
967 } else if (drive_is_ready(drive)) { 966 } else if (drive_is_ready(drive)) {
968 if (drive->waiting_for_dma) 967 if (drive->waiting_for_dma)
@@ -978,7 +977,7 @@ void ide_timer_expiry (unsigned long data)
978 ide_error(drive, "irq timeout", 977 ide_error(drive, "irq timeout",
979 hwif->tp_ops->read_status(hwif)); 978 hwif->tp_ops->read_status(hwif));
980 } 979 }
981 spin_lock_irq(&hwgroup->lock); 980 spin_lock_irq(&hwif->lock);
982 enable_irq(hwif->irq); 981 enable_irq(hwif->irq);
983 if (startstop == ide_stopped) { 982 if (startstop == ide_stopped) {
984 ide_unlock_port(hwif); 983 ide_unlock_port(hwif);
@@ -986,7 +985,7 @@ void ide_timer_expiry (unsigned long data)
986 } 985 }
987 } 986 }
988 } 987 }
989 spin_unlock_irqrestore(&hwgroup->lock, flags); 988 spin_unlock_irqrestore(&hwif->lock, flags);
990 989
991 if (plug_device) { 990 if (plug_device) {
992 ide_unlock_host(hwif->host); 991 ide_unlock_host(hwif->host);
@@ -1052,7 +1051,7 @@ static void unexpected_intr(int irq, ide_hwif_t *hwif)
1052 * places 1051 * places
1053 * 1052 *
1054 * hwif is the interface in the group currently performing 1053 * hwif is the interface in the group currently performing
1055 * a command. hwgroup->cur_dev is the drive and hwgroup->handler is 1054 * a command. hwif->cur_dev is the drive and hwif->handler is
1056 * the IRQ handler to call. As we issue a command the handlers 1055 * the IRQ handler to call. As we issue a command the handlers
1057 * step through multiple states, reassigning the handler to the 1056 * step through multiple states, reassigning the handler to the
1058 * next step in the process. Unlike a smart SCSI controller IDE 1057 * next step in the process. Unlike a smart SCSI controller IDE
@@ -1063,13 +1062,12 @@ static void unexpected_intr(int irq, ide_hwif_t *hwif)
1063 * 1062 *
1064 * The handler eventually returns ide_stopped to indicate the 1063 * The handler eventually returns ide_stopped to indicate the
1065 * request completed. At this point we issue the next request 1064 * request completed. At this point we issue the next request
1066 * on the hwgroup and the process begins again. 1065 * on the port and the process begins again.
1067 */ 1066 */
1068 1067
1069irqreturn_t ide_intr (int irq, void *dev_id) 1068irqreturn_t ide_intr (int irq, void *dev_id)
1070{ 1069{
1071 ide_hwif_t *hwif = (ide_hwif_t *)dev_id; 1070 ide_hwif_t *hwif = (ide_hwif_t *)dev_id;
1072 ide_hwgroup_t *hwgroup = hwif->hwgroup;
1073 ide_drive_t *uninitialized_var(drive); 1071 ide_drive_t *uninitialized_var(drive);
1074 ide_handler_t *handler; 1072 ide_handler_t *handler;
1075 unsigned long flags; 1073 unsigned long flags;
@@ -1082,12 +1080,14 @@ irqreturn_t ide_intr (int irq, void *dev_id)
1082 goto out_early; 1080 goto out_early;
1083 } 1081 }
1084 1082
1085 spin_lock_irqsave(&hwgroup->lock, flags); 1083 spin_lock_irqsave(&hwif->lock, flags);
1086 1084
1087 if (!ide_ack_intr(hwif)) 1085 if (!ide_ack_intr(hwif))
1088 goto out; 1086 goto out;
1089 1087
1090 if ((handler = hwgroup->handler) == NULL || hwgroup->polling) { 1088 handler = hwif->handler;
1089
1090 if (handler == NULL || hwif->polling) {
1091 /* 1091 /*
1092 * Not expecting an interrupt from this drive. 1092 * Not expecting an interrupt from this drive.
1093 * That means this could be: 1093 * That means this could be:
@@ -1124,7 +1124,7 @@ irqreturn_t ide_intr (int irq, void *dev_id)
1124 goto out; 1124 goto out;
1125 } 1125 }
1126 1126
1127 drive = hwgroup->cur_dev; 1127 drive = hwif->cur_dev;
1128 if (!drive) { 1128 if (!drive) {
1129 /* 1129 /*
1130 * This should NEVER happen, and there isn't much 1130 * This should NEVER happen, and there isn't much
@@ -1145,10 +1145,10 @@ irqreturn_t ide_intr (int irq, void *dev_id)
1145 */ 1145 */
1146 goto out; 1146 goto out;
1147 1147
1148 hwgroup->handler = NULL; 1148 hwif->handler = NULL;
1149 hwgroup->req_gen++; 1149 hwif->req_gen++;
1150 del_timer(&hwgroup->timer); 1150 del_timer(&hwif->timer);
1151 spin_unlock(&hwgroup->lock); 1151 spin_unlock(&hwif->lock);
1152 1152
1153 if (hwif->port_ops && hwif->port_ops->clear_irq) 1153 if (hwif->port_ops && hwif->port_ops->clear_irq)
1154 hwif->port_ops->clear_irq(drive); 1154 hwif->port_ops->clear_irq(drive);
@@ -1159,7 +1159,7 @@ irqreturn_t ide_intr (int irq, void *dev_id)
1159 /* service this interrupt, may set handler for next interrupt */ 1159 /* service this interrupt, may set handler for next interrupt */
1160 startstop = handler(drive); 1160 startstop = handler(drive);
1161 1161
1162 spin_lock_irq(&hwgroup->lock); 1162 spin_lock_irq(&hwif->lock);
1163 /* 1163 /*
1164 * Note that handler() may have set things up for another 1164 * Note that handler() may have set things up for another
1165 * interrupt to occur soon, but it cannot happen until 1165 * interrupt to occur soon, but it cannot happen until
@@ -1168,7 +1168,7 @@ irqreturn_t ide_intr (int irq, void *dev_id)
1168 * won't allow another of the same (on any CPU) until we return. 1168 * won't allow another of the same (on any CPU) until we return.
1169 */ 1169 */
1170 if (startstop == ide_stopped) { 1170 if (startstop == ide_stopped) {
1171 if (hwgroup->handler == NULL) { /* paranoia */ 1171 if (hwif->handler == NULL) { /* paranoia */
1172 ide_unlock_port(hwif); 1172 ide_unlock_port(hwif);
1173 plug_device = 1; 1173 plug_device = 1;
1174 } else 1174 } else
@@ -1178,7 +1178,7 @@ irqreturn_t ide_intr (int irq, void *dev_id)
1178out_handled: 1178out_handled:
1179 irq_ret = IRQ_HANDLED; 1179 irq_ret = IRQ_HANDLED;
1180out: 1180out:
1181 spin_unlock_irqrestore(&hwgroup->lock, flags); 1181 spin_unlock_irqrestore(&hwif->lock, flags);
1182out_early: 1182out_early:
1183 if (plug_device) { 1183 if (plug_device) {
1184 ide_unlock_host(hwif->host); 1184 ide_unlock_host(hwif->host);
@@ -1205,11 +1205,10 @@ out_early:
1205 1205
1206void ide_do_drive_cmd(ide_drive_t *drive, struct request *rq) 1206void ide_do_drive_cmd(ide_drive_t *drive, struct request *rq)
1207{ 1207{
1208 ide_hwgroup_t *hwgroup = drive->hwif->hwgroup;
1209 struct request_queue *q = drive->queue; 1208 struct request_queue *q = drive->queue;
1210 unsigned long flags; 1209 unsigned long flags;
1211 1210
1212 hwgroup->rq = NULL; 1211 drive->hwif->rq = NULL;
1213 1212
1214 spin_lock_irqsave(q->queue_lock, flags); 1213 spin_lock_irqsave(q->queue_lock, flags);
1215 __elv_add_request(q, rq, ELEVATOR_INSERT_FRONT, 0); 1214 __elv_add_request(q, rq, ELEVATOR_INSERT_FRONT, 0);
diff --git a/drivers/ide/ide-iops.c b/drivers/ide/ide-iops.c
index ad8bd6539283..b92304d0e79a 100644
--- a/drivers/ide/ide-iops.c
+++ b/drivers/ide/ide-iops.c
@@ -822,25 +822,25 @@ int ide_config_drive_speed(ide_drive_t *drive, u8 speed)
822static void __ide_set_handler (ide_drive_t *drive, ide_handler_t *handler, 822static void __ide_set_handler (ide_drive_t *drive, ide_handler_t *handler,
823 unsigned int timeout, ide_expiry_t *expiry) 823 unsigned int timeout, ide_expiry_t *expiry)
824{ 824{
825 ide_hwgroup_t *hwgroup = HWGROUP(drive); 825 ide_hwif_t *hwif = drive->hwif;
826 826
827 BUG_ON(hwgroup->handler); 827 BUG_ON(hwif->handler);
828 hwgroup->handler = handler; 828 hwif->handler = handler;
829 hwgroup->expiry = expiry; 829 hwif->expiry = expiry;
830 hwgroup->timer.expires = jiffies + timeout; 830 hwif->timer.expires = jiffies + timeout;
831 hwgroup->req_gen_timer = hwgroup->req_gen; 831 hwif->req_gen_timer = hwif->req_gen;
832 add_timer(&hwgroup->timer); 832 add_timer(&hwif->timer);
833} 833}
834 834
835void ide_set_handler (ide_drive_t *drive, ide_handler_t *handler, 835void ide_set_handler (ide_drive_t *drive, ide_handler_t *handler,
836 unsigned int timeout, ide_expiry_t *expiry) 836 unsigned int timeout, ide_expiry_t *expiry)
837{ 837{
838 ide_hwgroup_t *hwgroup = drive->hwif->hwgroup; 838 ide_hwif_t *hwif = drive->hwif;
839 unsigned long flags; 839 unsigned long flags;
840 840
841 spin_lock_irqsave(&hwgroup->lock, flags); 841 spin_lock_irqsave(&hwif->lock, flags);
842 __ide_set_handler(drive, handler, timeout, expiry); 842 __ide_set_handler(drive, handler, timeout, expiry);
843 spin_unlock_irqrestore(&hwgroup->lock, flags); 843 spin_unlock_irqrestore(&hwif->lock, flags);
844} 844}
845 845
846EXPORT_SYMBOL(ide_set_handler); 846EXPORT_SYMBOL(ide_set_handler);
@@ -863,10 +863,9 @@ void ide_execute_command(ide_drive_t *drive, u8 cmd, ide_handler_t *handler,
863 unsigned timeout, ide_expiry_t *expiry) 863 unsigned timeout, ide_expiry_t *expiry)
864{ 864{
865 ide_hwif_t *hwif = drive->hwif; 865 ide_hwif_t *hwif = drive->hwif;
866 ide_hwgroup_t *hwgroup = hwif->hwgroup;
867 unsigned long flags; 866 unsigned long flags;
868 867
869 spin_lock_irqsave(&hwgroup->lock, flags); 868 spin_lock_irqsave(&hwif->lock, flags);
870 __ide_set_handler(drive, handler, timeout, expiry); 869 __ide_set_handler(drive, handler, timeout, expiry);
871 hwif->tp_ops->exec_command(hwif, cmd); 870 hwif->tp_ops->exec_command(hwif, cmd);
872 /* 871 /*
@@ -876,26 +875,25 @@ void ide_execute_command(ide_drive_t *drive, u8 cmd, ide_handler_t *handler,
876 * FIXME: we could skip this delay with care on non shared devices 875 * FIXME: we could skip this delay with care on non shared devices
877 */ 876 */
878 ndelay(400); 877 ndelay(400);
879 spin_unlock_irqrestore(&hwgroup->lock, flags); 878 spin_unlock_irqrestore(&hwif->lock, flags);
880} 879}
881EXPORT_SYMBOL(ide_execute_command); 880EXPORT_SYMBOL(ide_execute_command);
882 881
883void ide_execute_pkt_cmd(ide_drive_t *drive) 882void ide_execute_pkt_cmd(ide_drive_t *drive)
884{ 883{
885 ide_hwif_t *hwif = drive->hwif; 884 ide_hwif_t *hwif = drive->hwif;
886 ide_hwgroup_t *hwgroup = hwif->hwgroup;
887 unsigned long flags; 885 unsigned long flags;
888 886
889 spin_lock_irqsave(&hwgroup->lock, flags); 887 spin_lock_irqsave(&hwif->lock, flags);
890 hwif->tp_ops->exec_command(hwif, ATA_CMD_PACKET); 888 hwif->tp_ops->exec_command(hwif, ATA_CMD_PACKET);
891 ndelay(400); 889 ndelay(400);
892 spin_unlock_irqrestore(&hwgroup->lock, flags); 890 spin_unlock_irqrestore(&hwif->lock, flags);
893} 891}
894EXPORT_SYMBOL_GPL(ide_execute_pkt_cmd); 892EXPORT_SYMBOL_GPL(ide_execute_pkt_cmd);
895 893
896static inline void ide_complete_drive_reset(ide_drive_t *drive, int err) 894static inline void ide_complete_drive_reset(ide_drive_t *drive, int err)
897{ 895{
898 struct request *rq = drive->hwif->hwgroup->rq; 896 struct request *rq = drive->hwif->rq;
899 897
900 if (rq && blk_special_request(rq) && rq->cmd[0] == REQ_DRIVE_RESET) 898 if (rq && blk_special_request(rq) && rq->cmd[0] == REQ_DRIVE_RESET)
901 ide_end_request(drive, err ? err : 1, 0); 899 ide_end_request(drive, err ? err : 1, 0);
@@ -913,7 +911,6 @@ static ide_startstop_t do_reset1 (ide_drive_t *, int);
913static ide_startstop_t atapi_reset_pollfunc (ide_drive_t *drive) 911static ide_startstop_t atapi_reset_pollfunc (ide_drive_t *drive)
914{ 912{
915 ide_hwif_t *hwif = drive->hwif; 913 ide_hwif_t *hwif = drive->hwif;
916 ide_hwgroup_t *hwgroup = hwif->hwgroup;
917 u8 stat; 914 u8 stat;
918 915
919 SELECT_DRIVE(drive); 916 SELECT_DRIVE(drive);
@@ -923,20 +920,20 @@ static ide_startstop_t atapi_reset_pollfunc (ide_drive_t *drive)
923 if (OK_STAT(stat, 0, ATA_BUSY)) 920 if (OK_STAT(stat, 0, ATA_BUSY))
924 printk("%s: ATAPI reset complete\n", drive->name); 921 printk("%s: ATAPI reset complete\n", drive->name);
925 else { 922 else {
926 if (time_before(jiffies, hwgroup->poll_timeout)) { 923 if (time_before(jiffies, hwif->poll_timeout)) {
927 ide_set_handler(drive, &atapi_reset_pollfunc, HZ/20, NULL); 924 ide_set_handler(drive, &atapi_reset_pollfunc, HZ/20, NULL);
928 /* continue polling */ 925 /* continue polling */
929 return ide_started; 926 return ide_started;
930 } 927 }
931 /* end of polling */ 928 /* end of polling */
932 hwgroup->polling = 0; 929 hwif->polling = 0;
933 printk("%s: ATAPI reset timed-out, status=0x%02x\n", 930 printk("%s: ATAPI reset timed-out, status=0x%02x\n",
934 drive->name, stat); 931 drive->name, stat);
935 /* do it the old fashioned way */ 932 /* do it the old fashioned way */
936 return do_reset1(drive, 1); 933 return do_reset1(drive, 1);
937 } 934 }
938 /* done polling */ 935 /* done polling */
939 hwgroup->polling = 0; 936 hwif->polling = 0;
940 ide_complete_drive_reset(drive, 0); 937 ide_complete_drive_reset(drive, 0);
941 return ide_stopped; 938 return ide_stopped;
942} 939}
@@ -968,7 +965,6 @@ static void ide_reset_report_error(ide_hwif_t *hwif, u8 err)
968 */ 965 */
969static ide_startstop_t reset_pollfunc (ide_drive_t *drive) 966static ide_startstop_t reset_pollfunc (ide_drive_t *drive)
970{ 967{
971 ide_hwgroup_t *hwgroup = HWGROUP(drive);
972 ide_hwif_t *hwif = HWIF(drive); 968 ide_hwif_t *hwif = HWIF(drive);
973 const struct ide_port_ops *port_ops = hwif->port_ops; 969 const struct ide_port_ops *port_ops = hwif->port_ops;
974 u8 tmp; 970 u8 tmp;
@@ -986,7 +982,7 @@ static ide_startstop_t reset_pollfunc (ide_drive_t *drive)
986 tmp = hwif->tp_ops->read_status(hwif); 982 tmp = hwif->tp_ops->read_status(hwif);
987 983
988 if (!OK_STAT(tmp, 0, ATA_BUSY)) { 984 if (!OK_STAT(tmp, 0, ATA_BUSY)) {
989 if (time_before(jiffies, hwgroup->poll_timeout)) { 985 if (time_before(jiffies, hwif->poll_timeout)) {
990 ide_set_handler(drive, &reset_pollfunc, HZ/20, NULL); 986 ide_set_handler(drive, &reset_pollfunc, HZ/20, NULL);
991 /* continue polling */ 987 /* continue polling */
992 return ide_started; 988 return ide_started;
@@ -1007,7 +1003,7 @@ static ide_startstop_t reset_pollfunc (ide_drive_t *drive)
1007 } 1003 }
1008 } 1004 }
1009out: 1005out:
1010 hwgroup->polling = 0; /* done polling */ 1006 hwif->polling = 0; /* done polling */
1011 ide_complete_drive_reset(drive, err); 1007 ide_complete_drive_reset(drive, err);
1012 return ide_stopped; 1008 return ide_stopped;
1013} 1009}
@@ -1081,7 +1077,6 @@ static void pre_reset(ide_drive_t *drive)
1081static ide_startstop_t do_reset1 (ide_drive_t *drive, int do_not_try_atapi) 1077static ide_startstop_t do_reset1 (ide_drive_t *drive, int do_not_try_atapi)
1082{ 1078{
1083 ide_hwif_t *hwif = drive->hwif; 1079 ide_hwif_t *hwif = drive->hwif;
1084 ide_hwgroup_t *hwgroup = hwif->hwgroup;
1085 struct ide_io_ports *io_ports = &hwif->io_ports; 1080 struct ide_io_ports *io_ports = &hwif->io_ports;
1086 const struct ide_tp_ops *tp_ops = hwif->tp_ops; 1081 const struct ide_tp_ops *tp_ops = hwif->tp_ops;
1087 const struct ide_port_ops *port_ops; 1082 const struct ide_port_ops *port_ops;
@@ -1089,10 +1084,10 @@ static ide_startstop_t do_reset1 (ide_drive_t *drive, int do_not_try_atapi)
1089 unsigned int unit; 1084 unsigned int unit;
1090 DEFINE_WAIT(wait); 1085 DEFINE_WAIT(wait);
1091 1086
1092 spin_lock_irqsave(&hwgroup->lock, flags); 1087 spin_lock_irqsave(&hwif->lock, flags);
1093 1088
1094 /* We must not reset with running handlers */ 1089 /* We must not reset with running handlers */
1095 BUG_ON(hwgroup->handler != NULL); 1090 BUG_ON(hwif->handler != NULL);
1096 1091
1097 /* For an ATAPI device, first try an ATAPI SRST. */ 1092 /* For an ATAPI device, first try an ATAPI SRST. */
1098 if (drive->media != ide_disk && !do_not_try_atapi) { 1093 if (drive->media != ide_disk && !do_not_try_atapi) {
@@ -1101,10 +1096,10 @@ static ide_startstop_t do_reset1 (ide_drive_t *drive, int do_not_try_atapi)
1101 udelay (20); 1096 udelay (20);
1102 tp_ops->exec_command(hwif, ATA_CMD_DEV_RESET); 1097 tp_ops->exec_command(hwif, ATA_CMD_DEV_RESET);
1103 ndelay(400); 1098 ndelay(400);
1104 hwgroup->poll_timeout = jiffies + WAIT_WORSTCASE; 1099 hwif->poll_timeout = jiffies + WAIT_WORSTCASE;
1105 hwgroup->polling = 1; 1100 hwif->polling = 1;
1106 __ide_set_handler(drive, &atapi_reset_pollfunc, HZ/20, NULL); 1101 __ide_set_handler(drive, &atapi_reset_pollfunc, HZ/20, NULL);
1107 spin_unlock_irqrestore(&hwgroup->lock, flags); 1102 spin_unlock_irqrestore(&hwif->lock, flags);
1108 return ide_started; 1103 return ide_started;
1109 } 1104 }
1110 1105
@@ -1127,9 +1122,9 @@ static ide_startstop_t do_reset1 (ide_drive_t *drive, int do_not_try_atapi)
1127 if (time_before_eq(timeout, now)) 1122 if (time_before_eq(timeout, now))
1128 break; 1123 break;
1129 1124
1130 spin_unlock_irqrestore(&hwgroup->lock, flags); 1125 spin_unlock_irqrestore(&hwif->lock, flags);
1131 timeout = schedule_timeout_uninterruptible(timeout - now); 1126 timeout = schedule_timeout_uninterruptible(timeout - now);
1132 spin_lock_irqsave(&hwgroup->lock, flags); 1127 spin_lock_irqsave(&hwif->lock, flags);
1133 } while (timeout); 1128 } while (timeout);
1134 finish_wait(&ide_park_wq, &wait); 1129 finish_wait(&ide_park_wq, &wait);
1135 1130
@@ -1141,7 +1136,7 @@ static ide_startstop_t do_reset1 (ide_drive_t *drive, int do_not_try_atapi)
1141 pre_reset(&hwif->drives[unit]); 1136 pre_reset(&hwif->drives[unit]);
1142 1137
1143 if (io_ports->ctl_addr == 0) { 1138 if (io_ports->ctl_addr == 0) {
1144 spin_unlock_irqrestore(&hwgroup->lock, flags); 1139 spin_unlock_irqrestore(&hwif->lock, flags);
1145 ide_complete_drive_reset(drive, -ENXIO); 1140 ide_complete_drive_reset(drive, -ENXIO);
1146 return ide_stopped; 1141 return ide_stopped;
1147 } 1142 }
@@ -1164,8 +1159,8 @@ static ide_startstop_t do_reset1 (ide_drive_t *drive, int do_not_try_atapi)
1164 tp_ops->set_irq(hwif, drive->quirk_list == 2); 1159 tp_ops->set_irq(hwif, drive->quirk_list == 2);
1165 /* more than enough time */ 1160 /* more than enough time */
1166 udelay(10); 1161 udelay(10);
1167 hwgroup->poll_timeout = jiffies + WAIT_WORSTCASE; 1162 hwif->poll_timeout = jiffies + WAIT_WORSTCASE;
1168 hwgroup->polling = 1; 1163 hwif->polling = 1;
1169 __ide_set_handler(drive, &reset_pollfunc, HZ/20, NULL); 1164 __ide_set_handler(drive, &reset_pollfunc, HZ/20, NULL);
1170 1165
1171 /* 1166 /*
@@ -1177,7 +1172,7 @@ static ide_startstop_t do_reset1 (ide_drive_t *drive, int do_not_try_atapi)
1177 if (port_ops && port_ops->resetproc) 1172 if (port_ops && port_ops->resetproc)
1178 port_ops->resetproc(drive); 1173 port_ops->resetproc(drive);
1179 1174
1180 spin_unlock_irqrestore(&hwgroup->lock, flags); 1175 spin_unlock_irqrestore(&hwif->lock, flags);
1181 return ide_started; 1176 return ide_started;
1182} 1177}
1183 1178
diff --git a/drivers/ide/ide-lib.c b/drivers/ide/ide-lib.c
index 9f6e33d8a8b2..09526a0de734 100644
--- a/drivers/ide/ide-lib.c
+++ b/drivers/ide/ide-lib.c
@@ -273,7 +273,7 @@ int ide_set_xfer_rate(ide_drive_t *drive, u8 rate)
273 273
274static void ide_dump_opcode(ide_drive_t *drive) 274static void ide_dump_opcode(ide_drive_t *drive)
275{ 275{
276 struct request *rq = drive->hwif->hwgroup->rq; 276 struct request *rq = drive->hwif->rq;
277 ide_task_t *task = NULL; 277 ide_task_t *task = NULL;
278 278
279 if (!rq) 279 if (!rq)
@@ -346,10 +346,13 @@ static void ide_dump_ata_error(ide_drive_t *drive, u8 err)
346 printk(KERN_CONT "}"); 346 printk(KERN_CONT "}");
347 if ((err & (ATA_BBK | ATA_ABORTED)) == ATA_BBK || 347 if ((err & (ATA_BBK | ATA_ABORTED)) == ATA_BBK ||
348 (err & (ATA_UNC | ATA_IDNF | ATA_AMNF))) { 348 (err & (ATA_UNC | ATA_IDNF | ATA_AMNF))) {
349 struct request *rq = drive->hwif->rq;
350
349 ide_dump_sector(drive); 351 ide_dump_sector(drive);
350 if (HWGROUP(drive) && HWGROUP(drive)->rq) 352
353 if (rq)
351 printk(KERN_CONT ", sector=%llu", 354 printk(KERN_CONT ", sector=%llu",
352 (unsigned long long)HWGROUP(drive)->rq->sector); 355 (unsigned long long)rq->sector);
353 } 356 }
354 printk(KERN_CONT "\n"); 357 printk(KERN_CONT "\n");
355} 358}
diff --git a/drivers/ide/ide-park.c b/drivers/ide/ide-park.c
index 678454ac2483..c875a957596c 100644
--- a/drivers/ide/ide-park.c
+++ b/drivers/ide/ide-park.c
@@ -7,22 +7,22 @@ DECLARE_WAIT_QUEUE_HEAD(ide_park_wq);
7 7
8static void issue_park_cmd(ide_drive_t *drive, unsigned long timeout) 8static void issue_park_cmd(ide_drive_t *drive, unsigned long timeout)
9{ 9{
10 ide_hwgroup_t *hwgroup = drive->hwif->hwgroup; 10 ide_hwif_t *hwif = drive->hwif;
11 struct request_queue *q = drive->queue; 11 struct request_queue *q = drive->queue;
12 struct request *rq; 12 struct request *rq;
13 int rc; 13 int rc;
14 14
15 timeout += jiffies; 15 timeout += jiffies;
16 spin_lock_irq(&hwgroup->lock); 16 spin_lock_irq(&hwif->lock);
17 if (drive->dev_flags & IDE_DFLAG_PARKED) { 17 if (drive->dev_flags & IDE_DFLAG_PARKED) {
18 int reset_timer = time_before(timeout, drive->sleep); 18 int reset_timer = time_before(timeout, drive->sleep);
19 int start_queue = 0; 19 int start_queue = 0;
20 20
21 drive->sleep = timeout; 21 drive->sleep = timeout;
22 wake_up_all(&ide_park_wq); 22 wake_up_all(&ide_park_wq);
23 if (reset_timer && del_timer(&hwgroup->timer)) 23 if (reset_timer && del_timer(&hwif->timer))
24 start_queue = 1; 24 start_queue = 1;
25 spin_unlock_irq(&hwgroup->lock); 25 spin_unlock_irq(&hwif->lock);
26 26
27 if (start_queue) { 27 if (start_queue) {
28 spin_lock_irq(q->queue_lock); 28 spin_lock_irq(q->queue_lock);
@@ -31,7 +31,7 @@ static void issue_park_cmd(ide_drive_t *drive, unsigned long timeout)
31 } 31 }
32 return; 32 return;
33 } 33 }
34 spin_unlock_irq(&hwgroup->lock); 34 spin_unlock_irq(&hwif->lock);
35 35
36 rq = blk_get_request(q, READ, __GFP_WAIT); 36 rq = blk_get_request(q, READ, __GFP_WAIT);
37 rq->cmd[0] = REQ_PARK_HEADS; 37 rq->cmd[0] = REQ_PARK_HEADS;
@@ -64,21 +64,21 @@ ssize_t ide_park_show(struct device *dev, struct device_attribute *attr,
64 char *buf) 64 char *buf)
65{ 65{
66 ide_drive_t *drive = to_ide_device(dev); 66 ide_drive_t *drive = to_ide_device(dev);
67 ide_hwgroup_t *hwgroup = drive->hwif->hwgroup; 67 ide_hwif_t *hwif = drive->hwif;
68 unsigned long now; 68 unsigned long now;
69 unsigned int msecs; 69 unsigned int msecs;
70 70
71 if (drive->dev_flags & IDE_DFLAG_NO_UNLOAD) 71 if (drive->dev_flags & IDE_DFLAG_NO_UNLOAD)
72 return -EOPNOTSUPP; 72 return -EOPNOTSUPP;
73 73
74 spin_lock_irq(&hwgroup->lock); 74 spin_lock_irq(&hwif->lock);
75 now = jiffies; 75 now = jiffies;
76 if (drive->dev_flags & IDE_DFLAG_PARKED && 76 if (drive->dev_flags & IDE_DFLAG_PARKED &&
77 time_after(drive->sleep, now)) 77 time_after(drive->sleep, now))
78 msecs = jiffies_to_msecs(drive->sleep - now); 78 msecs = jiffies_to_msecs(drive->sleep - now);
79 else 79 else
80 msecs = 0; 80 msecs = 0;
81 spin_unlock_irq(&hwgroup->lock); 81 spin_unlock_irq(&hwif->lock);
82 82
83 return snprintf(buf, 20, "%u\n", msecs); 83 return snprintf(buf, 20, "%u\n", msecs);
84} 84}
diff --git a/drivers/ide/ide-pm.c b/drivers/ide/ide-pm.c
index 8282c6086e6a..abb84a2dd821 100644
--- a/drivers/ide/ide-pm.c
+++ b/drivers/ide/ide-pm.c
@@ -194,7 +194,7 @@ void ide_complete_pm_request(ide_drive_t *drive, struct request *rq)
194 } 194 }
195 spin_unlock_irqrestore(q->queue_lock, flags); 195 spin_unlock_irqrestore(q->queue_lock, flags);
196 196
197 drive->hwif->hwgroup->rq = NULL; 197 drive->hwif->rq = NULL;
198 198
199 if (blk_end_request(rq, 0, 0)) 199 if (blk_end_request(rq, 0, 0))
200 BUG(); 200 BUG();
diff --git a/drivers/ide/ide-probe.c b/drivers/ide/ide-probe.c
index 68f3c87b8284..e953b70706c2 100644
--- a/drivers/ide/ide-probe.c
+++ b/drivers/ide/ide-probe.c
@@ -949,79 +949,20 @@ static int ide_port_setup_devices(ide_hwif_t *hwif)
949 return j; 949 return j;
950} 950}
951 951
952static ide_hwif_t *ide_ports[MAX_HWIFS];
953
954void ide_remove_port_from_hwgroup(ide_hwif_t *hwif)
955{
956 ide_hwgroup_t *hwgroup = hwif->hwgroup;
957
958 ide_ports[hwif->index] = NULL;
959
960 spin_lock_irq(&hwgroup->lock);
961 /* Free the hwgroup if we were the only member. */
962 if (--hwgroup->port_count == 0)
963 kfree(hwgroup);
964 spin_unlock_irq(&hwgroup->lock);
965}
966
967/* 952/*
968 * This routine sets up the irq for an ide interface, and creates a new 953 * This routine sets up the IRQ for an IDE interface.
969 * hwgroup for the irq/hwif if none was previously assigned.
970 *
971 * Much of the code is for correctly detecting/handling irq sharing
972 * and irq serialization situations. This is somewhat complex because
973 * it handles static as well as dynamic (PCMCIA) IDE interfaces.
974 */ 954 */
975static int init_irq (ide_hwif_t *hwif) 955static int init_irq (ide_hwif_t *hwif)
976{ 956{
977 struct ide_io_ports *io_ports = &hwif->io_ports; 957 struct ide_io_ports *io_ports = &hwif->io_ports;
978 unsigned int index;
979 ide_hwgroup_t *hwgroup;
980 ide_hwif_t *match = NULL;
981 int sa = 0; 958 int sa = 0;
982 959
983 mutex_lock(&ide_cfg_mtx); 960 mutex_lock(&ide_cfg_mtx);
984 hwif->hwgroup = NULL; 961 spin_lock_init(&hwif->lock);
985
986 for (index = 0; index < MAX_HWIFS; index++) {
987 ide_hwif_t *h = ide_ports[index];
988 962
989 if (h && h->hwgroup) { /* scan only initialized ports */ 963 init_timer(&hwif->timer);
990 if (hwif->host->host_flags & IDE_HFLAG_SERIALIZE) { 964 hwif->timer.function = &ide_timer_expiry;
991 if (hwif->host == h->host) 965 hwif->timer.data = (unsigned long)hwif;
992 match = h;
993 }
994 }
995 }
996
997 /*
998 * If we are still without a hwgroup, then form a new one
999 */
1000 if (match) {
1001 hwgroup = match->hwgroup;
1002 hwif->hwgroup = hwgroup;
1003
1004 spin_lock_irq(&hwgroup->lock);
1005 hwgroup->port_count++;
1006 spin_unlock_irq(&hwgroup->lock);
1007 } else {
1008 hwgroup = kmalloc_node(sizeof(*hwgroup), GFP_KERNEL|__GFP_ZERO,
1009 hwif_to_node(hwif));
1010 if (hwgroup == NULL)
1011 goto out_up;
1012
1013 spin_lock_init(&hwgroup->lock);
1014
1015 hwif->hwgroup = hwgroup;
1016
1017 hwgroup->port_count = 1;
1018
1019 init_timer(&hwgroup->timer);
1020 hwgroup->timer.function = &ide_timer_expiry;
1021 hwgroup->timer.data = (unsigned long) hwgroup;
1022 }
1023
1024 ide_ports[hwif->index] = hwif;
1025 966
1026#if defined(__mc68000__) 967#if defined(__mc68000__)
1027 sa = IRQF_SHARED; 968 sa = IRQF_SHARED;
@@ -1034,7 +975,7 @@ static int init_irq (ide_hwif_t *hwif)
1034 hwif->tp_ops->set_irq(hwif, 1); 975 hwif->tp_ops->set_irq(hwif, 1);
1035 976
1036 if (request_irq(hwif->irq, &ide_intr, sa, hwif->name, hwif)) 977 if (request_irq(hwif->irq, &ide_intr, sa, hwif->name, hwif))
1037 goto out_unlink; 978 goto out_up;
1038 979
1039 if (!hwif->rqsize) { 980 if (!hwif->rqsize) {
1040 if ((hwif->host_flags & IDE_HFLAG_NO_LBA48) || 981 if ((hwif->host_flags & IDE_HFLAG_NO_LBA48) ||
@@ -1052,14 +993,12 @@ static int init_irq (ide_hwif_t *hwif)
1052 printk(KERN_INFO "%s at 0x%08lx on irq %d", hwif->name, 993 printk(KERN_INFO "%s at 0x%08lx on irq %d", hwif->name,
1053 io_ports->data_addr, hwif->irq); 994 io_ports->data_addr, hwif->irq);
1054#endif /* __mc68000__ */ 995#endif /* __mc68000__ */
1055 if (match) 996 if (hwif->host->host_flags & IDE_HFLAG_SERIALIZE)
1056 printk(KERN_CONT " (serialized with %s)", match->name); 997 printk(KERN_CONT " (serialized)");
1057 printk(KERN_CONT "\n"); 998 printk(KERN_CONT "\n");
1058 999
1059 mutex_unlock(&ide_cfg_mtx); 1000 mutex_unlock(&ide_cfg_mtx);
1060 return 0; 1001 return 0;
1061out_unlink:
1062 ide_remove_port_from_hwgroup(hwif);
1063out_up: 1002out_up:
1064 mutex_unlock(&ide_cfg_mtx); 1003 mutex_unlock(&ide_cfg_mtx);
1065 return 1; 1004 return 1;
@@ -1140,20 +1079,20 @@ EXPORT_SYMBOL_GPL(ide_init_disk);
1140static void drive_release_dev (struct device *dev) 1079static void drive_release_dev (struct device *dev)
1141{ 1080{
1142 ide_drive_t *drive = container_of(dev, ide_drive_t, gendev); 1081 ide_drive_t *drive = container_of(dev, ide_drive_t, gendev);
1143 ide_hwgroup_t *hwgroup = drive->hwif->hwgroup; 1082 ide_hwif_t *hwif = drive->hwif;
1144 1083
1145 ide_proc_unregister_device(drive); 1084 ide_proc_unregister_device(drive);
1146 1085
1147 spin_lock_irq(&hwgroup->lock); 1086 spin_lock_irq(&hwif->lock);
1148 kfree(drive->id); 1087 kfree(drive->id);
1149 drive->id = NULL; 1088 drive->id = NULL;
1150 drive->dev_flags &= ~IDE_DFLAG_PRESENT; 1089 drive->dev_flags &= ~IDE_DFLAG_PRESENT;
1151 /* Messed up locking ... */ 1090 /* Messed up locking ... */
1152 spin_unlock_irq(&hwgroup->lock); 1091 spin_unlock_irq(&hwif->lock);
1153 blk_cleanup_queue(drive->queue); 1092 blk_cleanup_queue(drive->queue);
1154 spin_lock_irq(&hwgroup->lock); 1093 spin_lock_irq(&hwif->lock);
1155 drive->queue = NULL; 1094 drive->queue = NULL;
1156 spin_unlock_irq(&hwgroup->lock); 1095 spin_unlock_irq(&hwif->lock);
1157 1096
1158 complete(&drive->gendev_rel_comp); 1097 complete(&drive->gendev_rel_comp);
1159} 1098}
diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c
index 5d2aa22cd6e4..e39f2f46d982 100644
--- a/drivers/ide/ide-tape.c
+++ b/drivers/ide/ide-tape.c
@@ -479,7 +479,7 @@ static void ide_tape_kfree_buffer(idetape_tape_t *tape)
479 479
480static int idetape_end_request(ide_drive_t *drive, int uptodate, int nr_sects) 480static int idetape_end_request(ide_drive_t *drive, int uptodate, int nr_sects)
481{ 481{
482 struct request *rq = HWGROUP(drive)->rq; 482 struct request *rq = drive->hwif->rq;
483 idetape_tape_t *tape = drive->driver_data; 483 idetape_tape_t *tape = drive->driver_data;
484 unsigned long flags; 484 unsigned long flags;
485 int error; 485 int error;
@@ -531,7 +531,7 @@ static void ide_tape_callback(ide_drive_t *drive, int dsc)
531 printk(KERN_ERR "ide-tape: Error in REQUEST SENSE " 531 printk(KERN_ERR "ide-tape: Error in REQUEST SENSE "
532 "itself - Aborting request!\n"); 532 "itself - Aborting request!\n");
533 } else if (pc->c[0] == READ_6 || pc->c[0] == WRITE_6) { 533 } else if (pc->c[0] == READ_6 || pc->c[0] == WRITE_6) {
534 struct request *rq = drive->hwif->hwgroup->rq; 534 struct request *rq = drive->hwif->rq;
535 int blocks = pc->xferred / tape->blk_size; 535 int blocks = pc->xferred / tape->blk_size;
536 536
537 tape->avg_size += blocks * tape->blk_size; 537 tape->avg_size += blocks * tape->blk_size;
@@ -576,7 +576,7 @@ static void ide_tape_callback(ide_drive_t *drive, int dsc)
576 576
577/* 577/*
578 * Postpone the current request so that ide.c will be able to service requests 578 * Postpone the current request so that ide.c will be able to service requests
579 * from another device on the same hwgroup while we are polling for DSC. 579 * from another device on the same port while we are polling for DSC.
580 */ 580 */
581static void idetape_postpone_request(ide_drive_t *drive) 581static void idetape_postpone_request(ide_drive_t *drive)
582{ 582{
@@ -584,7 +584,8 @@ static void idetape_postpone_request(ide_drive_t *drive)
584 584
585 debug_log(DBG_PROCS, "Enter %s\n", __func__); 585 debug_log(DBG_PROCS, "Enter %s\n", __func__);
586 586
587 tape->postponed_rq = HWGROUP(drive)->rq; 587 tape->postponed_rq = drive->hwif->rq;
588
588 ide_stall_queue(drive, tape->dsc_poll_freq); 589 ide_stall_queue(drive, tape->dsc_poll_freq);
589} 590}
590 591
diff --git a/drivers/ide/ide-taskfile.c b/drivers/ide/ide-taskfile.c
index bf4fb9d8d176..693e8d15fb78 100644
--- a/drivers/ide/ide-taskfile.c
+++ b/drivers/ide/ide-taskfile.c
@@ -361,7 +361,7 @@ static ide_startstop_t task_in_unexpected(ide_drive_t *drive, struct request *rq
361static ide_startstop_t task_in_intr(ide_drive_t *drive) 361static ide_startstop_t task_in_intr(ide_drive_t *drive)
362{ 362{
363 ide_hwif_t *hwif = drive->hwif; 363 ide_hwif_t *hwif = drive->hwif;
364 struct request *rq = hwif->hwgroup->rq; 364 struct request *rq = hwif->rq;
365 u8 stat = hwif->tp_ops->read_status(hwif); 365 u8 stat = hwif->tp_ops->read_status(hwif);
366 366
367 /* Error? */ 367 /* Error? */
@@ -395,7 +395,7 @@ static ide_startstop_t task_in_intr(ide_drive_t *drive)
395static ide_startstop_t task_out_intr (ide_drive_t *drive) 395static ide_startstop_t task_out_intr (ide_drive_t *drive)
396{ 396{
397 ide_hwif_t *hwif = drive->hwif; 397 ide_hwif_t *hwif = drive->hwif;
398 struct request *rq = HWGROUP(drive)->rq; 398 struct request *rq = hwif->rq;
399 u8 stat = hwif->tp_ops->read_status(hwif); 399 u8 stat = hwif->tp_ops->read_status(hwif);
400 400
401 if (!OK_STAT(stat, DRIVE_READY, drive->bad_wstat)) 401 if (!OK_STAT(stat, DRIVE_READY, drive->bad_wstat))
diff --git a/drivers/ide/ide.c b/drivers/ide/ide.c
index 5bc2e4782a55..9e403282dfa7 100644
--- a/drivers/ide/ide.c
+++ b/drivers/ide/ide.c
@@ -189,8 +189,6 @@ void ide_unregister(ide_hwif_t *hwif)
189 189
190 free_irq(hwif->irq, hwif); 190 free_irq(hwif->irq, hwif);
191 191
192 ide_remove_port_from_hwgroup(hwif);
193
194 device_unregister(hwif->portdev); 192 device_unregister(hwif->portdev);
195 device_unregister(&hwif->gendev); 193 device_unregister(&hwif->gendev);
196 wait_for_completion(&hwif->gendev_rel_comp); 194 wait_for_completion(&hwif->gendev_rel_comp);
@@ -315,7 +313,6 @@ static int set_pio_mode_abuse(ide_hwif_t *hwif, u8 req_pio)
315static int set_pio_mode(ide_drive_t *drive, int arg) 313static int set_pio_mode(ide_drive_t *drive, int arg)
316{ 314{
317 ide_hwif_t *hwif = drive->hwif; 315 ide_hwif_t *hwif = drive->hwif;
318 ide_hwgroup_t *hwgroup = hwif->hwgroup;
319 const struct ide_port_ops *port_ops = hwif->port_ops; 316 const struct ide_port_ops *port_ops = hwif->port_ops;
320 317
321 if (arg < 0 || arg > 255) 318 if (arg < 0 || arg > 255)
@@ -330,9 +327,9 @@ static int set_pio_mode(ide_drive_t *drive, int arg)
330 unsigned long flags; 327 unsigned long flags;
331 328
332 /* take lock for IDE_DFLAG_[NO_]UNMASK/[NO_]IO_32BIT */ 329 /* take lock for IDE_DFLAG_[NO_]UNMASK/[NO_]IO_32BIT */
333 spin_lock_irqsave(&hwgroup->lock, flags); 330 spin_lock_irqsave(&hwif->lock, flags);
334 port_ops->set_pio_mode(drive, arg); 331 port_ops->set_pio_mode(drive, arg);
335 spin_unlock_irqrestore(&hwgroup->lock, flags); 332 spin_unlock_irqrestore(&hwif->lock, flags);
336 } else 333 } else
337 port_ops->set_pio_mode(drive, arg); 334 port_ops->set_pio_mode(drive, arg);
338 } else { 335 } else {
diff --git a/drivers/ide/pdc202xx_old.c b/drivers/ide/pdc202xx_old.c
index 624e62e5cc9a..072ef70bf061 100644
--- a/drivers/ide/pdc202xx_old.c
+++ b/drivers/ide/pdc202xx_old.c
@@ -169,8 +169,8 @@ static void pdc202xx_dma_start(ide_drive_t *drive)
169 if (drive->current_speed > XFER_UDMA_2) 169 if (drive->current_speed > XFER_UDMA_2)
170 pdc_old_enable_66MHz_clock(drive->hwif); 170 pdc_old_enable_66MHz_clock(drive->hwif);
171 if (drive->media != ide_disk || (drive->dev_flags & IDE_DFLAG_LBA48)) { 171 if (drive->media != ide_disk || (drive->dev_flags & IDE_DFLAG_LBA48)) {
172 struct request *rq = HWGROUP(drive)->rq;
173 ide_hwif_t *hwif = HWIF(drive); 172 ide_hwif_t *hwif = HWIF(drive);
173 struct request *rq = hwif->rq;
174 unsigned long high_16 = hwif->extra_base - 16; 174 unsigned long high_16 = hwif->extra_base - 16;
175 unsigned long atapi_reg = high_16 + (hwif->channel ? 0x24 : 0x20); 175 unsigned long atapi_reg = high_16 + (hwif->channel ? 0x24 : 0x20);
176 u32 word_count = 0; 176 u32 word_count = 0;
diff --git a/drivers/ide/pmac.c b/drivers/ide/pmac.c
index 7c481bb56fab..899b96baf215 100644
--- a/drivers/ide/pmac.c
+++ b/drivers/ide/pmac.c
@@ -1516,7 +1516,7 @@ pmac_ide_dma_setup(ide_drive_t *drive)
1516 ide_hwif_t *hwif = HWIF(drive); 1516 ide_hwif_t *hwif = HWIF(drive);
1517 pmac_ide_hwif_t *pmif = 1517 pmac_ide_hwif_t *pmif =
1518 (pmac_ide_hwif_t *)dev_get_drvdata(hwif->gendev.parent); 1518 (pmac_ide_hwif_t *)dev_get_drvdata(hwif->gendev.parent);
1519 struct request *rq = HWGROUP(drive)->rq; 1519 struct request *rq = hwif->rq;
1520 u8 unit = drive->dn & 1, ata4 = (pmif->kind == controller_kl_ata4); 1520 u8 unit = drive->dn & 1, ata4 = (pmif->kind == controller_kl_ata4);
1521 1521
1522 if (!pmac_ide_build_dmatable(drive, rq)) { 1522 if (!pmac_ide_build_dmatable(drive, rq)) {
diff --git a/drivers/ide/scc_pata.c b/drivers/ide/scc_pata.c
index 0f48f9dacfa5..e966113fd569 100644
--- a/drivers/ide/scc_pata.c
+++ b/drivers/ide/scc_pata.c
@@ -316,7 +316,7 @@ static void scc_dma_host_set(ide_drive_t *drive, int on)
316static int scc_dma_setup(ide_drive_t *drive) 316static int scc_dma_setup(ide_drive_t *drive)
317{ 317{
318 ide_hwif_t *hwif = drive->hwif; 318 ide_hwif_t *hwif = drive->hwif;
319 struct request *rq = HWGROUP(drive)->rq; 319 struct request *rq = hwif->rq;
320 unsigned int reading; 320 unsigned int reading;
321 u8 dma_stat; 321 u8 dma_stat;
322 322
@@ -405,7 +405,7 @@ static int scc_dma_end(ide_drive_t *drive)
405 drive->name); 405 drive->name);
406 data_loss = 1; 406 data_loss = 1;
407 if (retry++) { 407 if (retry++) {
408 struct request *rq = HWGROUP(drive)->rq; 408 struct request *rq = hwif->rq;
409 int unit; 409 int unit;
410 /* ERROR_RESET and drive->crc_count are needed 410 /* ERROR_RESET and drive->crc_count are needed
411 * to reduce DMA transfer mode in retry process. 411 * to reduce DMA transfer mode in retry process.
diff --git a/drivers/ide/sgiioc4.c b/drivers/ide/sgiioc4.c
index a687a7dfea6f..c68b71b1087b 100644
--- a/drivers/ide/sgiioc4.c
+++ b/drivers/ide/sgiioc4.c
@@ -492,7 +492,7 @@ use_pio_instead:
492 492
493static int sgiioc4_dma_setup(ide_drive_t *drive) 493static int sgiioc4_dma_setup(ide_drive_t *drive)
494{ 494{
495 struct request *rq = HWGROUP(drive)->rq; 495 struct request *rq = drive->hwif->rq;
496 unsigned int count = 0; 496 unsigned int count = 0;
497 int ddir; 497 int ddir;
498 498
diff --git a/drivers/ide/tc86c001.c b/drivers/ide/tc86c001.c
index 93e2cce4b296..accb379bcad6 100644
--- a/drivers/ide/tc86c001.c
+++ b/drivers/ide/tc86c001.c
@@ -64,11 +64,10 @@ static int tc86c001_timer_expiry(ide_drive_t *drive)
64{ 64{
65 ide_hwif_t *hwif = HWIF(drive); 65 ide_hwif_t *hwif = HWIF(drive);
66 ide_expiry_t *expiry = ide_get_hwifdata(hwif); 66 ide_expiry_t *expiry = ide_get_hwifdata(hwif);
67 ide_hwgroup_t *hwgroup = HWGROUP(drive);
68 u8 dma_stat = inb(hwif->dma_base + ATA_DMA_STATUS); 67 u8 dma_stat = inb(hwif->dma_base + ATA_DMA_STATUS);
69 68
70 /* Restore a higher level driver's expiry handler first. */ 69 /* Restore a higher level driver's expiry handler first. */
71 hwgroup->expiry = expiry; 70 hwif->expiry = expiry;
72 71
73 if ((dma_stat & 5) == 1) { /* DMA active and no interrupt */ 72 if ((dma_stat & 5) == 1) { /* DMA active and no interrupt */
74 unsigned long sc_base = hwif->config_data; 73 unsigned long sc_base = hwif->config_data;
@@ -111,10 +110,9 @@ static int tc86c001_timer_expiry(ide_drive_t *drive)
111static void tc86c001_dma_start(ide_drive_t *drive) 110static void tc86c001_dma_start(ide_drive_t *drive)
112{ 111{
113 ide_hwif_t *hwif = HWIF(drive); 112 ide_hwif_t *hwif = HWIF(drive);
114 ide_hwgroup_t *hwgroup = HWGROUP(drive);
115 unsigned long sc_base = hwif->config_data; 113 unsigned long sc_base = hwif->config_data;
116 unsigned long twcr_port = sc_base + (drive->dn ? 0x06 : 0x04); 114 unsigned long twcr_port = sc_base + (drive->dn ? 0x06 : 0x04);
117 unsigned long nsectors = hwgroup->rq->nr_sectors; 115 unsigned long nsectors = hwif->rq->nr_sectors;
118 116
119 /* 117 /*
120 * We have to manually load the sector count and size into 118 * We have to manually load the sector count and size into
@@ -125,8 +123,8 @@ static void tc86c001_dma_start(ide_drive_t *drive)
125 outw(SECTOR_SIZE / 2, twcr_port); /* Transfer Word Count 1/2 */ 123 outw(SECTOR_SIZE / 2, twcr_port); /* Transfer Word Count 1/2 */
126 124
127 /* Install our timeout expiry hook, saving the current handler... */ 125 /* Install our timeout expiry hook, saving the current handler... */
128 ide_set_hwifdata(hwif, hwgroup->expiry); 126 ide_set_hwifdata(hwif, hwif->expiry);
129 hwgroup->expiry = &tc86c001_timer_expiry; 127 hwif->expiry = &tc86c001_timer_expiry;
130 128
131 ide_dma_start(drive); 129 ide_dma_start(drive);
132} 130}
diff --git a/drivers/ide/trm290.c b/drivers/ide/trm290.c
index 2a5ea90cf8b8..79a03df118d8 100644
--- a/drivers/ide/trm290.c
+++ b/drivers/ide/trm290.c
@@ -184,7 +184,7 @@ static void trm290_dma_exec_cmd(ide_drive_t *drive, u8 command)
184static int trm290_dma_setup(ide_drive_t *drive) 184static int trm290_dma_setup(ide_drive_t *drive)
185{ 185{
186 ide_hwif_t *hwif = drive->hwif; 186 ide_hwif_t *hwif = drive->hwif;
187 struct request *rq = hwif->hwgroup->rq; 187 struct request *rq = hwif->rq;
188 unsigned int count, rw; 188 unsigned int count, rw;
189 189
190 if (rq_data_dir(rq)) { 190 if (rq_data_dir(rq)) {
diff --git a/drivers/ide/tx4939ide.c b/drivers/ide/tx4939ide.c
index 4a8c5a21bd4c..1ac27ac7283b 100644
--- a/drivers/ide/tx4939ide.c
+++ b/drivers/ide/tx4939ide.c
@@ -293,7 +293,7 @@ static int tx4939ide_dma_setup(ide_drive_t *drive)
293{ 293{
294 ide_hwif_t *hwif = drive->hwif; 294 ide_hwif_t *hwif = drive->hwif;
295 void __iomem *base = TX4939IDE_BASE(hwif); 295 void __iomem *base = TX4939IDE_BASE(hwif);
296 struct request *rq = hwif->hwgroup->rq; 296 struct request *rq = hwif->rq;
297 u8 reading; 297 u8 reading;
298 int nent; 298 int nent;
299 299
diff --git a/drivers/ide/umc8672.c b/drivers/ide/umc8672.c
index e29978cf6197..0608d41fb6d0 100644
--- a/drivers/ide/umc8672.c
+++ b/drivers/ide/umc8672.c
@@ -106,22 +106,21 @@ static void umc_set_speeds(u8 speeds[])
106 106
107static void umc_set_pio_mode(ide_drive_t *drive, const u8 pio) 107static void umc_set_pio_mode(ide_drive_t *drive, const u8 pio)
108{ 108{
109 ide_hwif_t *hwif = drive->hwif; 109 ide_hwif_t *hwif = drive->hwif, *mate = hwif->mate;
110 ide_hwgroup_t *mate_hwgroup = hwif->mate ? hwif->mate->hwgroup : NULL;
111 unsigned long uninitialized_var(flags); 110 unsigned long uninitialized_var(flags);
112 111
113 printk("%s: setting umc8672 to PIO mode%d (speed %d)\n", 112 printk("%s: setting umc8672 to PIO mode%d (speed %d)\n",
114 drive->name, pio, pio_to_umc[pio]); 113 drive->name, pio, pio_to_umc[pio]);
115 if (mate_hwgroup) 114 if (mate)
116 spin_lock_irqsave(&mate_hwgroup->lock, flags); 115 spin_lock_irqsave(&mate->lock, flags);
117 if (mate_hwgroup && mate_hwgroup->handler) { 116 if (mate && mate->handler) {
118 printk(KERN_ERR "umc8672: other interface is busy: exiting tune_umc()\n"); 117 printk(KERN_ERR "umc8672: other interface is busy: exiting tune_umc()\n");
119 } else { 118 } else {
120 current_speeds[drive->name[2] - 'a'] = pio_to_umc[pio]; 119 current_speeds[drive->name[2] - 'a'] = pio_to_umc[pio];
121 umc_set_speeds(current_speeds); 120 umc_set_speeds(current_speeds);
122 } 121 }
123 if (mate_hwgroup) 122 if (mate)
124 spin_unlock_irqrestore(&mate_hwgroup->lock, flags); 123 spin_unlock_irqrestore(&mate->lock, flags);
125} 124}
126 125
127static const struct ide_port_ops umc8672_port_ops = { 126static const struct ide_port_ops umc8672_port_ops = {