aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ide/ide-iops.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/ide/ide-iops.c')
-rw-r--r--drivers/ide/ide-iops.c69
1 files changed, 32 insertions, 37 deletions
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