diff options
77 files changed, 1989 insertions, 2849 deletions
diff --git a/Documentation/ide/ChangeLog.ide-tape.1995-2002 b/Documentation/ide/ChangeLog.ide-tape.1995-2002 new file mode 100644 index 000000000000..877fac8770b3 --- /dev/null +++ b/Documentation/ide/ChangeLog.ide-tape.1995-2002 | |||
| @@ -0,0 +1,257 @@ | |||
| 1 | /* | ||
| 2 | * Ver 0.1 Nov 1 95 Pre-working code :-) | ||
| 3 | * Ver 0.2 Nov 23 95 A short backup (few megabytes) and restore procedure | ||
| 4 | * was successful ! (Using tar cvf ... on the block | ||
| 5 | * device interface). | ||
| 6 | * A longer backup resulted in major swapping, bad | ||
| 7 | * overall Linux performance and eventually failed as | ||
| 8 | * we received non serial read-ahead requests from the | ||
| 9 | * buffer cache. | ||
| 10 | * Ver 0.3 Nov 28 95 Long backups are now possible, thanks to the | ||
| 11 | * character device interface. Linux's responsiveness | ||
| 12 | * and performance doesn't seem to be much affected | ||
| 13 | * from the background backup procedure. | ||
| 14 | * Some general mtio.h magnetic tape operations are | ||
| 15 | * now supported by our character device. As a result, | ||
| 16 | * popular tape utilities are starting to work with | ||
| 17 | * ide tapes :-) | ||
| 18 | * The following configurations were tested: | ||
| 19 | * 1. An IDE ATAPI TAPE shares the same interface | ||
| 20 | * and irq with an IDE ATAPI CDROM. | ||
| 21 | * 2. An IDE ATAPI TAPE shares the same interface | ||
| 22 | * and irq with a normal IDE disk. | ||
| 23 | * Both configurations seemed to work just fine ! | ||
| 24 | * However, to be on the safe side, it is meanwhile | ||
| 25 | * recommended to give the IDE TAPE its own interface | ||
| 26 | * and irq. | ||
| 27 | * The one thing which needs to be done here is to | ||
| 28 | * add a "request postpone" feature to ide.c, | ||
| 29 | * so that we won't have to wait for the tape to finish | ||
| 30 | * performing a long media access (DSC) request (such | ||
| 31 | * as a rewind) before we can access the other device | ||
| 32 | * on the same interface. This effect doesn't disturb | ||
| 33 | * normal operation most of the time because read/write | ||
| 34 | * requests are relatively fast, and once we are | ||
| 35 | * performing one tape r/w request, a lot of requests | ||
| 36 | * from the other device can be queued and ide.c will | ||
| 37 | * service all of them after this single tape request. | ||
| 38 | * Ver 1.0 Dec 11 95 Integrated into Linux 1.3.46 development tree. | ||
| 39 | * On each read / write request, we now ask the drive | ||
| 40 | * if we can transfer a constant number of bytes | ||
| 41 | * (a parameter of the drive) only to its buffers, | ||
| 42 | * without causing actual media access. If we can't, | ||
| 43 | * we just wait until we can by polling the DSC bit. | ||
| 44 | * This ensures that while we are not transferring | ||
| 45 | * more bytes than the constant referred to above, the | ||
| 46 | * interrupt latency will not become too high and | ||
| 47 | * we won't cause an interrupt timeout, as happened | ||
| 48 | * occasionally in the previous version. | ||
| 49 | * While polling for DSC, the current request is | ||
| 50 | * postponed and ide.c is free to handle requests from | ||
| 51 | * the other device. This is handled transparently to | ||
| 52 | * ide.c. The hwgroup locking method which was used | ||
| 53 | * in the previous version was removed. | ||
| 54 | * Use of new general features which are provided by | ||
| 55 | * ide.c for use with atapi devices. | ||
| 56 | * (Programming done by Mark Lord) | ||
| 57 | * Few potential bug fixes (Again, suggested by Mark) | ||
| 58 | * Single character device data transfers are now | ||
| 59 | * not limited in size, as they were before. | ||
| 60 | * We are asking the tape about its recommended | ||
| 61 | * transfer unit and send a larger data transfer | ||
| 62 | * as several transfers of the above size. | ||
| 63 | * For best results, use an integral number of this | ||
| 64 | * basic unit (which is shown during driver | ||
| 65 | * initialization). I will soon add an ioctl to get | ||
| 66 | * this important parameter. | ||
| 67 | * Our data transfer buffer is allocated on startup, | ||
| 68 | * rather than before each data transfer. This should | ||
| 69 | * ensure that we will indeed have a data buffer. | ||
| 70 | * Ver 1.1 Dec 14 95 Fixed random problems which occurred when the tape | ||
| 71 | * shared an interface with another device. | ||
| 72 | * (poll_for_dsc was a complete mess). | ||
| 73 | * Removed some old (non-active) code which had | ||
| 74 | * to do with supporting buffer cache originated | ||
| 75 | * requests. | ||
| 76 | * The block device interface can now be opened, so | ||
| 77 | * that general ide driver features like the unmask | ||
| 78 | * interrupts flag can be selected with an ioctl. | ||
| 79 | * This is the only use of the block device interface. | ||
| 80 | * New fast pipelined operation mode (currently only on | ||
| 81 | * writes). When using the pipelined mode, the | ||
| 82 | * throughput can potentially reach the maximum | ||
| 83 | * tape supported throughput, regardless of the | ||
| 84 | * user backup program. On my tape drive, it sometimes | ||
| 85 | * boosted performance by a factor of 2. Pipelined | ||
| 86 | * mode is enabled by default, but since it has a few | ||
| 87 | * downfalls as well, you may want to disable it. | ||
| 88 | * A short explanation of the pipelined operation mode | ||
| 89 | * is available below. | ||
| 90 | * Ver 1.2 Jan 1 96 Eliminated pipelined mode race condition. | ||
| 91 | * Added pipeline read mode. As a result, restores | ||
| 92 | * are now as fast as backups. | ||
| 93 | * Optimized shared interface behavior. The new behavior | ||
| 94 | * typically results in better IDE bus efficiency and | ||
| 95 | * higher tape throughput. | ||
| 96 | * Pre-calculation of the expected read/write request | ||
| 97 | * service time, based on the tape's parameters. In | ||
| 98 | * the pipelined operation mode, this allows us to | ||
| 99 | * adjust our polling frequency to a much lower value, | ||
| 100 | * and thus to dramatically reduce our load on Linux, | ||
| 101 | * without any decrease in performance. | ||
| 102 | * Implemented additional mtio.h operations. | ||
| 103 | * The recommended user block size is returned by | ||
| 104 | * the MTIOCGET ioctl. | ||
| 105 | * Additional minor changes. | ||
| 106 | * Ver 1.3 Feb 9 96 Fixed pipelined read mode bug which prevented the | ||
| 107 | * use of some block sizes during a restore procedure. | ||
| 108 | * The character device interface will now present a | ||
| 109 | * continuous view of the media - any mix of block sizes | ||
| 110 | * during a backup/restore procedure is supported. The | ||
| 111 | * driver will buffer the requests internally and | ||
| 112 | * convert them to the tape's recommended transfer | ||
| 113 | * unit, making performance almost independent of the | ||
| 114 | * chosen user block size. | ||
| 115 | * Some improvements in error recovery. | ||
| 116 | * By cooperating with ide-dma.c, bus mastering DMA can | ||
| 117 | * now sometimes be used with IDE tape drives as well. | ||
| 118 | * Bus mastering DMA has the potential to dramatically | ||
| 119 | * reduce the CPU's overhead when accessing the device, | ||
| 120 | * and can be enabled by using hdparm -d1 on the tape's | ||
| 121 | * block device interface. For more info, read the | ||
| 122 | * comments in ide-dma.c. | ||
| 123 | * Ver 1.4 Mar 13 96 Fixed serialize support. | ||
| 124 | * Ver 1.5 Apr 12 96 Fixed shared interface operation, broken in 1.3.85. | ||
| 125 | * Fixed pipelined read mode inefficiency. | ||
| 126 | * Fixed nasty null dereferencing bug. | ||
| 127 | * Ver 1.6 Aug 16 96 Fixed FPU usage in the driver. | ||
| 128 | * Fixed end of media bug. | ||
| 129 | * Ver 1.7 Sep 10 96 Minor changes for the CONNER CTT8000-A model. | ||
| 130 | * Ver 1.8 Sep 26 96 Attempt to find a better balance between good | ||
| 131 | * interactive response and high system throughput. | ||
| 132 | * Ver 1.9 Nov 5 96 Automatically cross encountered filemarks rather | ||
| 133 | * than requiring an explicit FSF command. | ||
| 134 | * Abort pending requests at end of media. | ||
| 135 | * MTTELL was sometimes returning incorrect results. | ||
| 136 | * Return the real block size in the MTIOCGET ioctl. | ||
| 137 | * Some error recovery bug fixes. | ||
| 138 | * Ver 1.10 Nov 5 96 Major reorganization. | ||
| 139 | * Reduced CPU overhead a bit by eliminating internal | ||
| 140 | * bounce buffers. | ||
| 141 | * Added module support. | ||
| 142 | * Added multiple tape drives support. | ||
| 143 | * Added partition support. | ||
| 144 | * Rewrote DSC handling. | ||
| 145 | * Some portability fixes. | ||
| 146 | * Removed ide-tape.h. | ||
| 147 | * Additional minor changes. | ||
| 148 | * Ver 1.11 Dec 2 96 Bug fix in previous DSC timeout handling. | ||
| 149 | * Use ide_stall_queue() for DSC overlap. | ||
| 150 | * Use the maximum speed rather than the current speed | ||
| 151 | * to compute the request service time. | ||
| 152 | * Ver 1.12 Dec 7 97 Fix random memory overwriting and/or last block data | ||
| 153 | * corruption, which could occur if the total number | ||
| 154 | * of bytes written to the tape was not an integral | ||
| 155 | * number of tape blocks. | ||
| 156 | * Add support for INTERRUPT DRQ devices. | ||
| 157 | * Ver 1.13 Jan 2 98 Add "speed == 0" work-around for HP COLORADO 5GB | ||
| 158 | * Ver 1.14 Dec 30 98 Partial fixes for the Sony/AIWA tape drives. | ||
| 159 | * Replace cli()/sti() with hwgroup spinlocks. | ||
| 160 | * Ver 1.15 Mar 25 99 Fix SMP race condition by replacing hwgroup | ||
| 161 | * spinlock with private per-tape spinlock. | ||
| 162 | * Ver 1.16 Sep 1 99 Add OnStream tape support. | ||
| 163 | * Abort read pipeline on EOD. | ||
| 164 | * Wait for the tape to become ready in case it returns | ||
| 165 | * "in the process of becoming ready" on open(). | ||
| 166 | * Fix zero padding of the last written block in | ||
| 167 | * case the tape block size is larger than PAGE_SIZE. | ||
| 168 | * Decrease the default disconnection time to tn. | ||
| 169 | * Ver 1.16e Oct 3 99 Minor fixes. | ||
| 170 | * Ver 1.16e1 Oct 13 99 Patches by Arnold Niessen, | ||
| 171 | * niessen@iae.nl / arnold.niessen@philips.com | ||
| 172 | * GO-1) Undefined code in idetape_read_position | ||
| 173 | * according to Gadi's email | ||
| 174 | * AJN-1) Minor fix asc == 11 should be asc == 0x11 | ||
| 175 | * in idetape_issue_packet_command (did effect | ||
| 176 | * debugging output only) | ||
| 177 | * AJN-2) Added more debugging output, and | ||
| 178 | * added ide-tape: where missing. I would also | ||
| 179 | * like to add tape->name where possible | ||
| 180 | * AJN-3) Added different debug_level's | ||
| 181 | * via /proc/ide/hdc/settings | ||
| 182 | * "debug_level" determines amount of debugging output; | ||
| 183 | * can be changed using /proc/ide/hdx/settings | ||
| 184 | * 0 : almost no debugging output | ||
| 185 | * 1 : 0+output errors only | ||
| 186 | * 2 : 1+output all sensekey/asc | ||
| 187 | * 3 : 2+follow all chrdev related procedures | ||
| 188 | * 4 : 3+follow all procedures | ||
| 189 | * 5 : 4+include pc_stack rq_stack info | ||
| 190 | * 6 : 5+USE_COUNT updates | ||
| 191 | * AJN-4) Fixed timeout for retension in idetape_queue_pc_tail | ||
| 192 | * from 5 to 10 minutes | ||
| 193 | * AJN-5) Changed maximum number of blocks to skip when | ||
| 194 | * reading tapes with multiple consecutive write | ||
| 195 | * errors from 100 to 1000 in idetape_get_logical_blk | ||
| 196 | * Proposed changes to code: | ||
| 197 | * 1) output "logical_blk_num" via /proc | ||
| 198 | * 2) output "current_operation" via /proc | ||
| 199 | * 3) Either solve or document the fact that `mt rewind' is | ||
| 200 | * required after reading from /dev/nhtx to be | ||
| 201 | * able to rmmod the idetape module; | ||
| 202 | * Also, sometimes an application finishes but the | ||
| 203 | * device remains `busy' for some time. Same cause ? | ||
| 204 | * Proposed changes to release-notes: | ||
| 205 | * 4) write a simple `quickstart' section in the | ||
| 206 | * release notes; I volunteer if you don't want to | ||
| 207 | * 5) include a pointer to video4linux in the doc | ||
| 208 | * to stimulate video applications | ||
| 209 | * 6) release notes lines 331 and 362: explain what happens | ||
| 210 | * if the application data rate is higher than 1100 KB/s; | ||
| 211 | * similar approach to lower-than-500 kB/s ? | ||
| 212 | * 7) 6.6 Comparison; wouldn't it be better to allow different | ||
| 213 | * strategies for read and write ? | ||
| 214 | * Wouldn't it be better to control the tape buffer | ||
| 215 | * contents instead of the bandwidth ? | ||
| 216 | * 8) line 536: replace will by would (if I understand | ||
| 217 | * this section correctly, a hypothetical and unwanted situation | ||
| 218 | * is being described) | ||
| 219 | * Ver 1.16f Dec 15 99 Change place of the secondary OnStream header frames. | ||
| 220 | * Ver 1.17 Nov 2000 / Jan 2001 Marcel Mol, marcel@mesa.nl | ||
| 221 | * - Add idetape_onstream_mode_sense_tape_parameter_page | ||
| 222 | * function to get tape capacity in frames: tape->capacity. | ||
| 223 | * - Add support for DI-50 drives( or any DI- drive). | ||
| 224 | * - 'workaround' for read error/blank block around block 3000. | ||
| 225 | * - Implement Early warning for end of media for Onstream. | ||
| 226 | * - Cosmetic code changes for readability. | ||
| 227 | * - Idetape_position_tape should not use SKIP bit during | ||
| 228 | * Onstream read recovery. | ||
| 229 | * - Add capacity, logical_blk_num and first/last_frame_position | ||
| 230 | * to /proc/ide/hd?/settings. | ||
| 231 | * - Module use count was gone in the Linux 2.4 driver. | ||
| 232 | * Ver 1.17a Apr 2001 Willem Riede osst@riede.org | ||
| 233 | * - Get drive's actual block size from mode sense block descriptor | ||
| 234 | * - Limit size of pipeline | ||
| 235 | * Ver 1.17b Oct 2002 Alan Stern <stern@rowland.harvard.edu> | ||
| 236 | * Changed IDETAPE_MIN_PIPELINE_STAGES to 1 and actually used | ||
| 237 | * it in the code! | ||
| 238 | * Actually removed aborted stages in idetape_abort_pipeline | ||
| 239 | * instead of just changing the command code. | ||
| 240 | * Made the transfer byte count for Request Sense equal to the | ||
| 241 | * actual length of the data transfer. | ||
| 242 | * Changed handling of partial data transfers: they do not | ||
| 243 | * cause DMA errors. | ||
| 244 | * Moved initiation of DMA transfers to the correct place. | ||
| 245 | * Removed reference to unallocated memory. | ||
| 246 | * Made __idetape_discard_read_pipeline return the number of | ||
| 247 | * sectors skipped, not the number of stages. | ||
| 248 | * Replaced errant kfree() calls with __idetape_kfree_stage(). | ||
| 249 | * Fixed off-by-one error in testing the pipeline length. | ||
| 250 | * Fixed handling of filemarks in the read pipeline. | ||
| 251 | * Small code optimization for MTBSF and MTBSFM ioctls. | ||
| 252 | * Don't try to unlock the door during device close if is | ||
| 253 | * already unlocked! | ||
| 254 | * Cosmetic fixes to miscellaneous debugging output messages. | ||
| 255 | * Set the minimum /proc/ide/hd?/settings values for "pipeline", | ||
| 256 | * "pipeline_min", and "pipeline_max" to 1. | ||
| 257 | */ | ||
diff --git a/Documentation/ide/ide-tape.txt b/Documentation/ide/ide-tape.txt new file mode 100644 index 000000000000..658f271a373f --- /dev/null +++ b/Documentation/ide/ide-tape.txt | |||
| @@ -0,0 +1,146 @@ | |||
| 1 | /* | ||
| 2 | * IDE ATAPI streaming tape driver. | ||
| 3 | * | ||
| 4 | * This driver is a part of the Linux ide driver. | ||
| 5 | * | ||
| 6 | * The driver, in co-operation with ide.c, basically traverses the | ||
| 7 | * request-list for the block device interface. The character device | ||
| 8 | * interface, on the other hand, creates new requests, adds them | ||
| 9 | * to the request-list of the block device, and waits for their completion. | ||
| 10 | * | ||
| 11 | * Pipelined operation mode is now supported on both reads and writes. | ||
| 12 | * | ||
| 13 | * The block device major and minor numbers are determined from the | ||
| 14 | * tape's relative position in the ide interfaces, as explained in ide.c. | ||
| 15 | * | ||
| 16 | * The character device interface consists of the following devices: | ||
| 17 | * | ||
| 18 | * ht0 major 37, minor 0 first IDE tape, rewind on close. | ||
| 19 | * ht1 major 37, minor 1 second IDE tape, rewind on close. | ||
| 20 | * ... | ||
| 21 | * nht0 major 37, minor 128 first IDE tape, no rewind on close. | ||
| 22 | * nht1 major 37, minor 129 second IDE tape, no rewind on close. | ||
| 23 | * ... | ||
| 24 | * | ||
| 25 | * The general magnetic tape commands compatible interface, as defined by | ||
| 26 | * include/linux/mtio.h, is accessible through the character device. | ||
| 27 | * | ||
| 28 | * General ide driver configuration options, such as the interrupt-unmask | ||
| 29 | * flag, can be configured by issuing an ioctl to the block device interface, | ||
| 30 | * as any other ide device. | ||
| 31 | * | ||
| 32 | * Our own ide-tape ioctl's can be issued to either the block device or | ||
| 33 | * the character device interface. | ||
| 34 | * | ||
| 35 | * Maximal throughput with minimal bus load will usually be achieved in the | ||
| 36 | * following scenario: | ||
| 37 | * | ||
| 38 | * 1. ide-tape is operating in the pipelined operation mode. | ||
| 39 | * 2. No buffering is performed by the user backup program. | ||
| 40 | * | ||
| 41 | * Testing was done with a 2 GB CONNER CTMA 4000 IDE ATAPI Streaming Tape Drive. | ||
| 42 | * | ||
| 43 | * Here are some words from the first releases of hd.c, which are quoted | ||
| 44 | * in ide.c and apply here as well: | ||
| 45 | * | ||
| 46 | * | Special care is recommended. Have Fun! | ||
| 47 | * | ||
| 48 | * | ||
| 49 | * An overview of the pipelined operation mode. | ||
| 50 | * | ||
| 51 | * In the pipelined write mode, we will usually just add requests to our | ||
| 52 | * pipeline and return immediately, before we even start to service them. The | ||
| 53 | * user program will then have enough time to prepare the next request while | ||
| 54 | * we are still busy servicing previous requests. In the pipelined read mode, | ||
| 55 | * the situation is similar - we add read-ahead requests into the pipeline, | ||
| 56 | * before the user even requested them. | ||
| 57 | * | ||
| 58 | * The pipeline can be viewed as a "safety net" which will be activated when | ||
| 59 | * the system load is high and prevents the user backup program from keeping up | ||
| 60 | * with the current tape speed. At this point, the pipeline will get | ||
| 61 | * shorter and shorter but the tape will still be streaming at the same speed. | ||
| 62 | * Assuming we have enough pipeline stages, the system load will hopefully | ||
| 63 | * decrease before the pipeline is completely empty, and the backup program | ||
| 64 | * will be able to "catch up" and refill the pipeline again. | ||
| 65 | * | ||
| 66 | * When using the pipelined mode, it would be best to disable any type of | ||
| 67 | * buffering done by the user program, as ide-tape already provides all the | ||
| 68 | * benefits in the kernel, where it can be done in a more efficient way. | ||
| 69 | * As we will usually not block the user program on a request, the most | ||
| 70 | * efficient user code will then be a simple read-write-read-... cycle. | ||
| 71 | * Any additional logic will usually just slow down the backup process. | ||
| 72 | * | ||
| 73 | * Using the pipelined mode, I get a constant over 400 KBps throughput, | ||
| 74 | * which seems to be the maximum throughput supported by my tape. | ||
| 75 | * | ||
| 76 | * However, there are some downfalls: | ||
| 77 | * | ||
| 78 | * 1. We use memory (for data buffers) in proportional to the number | ||
| 79 | * of pipeline stages (each stage is about 26 KB with my tape). | ||
| 80 | * 2. In the pipelined write mode, we cheat and postpone error codes | ||
| 81 | * to the user task. In read mode, the actual tape position | ||
| 82 | * will be a bit further than the last requested block. | ||
| 83 | * | ||
| 84 | * Concerning (1): | ||
| 85 | * | ||
| 86 | * 1. We allocate stages dynamically only when we need them. When | ||
| 87 | * we don't need them, we don't consume additional memory. In | ||
| 88 | * case we can't allocate stages, we just manage without them | ||
| 89 | * (at the expense of decreased throughput) so when Linux is | ||
| 90 | * tight in memory, we will not pose additional difficulties. | ||
| 91 | * | ||
| 92 | * 2. The maximum number of stages (which is, in fact, the maximum | ||
| 93 | * amount of memory) which we allocate is limited by the compile | ||
| 94 | * time parameter IDETAPE_MAX_PIPELINE_STAGES. | ||
| 95 | * | ||
| 96 | * 3. The maximum number of stages is a controlled parameter - We | ||
| 97 | * don't start from the user defined maximum number of stages | ||
| 98 | * but from the lower IDETAPE_MIN_PIPELINE_STAGES (again, we | ||
| 99 | * will not even allocate this amount of stages if the user | ||
| 100 | * program can't handle the speed). We then implement a feedback | ||
| 101 | * loop which checks if the pipeline is empty, and if it is, we | ||
| 102 | * increase the maximum number of stages as necessary until we | ||
| 103 | * reach the optimum value which just manages to keep the tape | ||
| 104 | * busy with minimum allocated memory or until we reach | ||
| 105 | * IDETAPE_MAX_PIPELINE_STAGES. | ||
| 106 | * | ||
| 107 | * Concerning (2): | ||
| 108 | * | ||
| 109 | * In pipelined write mode, ide-tape can not return accurate error codes | ||
| 110 | * to the user program since we usually just add the request to the | ||
| 111 | * pipeline without waiting for it to be serviced. In case an error | ||
| 112 | * occurs, I will report it on the next user request. | ||
| 113 | * | ||
| 114 | * In the pipelined read mode, subsequent read requests or forward | ||
| 115 | * filemark spacing will perform correctly, as we preserve all blocks | ||
| 116 | * and filemarks which we encountered during our excess read-ahead. | ||
| 117 | * | ||
| 118 | * For accurate tape positioning and error reporting, disabling | ||
| 119 | * pipelined mode might be the best option. | ||
| 120 | * | ||
| 121 | * You can enable/disable/tune the pipelined operation mode by adjusting | ||
| 122 | * the compile time parameters below. | ||
| 123 | * | ||
| 124 | * | ||
| 125 | * Possible improvements. | ||
| 126 | * | ||
| 127 | * 1. Support for the ATAPI overlap protocol. | ||
| 128 | * | ||
| 129 | * In order to maximize bus throughput, we currently use the DSC | ||
| 130 | * overlap method which enables ide.c to service requests from the | ||
| 131 | * other device while the tape is busy executing a command. The | ||
| 132 | * DSC overlap method involves polling the tape's status register | ||
| 133 | * for the DSC bit, and servicing the other device while the tape | ||
| 134 | * isn't ready. | ||
| 135 | * | ||
| 136 | * In the current QIC development standard (December 1995), | ||
| 137 | * it is recommended that new tape drives will *in addition* | ||
| 138 | * implement the ATAPI overlap protocol, which is used for the | ||
| 139 | * same purpose - efficient use of the IDE bus, but is interrupt | ||
| 140 | * driven and thus has much less CPU overhead. | ||
| 141 | * | ||
| 142 | * ATAPI overlap is likely to be supported in most new ATAPI | ||
| 143 | * devices, including new ATAPI cdroms, and thus provides us | ||
| 144 | * a method by which we can achieve higher throughput when | ||
| 145 | * sharing a (fast) ATA-2 disk with any (slow) new ATAPI device. | ||
| 146 | */ | ||
diff --git a/drivers/ide/Kconfig b/drivers/ide/Kconfig index e42a465f5717..45b26ed351cf 100644 --- a/drivers/ide/Kconfig +++ b/drivers/ide/Kconfig | |||
| @@ -216,8 +216,7 @@ config BLK_DEV_IDECD_VERBOSE_ERRORS | |||
| 216 | memory, though. | 216 | memory, though. |
| 217 | 217 | ||
| 218 | config BLK_DEV_IDETAPE | 218 | config BLK_DEV_IDETAPE |
| 219 | tristate "Include IDE/ATAPI TAPE support (EXPERIMENTAL)" | 219 | tristate "Include IDE/ATAPI TAPE support" |
| 220 | depends on EXPERIMENTAL | ||
| 221 | help | 220 | help |
| 222 | If you have an IDE tape drive using the ATAPI protocol, say Y. | 221 | If you have an IDE tape drive using the ATAPI protocol, say Y. |
| 223 | ATAPI is a newer protocol used by IDE tape and CD-ROM drives, | 222 | ATAPI is a newer protocol used by IDE tape and CD-ROM drives, |
diff --git a/drivers/ide/arm/bast-ide.c b/drivers/ide/arm/bast-ide.c index 037300fa284c..0e7574c0ee60 100644 --- a/drivers/ide/arm/bast-ide.c +++ b/drivers/ide/arm/bast-ide.c | |||
| @@ -28,8 +28,10 @@ static int __init | |||
| 28 | bastide_register(unsigned int base, unsigned int aux, int irq, | 28 | bastide_register(unsigned int base, unsigned int aux, int irq, |
| 29 | ide_hwif_t **hwif) | 29 | ide_hwif_t **hwif) |
| 30 | { | 30 | { |
| 31 | ide_hwif_t *hwif; | ||
| 31 | hw_regs_t hw; | 32 | hw_regs_t hw; |
| 32 | int i; | 33 | int i; |
| 34 | u8 idx[4] = { 0xff, 0xff, 0xff, 0xff }; | ||
| 33 | 35 | ||
| 34 | memset(&hw, 0, sizeof(hw)); | 36 | memset(&hw, 0, sizeof(hw)); |
| 35 | 37 | ||
| @@ -44,8 +46,24 @@ bastide_register(unsigned int base, unsigned int aux, int irq, | |||
| 44 | hw.io_ports[IDE_CONTROL_OFFSET] = aux + (6 * 0x20); | 46 | hw.io_ports[IDE_CONTROL_OFFSET] = aux + (6 * 0x20); |
| 45 | hw.irq = irq; | 47 | hw.irq = irq; |
| 46 | 48 | ||
| 47 | ide_register_hw(&hw, NULL, hwif); | 49 | hwif = ide_deprecated_find_port(hw.io_ports[IDE_DATA_OFFSET]); |
| 50 | if (hwif == NULL) | ||
| 51 | goto out; | ||
| 48 | 52 | ||
| 53 | i = hwif->index; | ||
| 54 | |||
| 55 | if (hwif->present) | ||
| 56 | ide_unregister(i, 0, 0); | ||
| 57 | else if (!hwif->hold) | ||
| 58 | ide_init_port_data(hwif, i); | ||
| 59 | |||
| 60 | ide_init_port_hw(hwif, &hw); | ||
| 61 | hwif->quirkproc = NULL; | ||
| 62 | |||
| 63 | idx[0] = i; | ||
| 64 | |||
| 65 | ide_device_add(idx, NULL); | ||
| 66 | out: | ||
| 49 | return 0; | 67 | return 0; |
| 50 | } | 68 | } |
| 51 | 69 | ||
diff --git a/drivers/ide/arm/icside.c b/drivers/ide/arm/icside.c index 8d2cc47a362e..fb00f3827ecd 100644 --- a/drivers/ide/arm/icside.c +++ b/drivers/ide/arm/icside.c | |||
| @@ -377,9 +377,6 @@ static void icside_dma_lost_irq(ide_drive_t *drive) | |||
| 377 | 377 | ||
| 378 | static void icside_dma_init(ide_hwif_t *hwif) | 378 | static void icside_dma_init(ide_hwif_t *hwif) |
| 379 | { | 379 | { |
| 380 | hwif->mwdma_mask = 7; /* MW0..2 */ | ||
| 381 | hwif->swdma_mask = 7; /* SW0..2 */ | ||
| 382 | |||
| 383 | hwif->dmatable_cpu = NULL; | 380 | hwif->dmatable_cpu = NULL; |
| 384 | hwif->dmatable_dma = 0; | 381 | hwif->dmatable_dma = 0; |
| 385 | hwif->set_dma_mode = icside_set_dma_mode; | 382 | hwif->set_dma_mode = icside_set_dma_mode; |
| @@ -459,11 +456,19 @@ icside_register_v5(struct icside_state *state, struct expansion_card *ec) | |||
| 459 | 456 | ||
| 460 | idx[0] = hwif->index; | 457 | idx[0] = hwif->index; |
| 461 | 458 | ||
| 462 | ide_device_add(idx); | 459 | ide_device_add(idx, NULL); |
| 463 | 460 | ||
| 464 | return 0; | 461 | return 0; |
| 465 | } | 462 | } |
| 466 | 463 | ||
| 464 | static const struct ide_port_info icside_v6_port_info __initdata = { | ||
| 465 | .host_flags = IDE_HFLAG_SERIALIZE | | ||
| 466 | IDE_HFLAG_NO_DMA | /* no SFF-style DMA */ | ||
| 467 | IDE_HFLAG_NO_AUTOTUNE, | ||
| 468 | .mwdma_mask = ATA_MWDMA2, | ||
| 469 | .swdma_mask = ATA_SWDMA2, | ||
| 470 | }; | ||
| 471 | |||
| 467 | static int __init | 472 | static int __init |
| 468 | icside_register_v6(struct icside_state *state, struct expansion_card *ec) | 473 | icside_register_v6(struct icside_state *state, struct expansion_card *ec) |
| 469 | { | 474 | { |
| @@ -472,6 +477,7 @@ icside_register_v6(struct icside_state *state, struct expansion_card *ec) | |||
| 472 | unsigned int sel = 0; | 477 | unsigned int sel = 0; |
| 473 | int ret; | 478 | int ret; |
| 474 | u8 idx[4] = { 0xff, 0xff, 0xff, 0xff }; | 479 | u8 idx[4] = { 0xff, 0xff, 0xff, 0xff }; |
| 480 | struct ide_port_info d = icside_v6_port_info; | ||
| 475 | 481 | ||
| 476 | ioc_base = ecardm_iomap(ec, ECARD_RES_IOCFAST, 0, 0); | 482 | ioc_base = ecardm_iomap(ec, ECARD_RES_IOCFAST, 0, 0); |
| 477 | if (!ioc_base) { | 483 | if (!ioc_base) { |
| @@ -521,30 +527,25 @@ icside_register_v6(struct icside_state *state, struct expansion_card *ec) | |||
| 521 | state->hwif[1] = mate; | 527 | state->hwif[1] = mate; |
| 522 | 528 | ||
| 523 | hwif->maskproc = icside_maskproc; | 529 | hwif->maskproc = icside_maskproc; |
| 524 | hwif->channel = 0; | ||
| 525 | hwif->hwif_data = state; | 530 | hwif->hwif_data = state; |
| 526 | hwif->mate = mate; | ||
| 527 | hwif->serialized = 1; | ||
| 528 | hwif->config_data = (unsigned long)ioc_base; | 531 | hwif->config_data = (unsigned long)ioc_base; |
| 529 | hwif->select_data = sel; | 532 | hwif->select_data = sel; |
| 530 | 533 | ||
| 531 | mate->maskproc = icside_maskproc; | 534 | mate->maskproc = icside_maskproc; |
| 532 | mate->channel = 1; | ||
| 533 | mate->hwif_data = state; | 535 | mate->hwif_data = state; |
| 534 | mate->mate = hwif; | ||
| 535 | mate->serialized = 1; | ||
| 536 | mate->config_data = (unsigned long)ioc_base; | 536 | mate->config_data = (unsigned long)ioc_base; |
| 537 | mate->select_data = sel | 1; | 537 | mate->select_data = sel | 1; |
| 538 | 538 | ||
| 539 | if (ec->dma != NO_DMA && !request_dma(ec->dma, hwif->name)) { | 539 | if (ec->dma != NO_DMA && !request_dma(ec->dma, hwif->name)) { |
| 540 | icside_dma_init(hwif); | 540 | icside_dma_init(hwif); |
| 541 | icside_dma_init(mate); | 541 | icside_dma_init(mate); |
| 542 | } | 542 | } else |
| 543 | d.mwdma_mask = d.swdma_mask = 0; | ||
| 543 | 544 | ||
| 544 | idx[0] = hwif->index; | 545 | idx[0] = hwif->index; |
| 545 | idx[1] = mate->index; | 546 | idx[1] = mate->index; |
| 546 | 547 | ||
| 547 | ide_device_add(idx); | 548 | ide_device_add(idx, &d); |
| 548 | 549 | ||
| 549 | return 0; | 550 | return 0; |
| 550 | 551 | ||
diff --git a/drivers/ide/arm/ide_arm.c b/drivers/ide/arm/ide_arm.c index 60f2497542c0..43a70e91363e 100644 --- a/drivers/ide/arm/ide_arm.c +++ b/drivers/ide/arm/ide_arm.c | |||
| @@ -39,7 +39,7 @@ static int __init ide_arm_init(void) | |||
| 39 | ide_init_port_hw(hwif, &hw); | 39 | ide_init_port_hw(hwif, &hw); |
| 40 | idx[0] = hwif->index; | 40 | idx[0] = hwif->index; |
| 41 | 41 | ||
| 42 | ide_device_add(idx); | 42 | ide_device_add(idx, NULL); |
| 43 | } | 43 | } |
| 44 | 44 | ||
| 45 | return 0; | 45 | return 0; |
diff --git a/drivers/ide/arm/rapide.c b/drivers/ide/arm/rapide.c index c8b6581e624e..efba00d2fc37 100644 --- a/drivers/ide/arm/rapide.c +++ b/drivers/ide/arm/rapide.c | |||
| @@ -58,7 +58,7 @@ rapide_probe(struct expansion_card *ec, const struct ecard_id *id) | |||
| 58 | 58 | ||
| 59 | idx[0] = hwif->index; | 59 | idx[0] = hwif->index; |
| 60 | 60 | ||
| 61 | ide_device_add(idx); | 61 | ide_device_add(idx, NULL); |
| 62 | 62 | ||
| 63 | ecard_set_drvdata(ec, hwif); | 63 | ecard_set_drvdata(ec, hwif); |
| 64 | goto out; | 64 | goto out; |
| @@ -76,7 +76,7 @@ static void __devexit rapide_remove(struct expansion_card *ec) | |||
| 76 | 76 | ||
| 77 | ecard_set_drvdata(ec, NULL); | 77 | ecard_set_drvdata(ec, NULL); |
| 78 | 78 | ||
| 79 | ide_unregister(hwif->index); | 79 | ide_unregister(hwif->index, 0, 0); |
| 80 | 80 | ||
| 81 | ecard_release_resources(ec); | 81 | ecard_release_resources(ec); |
| 82 | } | 82 | } |
diff --git a/drivers/ide/cris/ide-cris.c b/drivers/ide/cris/ide-cris.c index 0640a38ff127..00587a8c2ba1 100644 --- a/drivers/ide/cris/ide-cris.c +++ b/drivers/ide/cris/ide-cris.c | |||
| @@ -753,6 +753,15 @@ static void cris_set_dma_mode(ide_drive_t *drive, const u8 speed) | |||
| 753 | cris_ide_set_speed(TYPE_DMA, 0, strobe, hold); | 753 | cris_ide_set_speed(TYPE_DMA, 0, strobe, hold); |
| 754 | } | 754 | } |
| 755 | 755 | ||
| 756 | static const struct ide_port_info cris_port_info __initdata = { | ||
| 757 | .chipset = ide_etrax100, | ||
| 758 | .host_flags = IDE_HFLAG_NO_ATAPI_DMA | | ||
| 759 | IDE_HFLAG_NO_DMA, /* no SFF-style DMA */ | ||
| 760 | .pio_mask = ATA_PIO4, | ||
| 761 | .udma_mask = cris_ultra_mask, | ||
| 762 | .mwdma_mask = ATA_MWDMA2, | ||
| 763 | }; | ||
| 764 | |||
| 756 | static int __init init_e100_ide(void) | 765 | static int __init init_e100_ide(void) |
| 757 | { | 766 | { |
| 758 | hw_regs_t hw; | 767 | hw_regs_t hw; |
| @@ -780,7 +789,6 @@ static int __init init_e100_ide(void) | |||
| 780 | ide_init_port_data(hwif, hwif->index); | 789 | ide_init_port_data(hwif, hwif->index); |
| 781 | ide_init_port_hw(hwif, &hw); | 790 | ide_init_port_hw(hwif, &hw); |
| 782 | hwif->mmio = 1; | 791 | hwif->mmio = 1; |
| 783 | hwif->chipset = ide_etrax100; | ||
| 784 | hwif->set_pio_mode = &cris_set_pio_mode; | 792 | hwif->set_pio_mode = &cris_set_pio_mode; |
| 785 | hwif->set_dma_mode = &cris_set_dma_mode; | 793 | hwif->set_dma_mode = &cris_set_dma_mode; |
| 786 | hwif->ata_input_data = &cris_ide_input_data; | 794 | hwif->ata_input_data = &cris_ide_input_data; |
| @@ -799,12 +807,6 @@ static int __init init_e100_ide(void) | |||
| 799 | hwif->INB = &cris_ide_inb; | 807 | hwif->INB = &cris_ide_inb; |
| 800 | hwif->INW = &cris_ide_inw; | 808 | hwif->INW = &cris_ide_inw; |
| 801 | hwif->cbl = ATA_CBL_PATA40; | 809 | hwif->cbl = ATA_CBL_PATA40; |
| 802 | hwif->host_flags |= IDE_HFLAG_NO_ATAPI_DMA; | ||
| 803 | hwif->pio_mask = ATA_PIO4, | ||
| 804 | hwif->drives[0].autotune = 1; | ||
| 805 | hwif->drives[1].autotune = 1; | ||
| 806 | hwif->ultra_mask = cris_ultra_mask; | ||
| 807 | hwif->mwdma_mask = 0x07; /* Multiword DMA 0-2 */ | ||
| 808 | 810 | ||
| 809 | idx[h] = hwif->index; | 811 | idx[h] = hwif->index; |
| 810 | } | 812 | } |
| @@ -820,7 +822,7 @@ static int __init init_e100_ide(void) | |||
| 820 | cris_ide_set_speed(TYPE_DMA, 0, ATA_DMA2_STROBE, ATA_DMA2_HOLD); | 822 | cris_ide_set_speed(TYPE_DMA, 0, ATA_DMA2_STROBE, ATA_DMA2_HOLD); |
| 821 | cris_ide_set_speed(TYPE_UDMA, ATA_UDMA2_CYC, ATA_UDMA2_DVS, 0); | 823 | cris_ide_set_speed(TYPE_UDMA, ATA_UDMA2_CYC, ATA_UDMA2_DVS, 0); |
| 822 | 824 | ||
| 823 | ide_device_add(idx); | 825 | ide_device_add(idx, &cris_port_info); |
| 824 | 826 | ||
| 825 | return 0; | 827 | return 0; |
| 826 | } | 828 | } |
| @@ -1032,11 +1034,7 @@ static int cris_dma_setup(ide_drive_t *drive) | |||
| 1032 | 1034 | ||
| 1033 | static void cris_dma_exec_cmd(ide_drive_t *drive, u8 command) | 1035 | static void cris_dma_exec_cmd(ide_drive_t *drive, u8 command) |
| 1034 | { | 1036 | { |
| 1035 | /* set the irq handler which will finish the request when DMA is done */ | 1037 | ide_execute_command(drive, command, &cris_dma_intr, WAIT_CMD, NULL); |
| 1036 | ide_set_handler(drive, &cris_dma_intr, WAIT_CMD, NULL); | ||
| 1037 | |||
| 1038 | /* issue cmd to drive */ | ||
| 1039 | cris_ide_outb(command, IDE_COMMAND_REG); | ||
| 1040 | } | 1038 | } |
| 1041 | 1039 | ||
| 1042 | static void cris_dma_start(ide_drive_t *drive) | 1040 | static void cris_dma_start(ide_drive_t *drive) |
diff --git a/drivers/ide/h8300/ide-h8300.c b/drivers/ide/h8300/ide-h8300.c index 02432958dfe1..520aec075700 100644 --- a/drivers/ide/h8300/ide-h8300.c +++ b/drivers/ide/h8300/ide-h8300.c | |||
| @@ -114,7 +114,7 @@ static int __init h8300_ide_init(void) | |||
| 114 | 114 | ||
| 115 | idx[0] = index; | 115 | idx[0] = index; |
| 116 | 116 | ||
| 117 | ide_device_add(idx); | 117 | ide_device_add(idx, NULL); |
| 118 | 118 | ||
| 119 | return 0; | 119 | return 0; |
| 120 | 120 | ||
diff --git a/drivers/ide/ide-acpi.c b/drivers/ide/ide-acpi.c index 68bc61844780..25aaeae1e830 100644 --- a/drivers/ide/ide-acpi.c +++ b/drivers/ide/ide-acpi.c | |||
| @@ -39,7 +39,6 @@ struct GTM_buffer { | |||
| 39 | }; | 39 | }; |
| 40 | 40 | ||
| 41 | struct ide_acpi_drive_link { | 41 | struct ide_acpi_drive_link { |
| 42 | ide_drive_t *drive; | ||
| 43 | acpi_handle obj_handle; | 42 | acpi_handle obj_handle; |
| 44 | u8 idbuff[512]; | 43 | u8 idbuff[512]; |
| 45 | }; | 44 | }; |
| @@ -280,16 +279,6 @@ static int do_drive_get_GTF(ide_drive_t *drive, | |||
| 280 | 279 | ||
| 281 | port = hwif->channel ? drive->dn - 2: drive->dn; | 280 | port = hwif->channel ? drive->dn - 2: drive->dn; |
| 282 | 281 | ||
| 283 | if (!drive->acpidata) { | ||
| 284 | if (port == 0) { | ||
| 285 | drive->acpidata = &hwif->acpidata->master; | ||
| 286 | hwif->acpidata->master.drive = drive; | ||
| 287 | } else { | ||
| 288 | drive->acpidata = &hwif->acpidata->slave; | ||
| 289 | hwif->acpidata->slave.drive = drive; | ||
| 290 | } | ||
| 291 | } | ||
| 292 | |||
| 293 | DEBPRINT("ENTER: %s at %s, port#: %d, hard_port#: %d\n", | 282 | DEBPRINT("ENTER: %s at %s, port#: %d, hard_port#: %d\n", |
| 294 | hwif->name, dev->bus_id, port, hwif->channel); | 283 | hwif->name, dev->bus_id, port, hwif->channel); |
| 295 | 284 | ||
| @@ -494,7 +483,6 @@ int ide_acpi_exec_tfs(ide_drive_t *drive) | |||
| 494 | 483 | ||
| 495 | return ret; | 484 | return ret; |
| 496 | } | 485 | } |
| 497 | EXPORT_SYMBOL_GPL(ide_acpi_exec_tfs); | ||
| 498 | 486 | ||
| 499 | /** | 487 | /** |
| 500 | * ide_acpi_get_timing - get the channel (controller) timings | 488 | * ide_acpi_get_timing - get the channel (controller) timings |
| @@ -580,7 +568,6 @@ void ide_acpi_get_timing(ide_hwif_t *hwif) | |||
| 580 | 568 | ||
| 581 | kfree(output.pointer); | 569 | kfree(output.pointer); |
| 582 | } | 570 | } |
| 583 | EXPORT_SYMBOL_GPL(ide_acpi_get_timing); | ||
| 584 | 571 | ||
| 585 | /** | 572 | /** |
| 586 | * ide_acpi_push_timing - set the channel (controller) timings | 573 | * ide_acpi_push_timing - set the channel (controller) timings |
| @@ -634,7 +621,6 @@ void ide_acpi_push_timing(ide_hwif_t *hwif) | |||
| 634 | } | 621 | } |
| 635 | DEBPRINT("_STM status: %d\n", status); | 622 | DEBPRINT("_STM status: %d\n", status); |
| 636 | } | 623 | } |
| 637 | EXPORT_SYMBOL_GPL(ide_acpi_push_timing); | ||
| 638 | 624 | ||
| 639 | /** | 625 | /** |
| 640 | * ide_acpi_set_state - set the channel power state | 626 | * ide_acpi_set_state - set the channel power state |
| @@ -688,11 +674,6 @@ void ide_acpi_set_state(ide_hwif_t *hwif, int on) | |||
| 688 | */ | 674 | */ |
| 689 | void ide_acpi_init(ide_hwif_t *hwif) | 675 | void ide_acpi_init(ide_hwif_t *hwif) |
| 690 | { | 676 | { |
| 691 | int unit; | ||
| 692 | int err; | ||
| 693 | struct ide_acpi_drive_link *master; | ||
| 694 | struct ide_acpi_drive_link *slave; | ||
| 695 | |||
| 696 | ide_acpi_blacklist(); | 677 | ide_acpi_blacklist(); |
| 697 | 678 | ||
| 698 | hwif->acpidata = kzalloc(sizeof(struct ide_acpi_hwif_link), GFP_KERNEL); | 679 | hwif->acpidata = kzalloc(sizeof(struct ide_acpi_hwif_link), GFP_KERNEL); |
| @@ -704,40 +685,38 @@ void ide_acpi_init(ide_hwif_t *hwif) | |||
| 704 | DEBPRINT("no ACPI object for %s found\n", hwif->name); | 685 | DEBPRINT("no ACPI object for %s found\n", hwif->name); |
| 705 | kfree(hwif->acpidata); | 686 | kfree(hwif->acpidata); |
| 706 | hwif->acpidata = NULL; | 687 | hwif->acpidata = NULL; |
| 707 | return; | ||
| 708 | } | 688 | } |
| 689 | } | ||
| 690 | |||
| 691 | void ide_acpi_port_init_devices(ide_hwif_t *hwif) | ||
| 692 | { | ||
| 693 | ide_drive_t *drive; | ||
| 694 | int i, err; | ||
| 695 | |||
| 696 | if (hwif->acpidata == NULL) | ||
| 697 | return; | ||
| 709 | 698 | ||
| 710 | /* | 699 | /* |
| 711 | * The ACPI spec mandates that we send information | 700 | * The ACPI spec mandates that we send information |
| 712 | * for both drives, regardless whether they are connected | 701 | * for both drives, regardless whether they are connected |
| 713 | * or not. | 702 | * or not. |
| 714 | */ | 703 | */ |
| 715 | hwif->acpidata->master.drive = &hwif->drives[0]; | ||
| 716 | hwif->drives[0].acpidata = &hwif->acpidata->master; | 704 | hwif->drives[0].acpidata = &hwif->acpidata->master; |
| 717 | master = &hwif->acpidata->master; | ||
| 718 | |||
| 719 | hwif->acpidata->slave.drive = &hwif->drives[1]; | ||
| 720 | hwif->drives[1].acpidata = &hwif->acpidata->slave; | 705 | hwif->drives[1].acpidata = &hwif->acpidata->slave; |
| 721 | slave = &hwif->acpidata->slave; | ||
| 722 | |||
| 723 | 706 | ||
| 724 | /* | 707 | /* |
| 725 | * Send IDENTIFY for each drive | 708 | * Send IDENTIFY for each drive |
| 726 | */ | 709 | */ |
| 727 | if (master->drive->present) { | 710 | for (i = 0; i < MAX_DRIVES; i++) { |
| 728 | err = taskfile_lib_get_identify(master->drive, master->idbuff); | 711 | drive = &hwif->drives[i]; |
| 729 | if (err) { | 712 | |
| 730 | DEBPRINT("identify device %s failed (%d)\n", | 713 | if (!drive->present) |
| 731 | master->drive->name, err); | 714 | continue; |
| 732 | } | ||
| 733 | } | ||
| 734 | 715 | ||
| 735 | if (slave->drive->present) { | 716 | err = taskfile_lib_get_identify(drive, drive->acpidata->idbuff); |
| 736 | err = taskfile_lib_get_identify(slave->drive, slave->idbuff); | 717 | if (err) |
| 737 | if (err) { | ||
| 738 | DEBPRINT("identify device %s failed (%d)\n", | 718 | DEBPRINT("identify device %s failed (%d)\n", |
| 739 | slave->drive->name, err); | 719 | drive->name, err); |
| 740 | } | ||
| 741 | } | 720 | } |
| 742 | 721 | ||
| 743 | if (ide_noacpionboot) { | 722 | if (ide_noacpionboot) { |
| @@ -753,13 +732,11 @@ void ide_acpi_init(ide_hwif_t *hwif) | |||
| 753 | ide_acpi_get_timing(hwif); | 732 | ide_acpi_get_timing(hwif); |
| 754 | ide_acpi_push_timing(hwif); | 733 | ide_acpi_push_timing(hwif); |
| 755 | 734 | ||
| 756 | for (unit = 0; unit < MAX_DRIVES; ++unit) { | 735 | for (i = 0; i < MAX_DRIVES; i++) { |
| 757 | ide_drive_t *drive = &hwif->drives[unit]; | 736 | drive = &hwif->drives[i]; |
| 758 | 737 | ||
| 759 | if (drive->present) { | 738 | if (drive->present) |
| 760 | /* Execute ACPI startup code */ | 739 | /* Execute ACPI startup code */ |
| 761 | ide_acpi_exec_tfs(drive); | 740 | ide_acpi_exec_tfs(drive); |
| 762 | } | ||
| 763 | } | 741 | } |
| 764 | } | 742 | } |
| 765 | EXPORT_SYMBOL_GPL(ide_acpi_init); | ||
diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c index 23074e84472e..ee4d458e2bbf 100644 --- a/drivers/ide/ide-cd.c +++ b/drivers/ide/ide-cd.c | |||
| @@ -604,8 +604,6 @@ static ide_startstop_t cdrom_transfer_packet_command (ide_drive_t *drive, | |||
| 604 | * Block read functions. | 604 | * Block read functions. |
| 605 | */ | 605 | */ |
| 606 | 606 | ||
| 607 | typedef void (xfer_func_t)(ide_drive_t *, void *, u32); | ||
| 608 | |||
| 609 | static void ide_cd_pad_transfer(ide_drive_t *drive, xfer_func_t *xf, int len) | 607 | static void ide_cd_pad_transfer(ide_drive_t *drive, xfer_func_t *xf, int len) |
| 610 | { | 608 | { |
| 611 | while (len > 0) { | 609 | while (len > 0) { |
diff --git a/drivers/ide/ide-dma.c b/drivers/ide/ide-dma.c index 7beaf1e9be12..3cf59f2c3928 100644 --- a/drivers/ide/ide-dma.c +++ b/drivers/ide/ide-dma.c | |||
| @@ -819,6 +819,26 @@ int ide_set_dma(ide_drive_t *drive) | |||
| 819 | return 0; | 819 | return 0; |
| 820 | } | 820 | } |
| 821 | 821 | ||
| 822 | void ide_check_dma_crc(ide_drive_t *drive) | ||
| 823 | { | ||
| 824 | u8 mode; | ||
| 825 | |||
| 826 | ide_dma_off_quietly(drive); | ||
| 827 | drive->crc_count = 0; | ||
| 828 | mode = drive->current_speed; | ||
| 829 | /* | ||
| 830 | * Don't try non Ultra-DMA modes without iCRC's. Force the | ||
| 831 | * device to PIO and make the user enable SWDMA/MWDMA modes. | ||
| 832 | */ | ||
| 833 | if (mode > XFER_UDMA_0 && mode <= XFER_UDMA_7) | ||
| 834 | mode--; | ||
| 835 | else | ||
| 836 | mode = XFER_PIO_4; | ||
| 837 | ide_set_xfer_rate(drive, mode); | ||
| 838 | if (drive->current_speed >= XFER_SW_DMA_0) | ||
| 839 | ide_dma_on(drive); | ||
| 840 | } | ||
| 841 | |||
| 822 | #ifdef CONFIG_BLK_DEV_IDEDMA_PCI | 842 | #ifdef CONFIG_BLK_DEV_IDEDMA_PCI |
| 823 | void ide_dma_lost_irq (ide_drive_t *drive) | 843 | void ide_dma_lost_irq (ide_drive_t *drive) |
| 824 | { | 844 | { |
diff --git a/drivers/ide/ide-floppy.c b/drivers/ide/ide-floppy.c index 3512637ae8d4..f8fe6ee128f3 100644 --- a/drivers/ide/ide-floppy.c +++ b/drivers/ide/ide-floppy.c | |||
| @@ -4,11 +4,6 @@ | |||
| 4 | * Copyright (C) 1996-1999 Gadi Oxman <gadio@netvision.net.il> | 4 | * Copyright (C) 1996-1999 Gadi Oxman <gadio@netvision.net.il> |
| 5 | * Copyright (C) 2000-2002 Paul Bristow <paul@paulbristow.net> | 5 | * Copyright (C) 2000-2002 Paul Bristow <paul@paulbristow.net> |
| 6 | * Copyright (C) 2005 Bartlomiej Zolnierkiewicz | 6 | * Copyright (C) 2005 Bartlomiej Zolnierkiewicz |
| 7 | */ | ||
| 8 | |||
| 9 | /* | ||
| 10 | * The driver currently doesn't have any fancy features, just the bare | ||
| 11 | * minimum read/write support. | ||
| 12 | * | 7 | * |
| 13 | * This driver supports the following IDE floppy drives: | 8 | * This driver supports the following IDE floppy drives: |
| 14 | * | 9 | * |
| @@ -20,7 +15,7 @@ | |||
| 20 | * Documentation/ide/ChangeLog.ide-floppy.1996-2002 | 15 | * Documentation/ide/ChangeLog.ide-floppy.1996-2002 |
| 21 | */ | 16 | */ |
| 22 | 17 | ||
| 23 | #define IDEFLOPPY_VERSION "0.99.newide" | 18 | #define IDEFLOPPY_VERSION "1.00" |
| 24 | 19 | ||
| 25 | #include <linux/module.h> | 20 | #include <linux/module.h> |
| 26 | #include <linux/types.h> | 21 | #include <linux/types.h> |
| @@ -42,179 +37,91 @@ | |||
| 42 | #include <scsi/scsi_ioctl.h> | 37 | #include <scsi/scsi_ioctl.h> |
| 43 | 38 | ||
| 44 | #include <asm/byteorder.h> | 39 | #include <asm/byteorder.h> |
| 45 | #include <asm/irq.h> | 40 | #include <linux/irq.h> |
| 46 | #include <asm/uaccess.h> | 41 | #include <linux/uaccess.h> |
| 47 | #include <asm/io.h> | 42 | #include <linux/io.h> |
| 48 | #include <asm/unaligned.h> | 43 | #include <asm/unaligned.h> |
| 49 | 44 | ||
| 50 | /* | 45 | /* define to see debug info */ |
| 51 | * The following are used to debug the driver. | ||
| 52 | */ | ||
| 53 | #define IDEFLOPPY_DEBUG_LOG 0 | 46 | #define IDEFLOPPY_DEBUG_LOG 0 |
| 54 | #define IDEFLOPPY_DEBUG_INFO 0 | ||
| 55 | #define IDEFLOPPY_DEBUG_BUGS 1 | ||
| 56 | 47 | ||
| 57 | /* #define IDEFLOPPY_DEBUG(fmt, args...) printk(KERN_INFO fmt, ## args) */ | 48 | /* #define IDEFLOPPY_DEBUG(fmt, args...) printk(KERN_INFO fmt, ## args) */ |
| 58 | #define IDEFLOPPY_DEBUG( fmt, args... ) | 49 | #define IDEFLOPPY_DEBUG(fmt, args...) |
| 59 | 50 | ||
| 60 | #if IDEFLOPPY_DEBUG_LOG | 51 | #if IDEFLOPPY_DEBUG_LOG |
| 61 | #define debug_log printk | 52 | #define debug_log(fmt, args...) \ |
| 53 | printk(KERN_INFO "ide-floppy: " fmt, ## args) | ||
| 62 | #else | 54 | #else |
| 63 | #define debug_log(fmt, args... ) do {} while(0) | 55 | #define debug_log(fmt, args...) do {} while (0) |
| 64 | #endif | 56 | #endif |
| 65 | 57 | ||
| 66 | 58 | ||
| 67 | /* | 59 | /* Some drives require a longer irq timeout. */ |
| 68 | * Some drives require a longer irq timeout. | ||
| 69 | */ | ||
| 70 | #define IDEFLOPPY_WAIT_CMD (5 * WAIT_CMD) | 60 | #define IDEFLOPPY_WAIT_CMD (5 * WAIT_CMD) |
| 71 | 61 | ||
| 72 | /* | 62 | /* |
| 73 | * After each failed packet command we issue a request sense command | 63 | * After each failed packet command we issue a request sense command and retry |
| 74 | * and retry the packet command IDEFLOPPY_MAX_PC_RETRIES times. | 64 | * the packet command IDEFLOPPY_MAX_PC_RETRIES times. |
| 75 | */ | 65 | */ |
| 76 | #define IDEFLOPPY_MAX_PC_RETRIES 3 | 66 | #define IDEFLOPPY_MAX_PC_RETRIES 3 |
| 77 | 67 | ||
| 78 | /* | 68 | /* |
| 79 | * With each packet command, we allocate a buffer of | 69 | * With each packet command, we allocate a buffer of IDEFLOPPY_PC_BUFFER_SIZE |
| 80 | * IDEFLOPPY_PC_BUFFER_SIZE bytes. | 70 | * bytes. |
| 81 | */ | 71 | */ |
| 82 | #define IDEFLOPPY_PC_BUFFER_SIZE 256 | 72 | #define IDEFLOPPY_PC_BUFFER_SIZE 256 |
| 83 | 73 | ||
| 84 | /* | 74 | /* |
| 85 | * In various places in the driver, we need to allocate storage | 75 | * In various places in the driver, we need to allocate storage for packet |
| 86 | * for packet commands and requests, which will remain valid while | 76 | * commands and requests, which will remain valid while we leave the driver to |
| 87 | * we leave the driver to wait for an interrupt or a timeout event. | 77 | * wait for an interrupt or a timeout event. |
| 88 | */ | 78 | */ |
| 89 | #define IDEFLOPPY_PC_STACK (10 + IDEFLOPPY_MAX_PC_RETRIES) | 79 | #define IDEFLOPPY_PC_STACK (10 + IDEFLOPPY_MAX_PC_RETRIES) |
| 90 | 80 | ||
| 91 | /* | ||
| 92 | * Our view of a packet command. | ||
| 93 | */ | ||
| 94 | typedef struct idefloppy_packet_command_s { | 81 | typedef struct idefloppy_packet_command_s { |
| 95 | u8 c[12]; /* Actual packet bytes */ | 82 | u8 c[12]; /* Actual packet bytes */ |
| 96 | int retries; /* On each retry, we increment retries */ | 83 | int retries; /* On each retry, we increment |
| 84 | retries */ | ||
| 97 | int error; /* Error code */ | 85 | int error; /* Error code */ |
| 98 | int request_transfer; /* Bytes to transfer */ | 86 | int request_transfer; /* Bytes to transfer */ |
| 99 | int actually_transferred; /* Bytes actually transferred */ | 87 | int actually_transferred; /* Bytes actually transferred */ |
| 100 | int buffer_size; /* Size of our data buffer */ | 88 | int buffer_size; /* Size of our data buffer */ |
| 101 | int b_count; /* Missing/Available data on the current buffer */ | 89 | int b_count; /* Missing/Available data on |
| 90 | the current buffer */ | ||
| 102 | struct request *rq; /* The corresponding request */ | 91 | struct request *rq; /* The corresponding request */ |
| 103 | u8 *buffer; /* Data buffer */ | 92 | u8 *buffer; /* Data buffer */ |
| 104 | u8 *current_position; /* Pointer into the above buffer */ | 93 | u8 *current_position; /* Pointer into above buffer */ |
| 105 | void (*callback) (ide_drive_t *); /* Called when this packet command is completed */ | 94 | void (*callback) (ide_drive_t *); /* Called when this packet |
| 95 | command is completed */ | ||
| 106 | u8 pc_buffer[IDEFLOPPY_PC_BUFFER_SIZE]; /* Temporary buffer */ | 96 | u8 pc_buffer[IDEFLOPPY_PC_BUFFER_SIZE]; /* Temporary buffer */ |
| 107 | unsigned long flags; /* Status/Action bit flags: long for set_bit */ | 97 | unsigned long flags; /* Status/Action bit flags: long |
| 98 | for set_bit */ | ||
| 108 | } idefloppy_pc_t; | 99 | } idefloppy_pc_t; |
| 109 | 100 | ||
| 110 | /* | 101 | /* Packet command flag bits. */ |
| 111 | * Packet command flag bits. | 102 | enum { |
| 112 | */ | 103 | /* 1 when we prefer to use DMA if possible */ |
| 113 | #define PC_ABORT 0 /* Set when an error is considered normal - We won't retry */ | 104 | PC_FLAG_DMA_RECOMMENDED = (1 << 0), |
| 114 | #define PC_DMA_RECOMMENDED 2 /* 1 when we prefer to use DMA if possible */ | 105 | /* 1 while DMA in progress */ |
| 115 | #define PC_DMA_IN_PROGRESS 3 /* 1 while DMA in progress */ | 106 | PC_FLAG_DMA_IN_PROGRESS = (1 << 1), |
| 116 | #define PC_DMA_ERROR 4 /* 1 when encountered problem during DMA */ | 107 | /* 1 when encountered problem during DMA */ |
| 117 | #define PC_WRITING 5 /* Data direction */ | 108 | PC_FLAG_DMA_ERROR = (1 << 2), |
| 118 | 109 | /* Data direction */ | |
| 119 | #define PC_SUPPRESS_ERROR 6 /* Suppress error reporting */ | 110 | PC_FLAG_WRITING = (1 << 3), |
| 120 | 111 | /* Suppress error reporting */ | |
| 121 | /* | 112 | PC_FLAG_SUPPRESS_ERROR = (1 << 4), |
| 122 | * Removable Block Access Capabilities Page | 113 | }; |
| 123 | */ | ||
| 124 | typedef struct { | ||
| 125 | #if defined(__LITTLE_ENDIAN_BITFIELD) | ||
| 126 | unsigned page_code :6; /* Page code - Should be 0x1b */ | ||
| 127 | unsigned reserved1_6 :1; /* Reserved */ | ||
| 128 | unsigned ps :1; /* Should be 0 */ | ||
| 129 | #elif defined(__BIG_ENDIAN_BITFIELD) | ||
| 130 | unsigned ps :1; /* Should be 0 */ | ||
| 131 | unsigned reserved1_6 :1; /* Reserved */ | ||
| 132 | unsigned page_code :6; /* Page code - Should be 0x1b */ | ||
| 133 | #else | ||
| 134 | #error "Bitfield endianness not defined! Check your byteorder.h" | ||
| 135 | #endif | ||
| 136 | u8 page_length; /* Page Length - Should be 0xa */ | ||
| 137 | #if defined(__LITTLE_ENDIAN_BITFIELD) | ||
| 138 | unsigned reserved2 :6; | ||
| 139 | unsigned srfp :1; /* Supports reporting progress of format */ | ||
| 140 | unsigned sflp :1; /* System floppy type device */ | ||
| 141 | unsigned tlun :3; /* Total logical units supported by the device */ | ||
| 142 | unsigned reserved3 :3; | ||
| 143 | unsigned sml :1; /* Single / Multiple lun supported */ | ||
| 144 | unsigned ncd :1; /* Non cd optical device */ | ||
| 145 | #elif defined(__BIG_ENDIAN_BITFIELD) | ||
| 146 | unsigned sflp :1; /* System floppy type device */ | ||
| 147 | unsigned srfp :1; /* Supports reporting progress of format */ | ||
| 148 | unsigned reserved2 :6; | ||
| 149 | unsigned ncd :1; /* Non cd optical device */ | ||
| 150 | unsigned sml :1; /* Single / Multiple lun supported */ | ||
| 151 | unsigned reserved3 :3; | ||
| 152 | unsigned tlun :3; /* Total logical units supported by the device */ | ||
| 153 | #else | ||
| 154 | #error "Bitfield endianness not defined! Check your byteorder.h" | ||
| 155 | #endif | ||
| 156 | u8 reserved[8]; | ||
| 157 | } idefloppy_capabilities_page_t; | ||
| 158 | |||
| 159 | /* | ||
| 160 | * Flexible disk page. | ||
| 161 | */ | ||
| 162 | typedef struct { | ||
| 163 | #if defined(__LITTLE_ENDIAN_BITFIELD) | ||
| 164 | unsigned page_code :6; /* Page code - Should be 0x5 */ | ||
| 165 | unsigned reserved1_6 :1; /* Reserved */ | ||
| 166 | unsigned ps :1; /* The device is capable of saving the page */ | ||
| 167 | #elif defined(__BIG_ENDIAN_BITFIELD) | ||
| 168 | unsigned ps :1; /* The device is capable of saving the page */ | ||
| 169 | unsigned reserved1_6 :1; /* Reserved */ | ||
| 170 | unsigned page_code :6; /* Page code - Should be 0x5 */ | ||
| 171 | #else | ||
| 172 | #error "Bitfield endianness not defined! Check your byteorder.h" | ||
| 173 | #endif | ||
| 174 | u8 page_length; /* Page Length - Should be 0x1e */ | ||
| 175 | u16 transfer_rate; /* In kilobits per second */ | ||
| 176 | u8 heads, sectors; /* Number of heads, Number of sectors per track */ | ||
| 177 | u16 sector_size; /* Byes per sector */ | ||
| 178 | u16 cyls; /* Number of cylinders */ | ||
| 179 | u8 reserved10[10]; | ||
| 180 | u8 motor_delay; /* Motor off delay */ | ||
| 181 | u8 reserved21[7]; | ||
| 182 | u16 rpm; /* Rotations per minute */ | ||
| 183 | u8 reserved30[2]; | ||
| 184 | } idefloppy_flexible_disk_page_t; | ||
| 185 | |||
| 186 | /* | ||
| 187 | * Format capacity | ||
| 188 | */ | ||
| 189 | typedef struct { | ||
| 190 | u8 reserved[3]; | ||
| 191 | u8 length; /* Length of the following descriptors in bytes */ | ||
| 192 | } idefloppy_capacity_header_t; | ||
| 193 | |||
| 194 | typedef struct { | ||
| 195 | u32 blocks; /* Number of blocks */ | ||
| 196 | #if defined(__LITTLE_ENDIAN_BITFIELD) | ||
| 197 | unsigned dc :2; /* Descriptor Code */ | ||
| 198 | unsigned reserved :6; | ||
| 199 | #elif defined(__BIG_ENDIAN_BITFIELD) | ||
| 200 | unsigned reserved :6; | ||
| 201 | unsigned dc :2; /* Descriptor Code */ | ||
| 202 | #else | ||
| 203 | #error "Bitfield endianness not defined! Check your byteorder.h" | ||
| 204 | #endif | ||
| 205 | u8 length_msb; /* Block Length (MSB)*/ | ||
| 206 | u16 length; /* Block Length */ | ||
| 207 | } idefloppy_capacity_descriptor_t; | ||
| 208 | 114 | ||
| 115 | /* format capacities descriptor codes */ | ||
| 209 | #define CAPACITY_INVALID 0x00 | 116 | #define CAPACITY_INVALID 0x00 |
| 210 | #define CAPACITY_UNFORMATTED 0x01 | 117 | #define CAPACITY_UNFORMATTED 0x01 |
| 211 | #define CAPACITY_CURRENT 0x02 | 118 | #define CAPACITY_CURRENT 0x02 |
| 212 | #define CAPACITY_NO_CARTRIDGE 0x03 | 119 | #define CAPACITY_NO_CARTRIDGE 0x03 |
| 213 | 120 | ||
| 214 | /* | 121 | /* |
| 215 | * Most of our global data which we need to save even as we leave the | 122 | * Most of our global data which we need to save even as we leave the driver |
| 216 | * driver due to an interrupt or a timer event is stored in a variable | 123 | * due to an interrupt or a timer event is stored in a variable of type |
| 217 | * of type idefloppy_floppy_t, defined below. | 124 | * idefloppy_floppy_t, defined below. |
| 218 | */ | 125 | */ |
| 219 | typedef struct ide_floppy_obj { | 126 | typedef struct ide_floppy_obj { |
| 220 | ide_drive_t *drive; | 127 | ide_drive_t *drive; |
| @@ -235,23 +142,19 @@ typedef struct ide_floppy_obj { | |||
| 235 | /* We implement a circular array */ | 142 | /* We implement a circular array */ |
| 236 | int rq_stack_index; | 143 | int rq_stack_index; |
| 237 | 144 | ||
| 238 | /* | 145 | /* Last error information */ |
| 239 | * Last error information | ||
| 240 | */ | ||
| 241 | u8 sense_key, asc, ascq; | 146 | u8 sense_key, asc, ascq; |
| 242 | /* delay this long before sending packet command */ | 147 | /* delay this long before sending packet command */ |
| 243 | u8 ticks; | 148 | u8 ticks; |
| 244 | int progress_indication; | 149 | int progress_indication; |
| 245 | 150 | ||
| 246 | /* | 151 | /* Device information */ |
| 247 | * Device information | ||
| 248 | */ | ||
| 249 | /* Current format */ | 152 | /* Current format */ |
| 250 | int blocks, block_size, bs_factor; | 153 | int blocks, block_size, bs_factor; |
| 251 | /* Last format capacity */ | 154 | /* Last format capacity descriptor */ |
| 252 | idefloppy_capacity_descriptor_t capacity; | 155 | u8 cap_desc[8]; |
| 253 | /* Copy of the flexible disk page */ | 156 | /* Copy of the flexible disk page */ |
| 254 | idefloppy_flexible_disk_page_t flexible_disk_page; | 157 | u8 flexible_disk_page[32]; |
| 255 | /* Write protect */ | 158 | /* Write protect */ |
| 256 | int wp; | 159 | int wp; |
| 257 | /* Supports format progress report */ | 160 | /* Supports format progress report */ |
| @@ -262,64 +165,40 @@ typedef struct ide_floppy_obj { | |||
| 262 | 165 | ||
| 263 | #define IDEFLOPPY_TICKS_DELAY HZ/20 /* default delay for ZIP 100 (50ms) */ | 166 | #define IDEFLOPPY_TICKS_DELAY HZ/20 /* default delay for ZIP 100 (50ms) */ |
| 264 | 167 | ||
| 265 | /* | 168 | /* Floppy flag bits values. */ |
| 266 | * Floppy flag bits values. | 169 | enum { |
| 267 | */ | 170 | /* DRQ interrupt device */ |
| 268 | #define IDEFLOPPY_DRQ_INTERRUPT 0 /* DRQ interrupt device */ | 171 | IDEFLOPPY_FLAG_DRQ_INTERRUPT = (1 << 0), |
| 269 | #define IDEFLOPPY_MEDIA_CHANGED 1 /* Media may have changed */ | 172 | /* Media may have changed */ |
| 270 | #define IDEFLOPPY_USE_READ12 2 /* Use READ12/WRITE12 or READ10/WRITE10 */ | 173 | IDEFLOPPY_FLAG_MEDIA_CHANGED = (1 << 1), |
| 271 | #define IDEFLOPPY_FORMAT_IN_PROGRESS 3 /* Format in progress */ | 174 | /* Format in progress */ |
| 272 | #define IDEFLOPPY_CLIK_DRIVE 4 /* Avoid commands not supported in Clik drive */ | 175 | IDEFLOPPY_FLAG_FORMAT_IN_PROGRESS = (1 << 2), |
| 273 | #define IDEFLOPPY_ZIP_DRIVE 5 /* Requires BH algorithm for packets */ | 176 | /* Avoid commands not supported in Clik drive */ |
| 274 | 177 | IDEFLOPPY_FLAG_CLIK_DRIVE = (1 << 3), | |
| 275 | /* | 178 | /* Requires BH algorithm for packets */ |
| 276 | * ATAPI floppy drive packet commands | 179 | IDEFLOPPY_FLAG_ZIP_DRIVE = (1 << 4), |
| 277 | */ | 180 | }; |
| 278 | #define IDEFLOPPY_FORMAT_UNIT_CMD 0x04 | ||
| 279 | #define IDEFLOPPY_INQUIRY_CMD 0x12 | ||
| 280 | #define IDEFLOPPY_MODE_SELECT_CMD 0x55 | ||
| 281 | #define IDEFLOPPY_MODE_SENSE_CMD 0x5a | ||
| 282 | #define IDEFLOPPY_READ10_CMD 0x28 | ||
| 283 | #define IDEFLOPPY_READ12_CMD 0xa8 | ||
| 284 | #define IDEFLOPPY_READ_CAPACITY_CMD 0x23 | ||
| 285 | #define IDEFLOPPY_REQUEST_SENSE_CMD 0x03 | ||
| 286 | #define IDEFLOPPY_PREVENT_REMOVAL_CMD 0x1e | ||
| 287 | #define IDEFLOPPY_SEEK_CMD 0x2b | ||
| 288 | #define IDEFLOPPY_START_STOP_CMD 0x1b | ||
| 289 | #define IDEFLOPPY_TEST_UNIT_READY_CMD 0x00 | ||
| 290 | #define IDEFLOPPY_VERIFY_CMD 0x2f | ||
| 291 | #define IDEFLOPPY_WRITE10_CMD 0x2a | ||
| 292 | #define IDEFLOPPY_WRITE12_CMD 0xaa | ||
| 293 | #define IDEFLOPPY_WRITE_VERIFY_CMD 0x2e | ||
| 294 | 181 | ||
| 295 | /* | 182 | /* Defines for the MODE SENSE command */ |
| 296 | * Defines for the mode sense command | ||
| 297 | */ | ||
| 298 | #define MODE_SENSE_CURRENT 0x00 | 183 | #define MODE_SENSE_CURRENT 0x00 |
| 299 | #define MODE_SENSE_CHANGEABLE 0x01 | 184 | #define MODE_SENSE_CHANGEABLE 0x01 |
| 300 | #define MODE_SENSE_DEFAULT 0x02 | 185 | #define MODE_SENSE_DEFAULT 0x02 |
| 301 | #define MODE_SENSE_SAVED 0x03 | 186 | #define MODE_SENSE_SAVED 0x03 |
| 302 | 187 | ||
| 303 | /* | 188 | /* IOCTLs used in low-level formatting. */ |
| 304 | * IOCTLs used in low-level formatting. | ||
| 305 | */ | ||
| 306 | |||
| 307 | #define IDEFLOPPY_IOCTL_FORMAT_SUPPORTED 0x4600 | 189 | #define IDEFLOPPY_IOCTL_FORMAT_SUPPORTED 0x4600 |
| 308 | #define IDEFLOPPY_IOCTL_FORMAT_GET_CAPACITY 0x4601 | 190 | #define IDEFLOPPY_IOCTL_FORMAT_GET_CAPACITY 0x4601 |
| 309 | #define IDEFLOPPY_IOCTL_FORMAT_START 0x4602 | 191 | #define IDEFLOPPY_IOCTL_FORMAT_START 0x4602 |
| 310 | #define IDEFLOPPY_IOCTL_FORMAT_GET_PROGRESS 0x4603 | 192 | #define IDEFLOPPY_IOCTL_FORMAT_GET_PROGRESS 0x4603 |
| 311 | 193 | ||
| 312 | /* | 194 | /* Error code returned in rq->errors to the higher part of the driver. */ |
| 313 | * Error codes which are returned in rq->errors to the higher part | ||
| 314 | * of the driver. | ||
| 315 | */ | ||
| 316 | #define IDEFLOPPY_ERROR_GENERAL 101 | 195 | #define IDEFLOPPY_ERROR_GENERAL 101 |
| 317 | 196 | ||
| 318 | /* | 197 | /* |
| 319 | * The following is used to format the general configuration word of | 198 | * The following is used to format the general configuration word of the |
| 320 | * the ATAPI IDENTIFY DEVICE command. | 199 | * ATAPI IDENTIFY DEVICE command. |
| 321 | */ | 200 | */ |
| 322 | struct idefloppy_id_gcw { | 201 | struct idefloppy_id_gcw { |
| 323 | #if defined(__LITTLE_ENDIAN_BITFIELD) | 202 | #if defined(__LITTLE_ENDIAN_BITFIELD) |
| 324 | unsigned packet_size :2; /* Packet Size */ | 203 | unsigned packet_size :2; /* Packet Size */ |
| 325 | unsigned reserved234 :3; /* Reserved */ | 204 | unsigned reserved234 :3; /* Reserved */ |
| @@ -342,103 +221,12 @@ struct idefloppy_id_gcw { | |||
| 342 | }; | 221 | }; |
| 343 | 222 | ||
| 344 | /* | 223 | /* |
| 345 | * INQUIRY packet command - Data Format | 224 | * Pages of the SELECT SENSE / MODE SENSE packet commands. |
| 346 | */ | 225 | * See SFF-8070i spec. |
| 347 | typedef struct { | ||
| 348 | #if defined(__LITTLE_ENDIAN_BITFIELD) | ||
| 349 | unsigned device_type :5; /* Peripheral Device Type */ | ||
| 350 | unsigned reserved0_765 :3; /* Peripheral Qualifier - Reserved */ | ||
| 351 | unsigned reserved1_6t0 :7; /* Reserved */ | ||
| 352 | unsigned rmb :1; /* Removable Medium Bit */ | ||
| 353 | unsigned ansi_version :3; /* ANSI Version */ | ||
| 354 | unsigned ecma_version :3; /* ECMA Version */ | ||
| 355 | unsigned iso_version :2; /* ISO Version */ | ||
| 356 | unsigned response_format :4; /* Response Data Format */ | ||
| 357 | unsigned reserved3_45 :2; /* Reserved */ | ||
| 358 | unsigned reserved3_6 :1; /* TrmIOP - Reserved */ | ||
| 359 | unsigned reserved3_7 :1; /* AENC - Reserved */ | ||
| 360 | #elif defined(__BIG_ENDIAN_BITFIELD) | ||
| 361 | unsigned reserved0_765 :3; /* Peripheral Qualifier - Reserved */ | ||
| 362 | unsigned device_type :5; /* Peripheral Device Type */ | ||
| 363 | unsigned rmb :1; /* Removable Medium Bit */ | ||
| 364 | unsigned reserved1_6t0 :7; /* Reserved */ | ||
| 365 | unsigned iso_version :2; /* ISO Version */ | ||
| 366 | unsigned ecma_version :3; /* ECMA Version */ | ||
| 367 | unsigned ansi_version :3; /* ANSI Version */ | ||
| 368 | unsigned reserved3_7 :1; /* AENC - Reserved */ | ||
| 369 | unsigned reserved3_6 :1; /* TrmIOP - Reserved */ | ||
| 370 | unsigned reserved3_45 :2; /* Reserved */ | ||
| 371 | unsigned response_format :4; /* Response Data Format */ | ||
| 372 | #else | ||
| 373 | #error "Bitfield endianness not defined! Check your byteorder.h" | ||
| 374 | #endif | ||
| 375 | u8 additional_length; /* Additional Length (total_length-4) */ | ||
| 376 | u8 rsv5, rsv6, rsv7; /* Reserved */ | ||
| 377 | u8 vendor_id[8]; /* Vendor Identification */ | ||
| 378 | u8 product_id[16]; /* Product Identification */ | ||
| 379 | u8 revision_level[4]; /* Revision Level */ | ||
| 380 | u8 vendor_specific[20]; /* Vendor Specific - Optional */ | ||
| 381 | u8 reserved56t95[40]; /* Reserved - Optional */ | ||
| 382 | /* Additional information may be returned */ | ||
| 383 | } idefloppy_inquiry_result_t; | ||
| 384 | |||
| 385 | /* | ||
| 386 | * REQUEST SENSE packet command result - Data Format. | ||
| 387 | */ | ||
| 388 | typedef struct { | ||
| 389 | #if defined(__LITTLE_ENDIAN_BITFIELD) | ||
| 390 | unsigned error_code :7; /* Current error (0x70) */ | ||
| 391 | unsigned valid :1; /* The information field conforms to SFF-8070i */ | ||
| 392 | u8 reserved1 :8; /* Reserved */ | ||
| 393 | unsigned sense_key :4; /* Sense Key */ | ||
| 394 | unsigned reserved2_4 :1; /* Reserved */ | ||
| 395 | unsigned ili :1; /* Incorrect Length Indicator */ | ||
| 396 | unsigned reserved2_67 :2; | ||
| 397 | #elif defined(__BIG_ENDIAN_BITFIELD) | ||
| 398 | unsigned valid :1; /* The information field conforms to SFF-8070i */ | ||
| 399 | unsigned error_code :7; /* Current error (0x70) */ | ||
| 400 | u8 reserved1 :8; /* Reserved */ | ||
| 401 | unsigned reserved2_67 :2; | ||
| 402 | unsigned ili :1; /* Incorrect Length Indicator */ | ||
| 403 | unsigned reserved2_4 :1; /* Reserved */ | ||
| 404 | unsigned sense_key :4; /* Sense Key */ | ||
| 405 | #else | ||
| 406 | #error "Bitfield endianness not defined! Check your byteorder.h" | ||
| 407 | #endif | ||
| 408 | u32 information __attribute__ ((packed)); | ||
| 409 | u8 asl; /* Additional sense length (n-7) */ | ||
| 410 | u32 command_specific; /* Additional command specific information */ | ||
| 411 | u8 asc; /* Additional Sense Code */ | ||
| 412 | u8 ascq; /* Additional Sense Code Qualifier */ | ||
| 413 | u8 replaceable_unit_code; /* Field Replaceable Unit Code */ | ||
| 414 | u8 sksv[3]; | ||
| 415 | u8 pad[2]; /* Padding to 20 bytes */ | ||
| 416 | } idefloppy_request_sense_result_t; | ||
| 417 | |||
| 418 | /* | ||
| 419 | * Pages of the SELECT SENSE / MODE SENSE packet commands. | ||
| 420 | */ | 226 | */ |
| 421 | #define IDEFLOPPY_CAPABILITIES_PAGE 0x1b | 227 | #define IDEFLOPPY_CAPABILITIES_PAGE 0x1b |
| 422 | #define IDEFLOPPY_FLEXIBLE_DISK_PAGE 0x05 | 228 | #define IDEFLOPPY_FLEXIBLE_DISK_PAGE 0x05 |
| 423 | 229 | ||
| 424 | /* | ||
| 425 | * Mode Parameter Header for the MODE SENSE packet command | ||
| 426 | */ | ||
| 427 | typedef struct { | ||
| 428 | u16 mode_data_length; /* Length of the following data transfer */ | ||
| 429 | u8 medium_type; /* Medium Type */ | ||
| 430 | #if defined(__LITTLE_ENDIAN_BITFIELD) | ||
| 431 | unsigned reserved3 :7; | ||
| 432 | unsigned wp :1; /* Write protect */ | ||
| 433 | #elif defined(__BIG_ENDIAN_BITFIELD) | ||
| 434 | unsigned wp :1; /* Write protect */ | ||
| 435 | unsigned reserved3 :7; | ||
| 436 | #else | ||
| 437 | #error "Bitfield endianness not defined! Check your byteorder.h" | ||
| 438 | #endif | ||
| 439 | u8 reserved[4]; | ||
| 440 | } idefloppy_mode_parameter_header_t; | ||
| 441 | |||
| 442 | static DEFINE_MUTEX(idefloppy_ref_mutex); | 230 | static DEFINE_MUTEX(idefloppy_ref_mutex); |
| 443 | 231 | ||
| 444 | #define to_ide_floppy(obj) container_of(obj, struct ide_floppy_obj, kref) | 232 | #define to_ide_floppy(obj) container_of(obj, struct ide_floppy_obj, kref) |
| @@ -458,39 +246,35 @@ static struct ide_floppy_obj *ide_floppy_get(struct gendisk *disk) | |||
| 458 | return floppy; | 246 | return floppy; |
| 459 | } | 247 | } |
| 460 | 248 | ||
| 461 | static void ide_floppy_release(struct kref *); | 249 | static void idefloppy_cleanup_obj(struct kref *); |
| 462 | 250 | ||
| 463 | static void ide_floppy_put(struct ide_floppy_obj *floppy) | 251 | static void ide_floppy_put(struct ide_floppy_obj *floppy) |
| 464 | { | 252 | { |
| 465 | mutex_lock(&idefloppy_ref_mutex); | 253 | mutex_lock(&idefloppy_ref_mutex); |
| 466 | kref_put(&floppy->kref, ide_floppy_release); | 254 | kref_put(&floppy->kref, idefloppy_cleanup_obj); |
| 467 | mutex_unlock(&idefloppy_ref_mutex); | 255 | mutex_unlock(&idefloppy_ref_mutex); |
| 468 | } | 256 | } |
| 469 | 257 | ||
| 470 | /* | 258 | /* |
| 471 | * Too bad. The drive wants to send us data which we are not ready to accept. | 259 | * Too bad. The drive wants to send us data which we are not ready to accept. |
| 472 | * Just throw it away. | 260 | * Just throw it away. |
| 473 | */ | 261 | */ |
| 474 | static void idefloppy_discard_data (ide_drive_t *drive, unsigned int bcount) | 262 | static void idefloppy_discard_data(ide_drive_t *drive, unsigned int bcount) |
| 475 | { | 263 | { |
| 476 | while (bcount--) | 264 | while (bcount--) |
| 477 | (void) HWIF(drive)->INB(IDE_DATA_REG); | 265 | (void) HWIF(drive)->INB(IDE_DATA_REG); |
| 478 | } | 266 | } |
| 479 | 267 | ||
| 480 | #if IDEFLOPPY_DEBUG_BUGS | 268 | static void idefloppy_write_zeros(ide_drive_t *drive, unsigned int bcount) |
| 481 | static void idefloppy_write_zeros (ide_drive_t *drive, unsigned int bcount) | ||
| 482 | { | 269 | { |
| 483 | while (bcount--) | 270 | while (bcount--) |
| 484 | HWIF(drive)->OUTB(0, IDE_DATA_REG); | 271 | HWIF(drive)->OUTB(0, IDE_DATA_REG); |
| 485 | } | 272 | } |
| 486 | #endif /* IDEFLOPPY_DEBUG_BUGS */ | ||
| 487 | 273 | ||
| 488 | 274 | ||
| 489 | /* | 275 | /* |
| 490 | * idefloppy_do_end_request is used to finish servicing a request. | 276 | * Used to finish servicing a request. For read/write requests, we will call |
| 491 | * | 277 | * ide_end_request to pass to the next buffer. |
| 492 | * For read/write requests, we will call ide_end_request to pass to the | ||
| 493 | * next buffer. | ||
| 494 | */ | 278 | */ |
| 495 | static int idefloppy_do_end_request(ide_drive_t *drive, int uptodate, int nsecs) | 279 | static int idefloppy_do_end_request(ide_drive_t *drive, int uptodate, int nsecs) |
| 496 | { | 280 | { |
| @@ -498,12 +282,12 @@ static int idefloppy_do_end_request(ide_drive_t *drive, int uptodate, int nsecs) | |||
| 498 | struct request *rq = HWGROUP(drive)->rq; | 282 | struct request *rq = HWGROUP(drive)->rq; |
| 499 | int error; | 283 | int error; |
| 500 | 284 | ||
| 501 | debug_log(KERN_INFO "Reached idefloppy_end_request\n"); | 285 | debug_log("Reached %s\n", __func__); |
| 502 | 286 | ||
| 503 | switch (uptodate) { | 287 | switch (uptodate) { |
| 504 | case 0: error = IDEFLOPPY_ERROR_GENERAL; break; | 288 | case 0: error = IDEFLOPPY_ERROR_GENERAL; break; |
| 505 | case 1: error = 0; break; | 289 | case 1: error = 0; break; |
| 506 | default: error = uptodate; | 290 | default: error = uptodate; |
| 507 | } | 291 | } |
| 508 | if (error) | 292 | if (error) |
| 509 | floppy->failed_pc = NULL; | 293 | floppy->failed_pc = NULL; |
| @@ -521,39 +305,8 @@ static int idefloppy_do_end_request(ide_drive_t *drive, int uptodate, int nsecs) | |||
| 521 | return 0; | 305 | return 0; |
| 522 | } | 306 | } |
| 523 | 307 | ||
| 524 | static void idefloppy_input_buffers (ide_drive_t *drive, idefloppy_pc_t *pc, unsigned int bcount) | 308 | static void ide_floppy_io_buffers(ide_drive_t *drive, idefloppy_pc_t *pc, |
| 525 | { | 309 | unsigned int bcount, int direction) |
| 526 | struct request *rq = pc->rq; | ||
| 527 | struct bio_vec *bvec; | ||
| 528 | struct req_iterator iter; | ||
| 529 | unsigned long flags; | ||
| 530 | char *data; | ||
| 531 | int count, done = 0; | ||
| 532 | |||
| 533 | rq_for_each_segment(bvec, rq, iter) { | ||
| 534 | if (!bcount) | ||
| 535 | break; | ||
| 536 | |||
| 537 | count = min(bvec->bv_len, bcount); | ||
| 538 | |||
| 539 | data = bvec_kmap_irq(bvec, &flags); | ||
| 540 | drive->hwif->atapi_input_bytes(drive, data, count); | ||
| 541 | bvec_kunmap_irq(data, &flags); | ||
| 542 | |||
| 543 | bcount -= count; | ||
| 544 | pc->b_count += count; | ||
| 545 | done += count; | ||
| 546 | } | ||
| 547 | |||
| 548 | idefloppy_do_end_request(drive, 1, done >> 9); | ||
| 549 | |||
| 550 | if (bcount) { | ||
| 551 | printk(KERN_ERR "%s: leftover data in idefloppy_input_buffers, bcount == %d\n", drive->name, bcount); | ||
| 552 | idefloppy_discard_data(drive, bcount); | ||
| 553 | } | ||
| 554 | } | ||
| 555 | |||
| 556 | static void idefloppy_output_buffers (ide_drive_t *drive, idefloppy_pc_t *pc, unsigned int bcount) | ||
| 557 | { | 310 | { |
| 558 | struct request *rq = pc->rq; | 311 | struct request *rq = pc->rq; |
| 559 | struct req_iterator iter; | 312 | struct req_iterator iter; |
| @@ -569,7 +322,10 @@ static void idefloppy_output_buffers (ide_drive_t *drive, idefloppy_pc_t *pc, un | |||
| 569 | count = min(bvec->bv_len, bcount); | 322 | count = min(bvec->bv_len, bcount); |
| 570 | 323 | ||
| 571 | data = bvec_kmap_irq(bvec, &flags); | 324 | data = bvec_kmap_irq(bvec, &flags); |
| 572 | drive->hwif->atapi_output_bytes(drive, data, count); | 325 | if (direction) |
| 326 | drive->hwif->atapi_output_bytes(drive, data, count); | ||
| 327 | else | ||
| 328 | drive->hwif->atapi_input_bytes(drive, data, count); | ||
| 573 | bvec_kunmap_irq(data, &flags); | 329 | bvec_kunmap_irq(data, &flags); |
| 574 | 330 | ||
| 575 | bcount -= count; | 331 | bcount -= count; |
| @@ -579,15 +335,18 @@ static void idefloppy_output_buffers (ide_drive_t *drive, idefloppy_pc_t *pc, un | |||
| 579 | 335 | ||
| 580 | idefloppy_do_end_request(drive, 1, done >> 9); | 336 | idefloppy_do_end_request(drive, 1, done >> 9); |
| 581 | 337 | ||
| 582 | #if IDEFLOPPY_DEBUG_BUGS | ||
| 583 | if (bcount) { | 338 | if (bcount) { |
| 584 | printk(KERN_ERR "%s: leftover data in idefloppy_output_buffers, bcount == %d\n", drive->name, bcount); | 339 | printk(KERN_ERR "%s: leftover data in %s, bcount == %d\n", |
| 585 | idefloppy_write_zeros(drive, bcount); | 340 | drive->name, __func__, bcount); |
| 341 | if (direction) | ||
| 342 | idefloppy_write_zeros(drive, bcount); | ||
| 343 | else | ||
| 344 | idefloppy_discard_data(drive, bcount); | ||
| 345 | |||
| 586 | } | 346 | } |
| 587 | #endif | ||
| 588 | } | 347 | } |
| 589 | 348 | ||
| 590 | static void idefloppy_update_buffers (ide_drive_t *drive, idefloppy_pc_t *pc) | 349 | static void idefloppy_update_buffers(ide_drive_t *drive, idefloppy_pc_t *pc) |
| 591 | { | 350 | { |
| 592 | struct request *rq = pc->rq; | 351 | struct request *rq = pc->rq; |
| 593 | struct bio *bio = rq->bio; | 352 | struct bio *bio = rq->bio; |
| @@ -597,11 +356,12 @@ static void idefloppy_update_buffers (ide_drive_t *drive, idefloppy_pc_t *pc) | |||
| 597 | } | 356 | } |
| 598 | 357 | ||
| 599 | /* | 358 | /* |
| 600 | * idefloppy_queue_pc_head generates a new packet command request in front | 359 | * Generate a new packet command request in front of the request queue, before |
| 601 | * of the request queue, before the current request, so that it will be | 360 | * the current request so that it will be processed immediately, on the next |
| 602 | * processed immediately, on the next pass through the driver. | 361 | * pass through the driver. |
| 603 | */ | 362 | */ |
| 604 | static void idefloppy_queue_pc_head (ide_drive_t *drive,idefloppy_pc_t *pc,struct request *rq) | 363 | static void idefloppy_queue_pc_head(ide_drive_t *drive, idefloppy_pc_t *pc, |
| 364 | struct request *rq) | ||
| 605 | { | 365 | { |
| 606 | struct ide_floppy_obj *floppy = drive->driver_data; | 366 | struct ide_floppy_obj *floppy = drive->driver_data; |
| 607 | 367 | ||
| @@ -612,16 +372,16 @@ static void idefloppy_queue_pc_head (ide_drive_t *drive,idefloppy_pc_t *pc,struc | |||
| 612 | (void) ide_do_drive_cmd(drive, rq, ide_preempt); | 372 | (void) ide_do_drive_cmd(drive, rq, ide_preempt); |
| 613 | } | 373 | } |
| 614 | 374 | ||
| 615 | static idefloppy_pc_t *idefloppy_next_pc_storage (ide_drive_t *drive) | 375 | static idefloppy_pc_t *idefloppy_next_pc_storage(ide_drive_t *drive) |
| 616 | { | 376 | { |
| 617 | idefloppy_floppy_t *floppy = drive->driver_data; | 377 | idefloppy_floppy_t *floppy = drive->driver_data; |
| 618 | 378 | ||
| 619 | if (floppy->pc_stack_index == IDEFLOPPY_PC_STACK) | 379 | if (floppy->pc_stack_index == IDEFLOPPY_PC_STACK) |
| 620 | floppy->pc_stack_index=0; | 380 | floppy->pc_stack_index = 0; |
| 621 | return (&floppy->pc_stack[floppy->pc_stack_index++]); | 381 | return (&floppy->pc_stack[floppy->pc_stack_index++]); |
| 622 | } | 382 | } |
| 623 | 383 | ||
| 624 | static struct request *idefloppy_next_rq_storage (ide_drive_t *drive) | 384 | static struct request *idefloppy_next_rq_storage(ide_drive_t *drive) |
| 625 | { | 385 | { |
| 626 | idefloppy_floppy_t *floppy = drive->driver_data; | 386 | idefloppy_floppy_t *floppy = drive->driver_data; |
| 627 | 387 | ||
| @@ -630,60 +390,53 @@ static struct request *idefloppy_next_rq_storage (ide_drive_t *drive) | |||
| 630 | return (&floppy->rq_stack[floppy->rq_stack_index++]); | 390 | return (&floppy->rq_stack[floppy->rq_stack_index++]); |
| 631 | } | 391 | } |
| 632 | 392 | ||
| 633 | /* | 393 | static void idefloppy_request_sense_callback(ide_drive_t *drive) |
| 634 | * idefloppy_analyze_error is called on each failed packet command retry | ||
| 635 | * to analyze the request sense. | ||
| 636 | */ | ||
| 637 | static void idefloppy_analyze_error (ide_drive_t *drive,idefloppy_request_sense_result_t *result) | ||
| 638 | { | 394 | { |
| 639 | idefloppy_floppy_t *floppy = drive->driver_data; | 395 | idefloppy_floppy_t *floppy = drive->driver_data; |
| 396 | u8 *buf = floppy->pc->buffer; | ||
| 640 | 397 | ||
| 641 | floppy->sense_key = result->sense_key; | 398 | debug_log("Reached %s\n", __func__); |
| 642 | floppy->asc = result->asc; | ||
| 643 | floppy->ascq = result->ascq; | ||
| 644 | floppy->progress_indication = result->sksv[0] & 0x80 ? | ||
| 645 | (u16)get_unaligned((u16 *)(result->sksv+1)):0x10000; | ||
| 646 | if (floppy->failed_pc) | ||
| 647 | debug_log(KERN_INFO "ide-floppy: pc = %x, sense key = %x, " | ||
| 648 | "asc = %x, ascq = %x\n", floppy->failed_pc->c[0], | ||
| 649 | result->sense_key, result->asc, result->ascq); | ||
| 650 | else | ||
| 651 | debug_log(KERN_INFO "ide-floppy: sense key = %x, asc = %x, " | ||
| 652 | "ascq = %x\n", result->sense_key, | ||
| 653 | result->asc, result->ascq); | ||
| 654 | } | ||
| 655 | |||
| 656 | static void idefloppy_request_sense_callback (ide_drive_t *drive) | ||
| 657 | { | ||
| 658 | idefloppy_floppy_t *floppy = drive->driver_data; | ||
| 659 | 399 | ||
| 660 | debug_log(KERN_INFO "ide-floppy: Reached %s\n", __FUNCTION__); | ||
| 661 | |||
| 662 | if (!floppy->pc->error) { | 400 | if (!floppy->pc->error) { |
| 663 | idefloppy_analyze_error(drive,(idefloppy_request_sense_result_t *) floppy->pc->buffer); | 401 | floppy->sense_key = buf[2] & 0x0F; |
| 402 | floppy->asc = buf[12]; | ||
| 403 | floppy->ascq = buf[13]; | ||
| 404 | floppy->progress_indication = buf[15] & 0x80 ? | ||
| 405 | (u16)get_unaligned((u16 *)&buf[16]) : 0x10000; | ||
| 406 | |||
| 407 | if (floppy->failed_pc) | ||
| 408 | debug_log("pc = %x, sense key = %x, asc = %x," | ||
| 409 | " ascq = %x\n", | ||
| 410 | floppy->failed_pc->c[0], | ||
| 411 | floppy->sense_key, | ||
| 412 | floppy->asc, | ||
| 413 | floppy->ascq); | ||
| 414 | else | ||
| 415 | debug_log("sense key = %x, asc = %x, ascq = %x\n", | ||
| 416 | floppy->sense_key, | ||
| 417 | floppy->asc, | ||
| 418 | floppy->ascq); | ||
| 419 | |||
| 420 | |||
| 664 | idefloppy_do_end_request(drive, 1, 0); | 421 | idefloppy_do_end_request(drive, 1, 0); |
| 665 | } else { | 422 | } else { |
| 666 | printk(KERN_ERR "Error in REQUEST SENSE itself - Aborting request!\n"); | 423 | printk(KERN_ERR "Error in REQUEST SENSE itself - Aborting" |
| 424 | " request!\n"); | ||
| 667 | idefloppy_do_end_request(drive, 0, 0); | 425 | idefloppy_do_end_request(drive, 0, 0); |
| 668 | } | 426 | } |
| 669 | } | 427 | } |
| 670 | 428 | ||
| 671 | /* | 429 | /* General packet command callback function. */ |
| 672 | * General packet command callback function. | 430 | static void idefloppy_pc_callback(ide_drive_t *drive) |
| 673 | */ | ||
| 674 | static void idefloppy_pc_callback (ide_drive_t *drive) | ||
| 675 | { | 431 | { |
| 676 | idefloppy_floppy_t *floppy = drive->driver_data; | 432 | idefloppy_floppy_t *floppy = drive->driver_data; |
| 677 | 433 | ||
| 678 | debug_log(KERN_INFO "ide-floppy: Reached %s\n", __FUNCTION__); | 434 | debug_log("Reached %s\n", __func__); |
| 679 | 435 | ||
| 680 | idefloppy_do_end_request(drive, floppy->pc->error ? 0 : 1, 0); | 436 | idefloppy_do_end_request(drive, floppy->pc->error ? 0 : 1, 0); |
| 681 | } | 437 | } |
| 682 | 438 | ||
| 683 | /* | 439 | static void idefloppy_init_pc(idefloppy_pc_t *pc) |
| 684 | * idefloppy_init_pc initializes a packet command. | ||
| 685 | */ | ||
| 686 | static void idefloppy_init_pc (idefloppy_pc_t *pc) | ||
| 687 | { | 440 | { |
| 688 | memset(pc->c, 0, 12); | 441 | memset(pc->c, 0, 12); |
| 689 | pc->retries = 0; | 442 | pc->retries = 0; |
| @@ -694,21 +447,20 @@ static void idefloppy_init_pc (idefloppy_pc_t *pc) | |||
| 694 | pc->callback = &idefloppy_pc_callback; | 447 | pc->callback = &idefloppy_pc_callback; |
| 695 | } | 448 | } |
| 696 | 449 | ||
| 697 | static void idefloppy_create_request_sense_cmd (idefloppy_pc_t *pc) | 450 | static void idefloppy_create_request_sense_cmd(idefloppy_pc_t *pc) |
| 698 | { | 451 | { |
| 699 | idefloppy_init_pc(pc); | 452 | idefloppy_init_pc(pc); |
| 700 | pc->c[0] = IDEFLOPPY_REQUEST_SENSE_CMD; | 453 | pc->c[0] = GPCMD_REQUEST_SENSE; |
| 701 | pc->c[4] = 255; | 454 | pc->c[4] = 255; |
| 702 | pc->request_transfer = 18; | 455 | pc->request_transfer = 18; |
| 703 | pc->callback = &idefloppy_request_sense_callback; | 456 | pc->callback = &idefloppy_request_sense_callback; |
| 704 | } | 457 | } |
| 705 | 458 | ||
| 706 | /* | 459 | /* |
| 707 | * idefloppy_retry_pc is called when an error was detected during the | 460 | * Called when an error was detected during the last packet command. We queue a |
| 708 | * last packet command. We queue a request sense packet command in | 461 | * request sense packet command in the head of the request list. |
| 709 | * the head of the request list. | ||
| 710 | */ | 462 | */ |
| 711 | static void idefloppy_retry_pc (ide_drive_t *drive) | 463 | static void idefloppy_retry_pc(ide_drive_t *drive) |
| 712 | { | 464 | { |
| 713 | idefloppy_pc_t *pc; | 465 | idefloppy_pc_t *pc; |
| 714 | struct request *rq; | 466 | struct request *rq; |
| @@ -720,49 +472,50 @@ static void idefloppy_retry_pc (ide_drive_t *drive) | |||
| 720 | idefloppy_queue_pc_head(drive, pc, rq); | 472 | idefloppy_queue_pc_head(drive, pc, rq); |
| 721 | } | 473 | } |
| 722 | 474 | ||
| 723 | /* | 475 | /* The usual interrupt handler called during a packet command. */ |
| 724 | * idefloppy_pc_intr is the usual interrupt handler which will be called | ||
| 725 | * during a packet command. | ||
| 726 | */ | ||
| 727 | static ide_startstop_t idefloppy_pc_intr (ide_drive_t *drive) | 476 | static ide_startstop_t idefloppy_pc_intr (ide_drive_t *drive) |
| 728 | { | 477 | { |
| 729 | idefloppy_floppy_t *floppy = drive->driver_data; | 478 | idefloppy_floppy_t *floppy = drive->driver_data; |
| 730 | ide_hwif_t *hwif = drive->hwif; | 479 | ide_hwif_t *hwif = drive->hwif; |
| 731 | idefloppy_pc_t *pc = floppy->pc; | 480 | idefloppy_pc_t *pc = floppy->pc; |
| 732 | struct request *rq = pc->rq; | 481 | struct request *rq = pc->rq; |
| 482 | xfer_func_t *xferfunc; | ||
| 733 | unsigned int temp; | 483 | unsigned int temp; |
| 484 | int dma_error = 0; | ||
| 734 | u16 bcount; | 485 | u16 bcount; |
| 735 | u8 stat, ireason; | 486 | u8 stat, ireason; |
| 736 | 487 | ||
| 737 | debug_log(KERN_INFO "ide-floppy: Reached %s interrupt handler\n", | 488 | debug_log("Reached %s interrupt handler\n", __func__); |
| 738 | __FUNCTION__); | ||
| 739 | 489 | ||
| 740 | if (test_bit(PC_DMA_IN_PROGRESS, &pc->flags)) { | 490 | if (pc->flags & PC_FLAG_DMA_IN_PROGRESS) { |
| 741 | if (HWIF(drive)->ide_dma_end(drive)) { | 491 | dma_error = hwif->ide_dma_end(drive); |
| 742 | set_bit(PC_DMA_ERROR, &pc->flags); | 492 | if (dma_error) { |
| 493 | printk(KERN_ERR "%s: DMA %s error\n", drive->name, | ||
| 494 | rq_data_dir(rq) ? "write" : "read"); | ||
| 495 | pc->flags |= PC_FLAG_DMA_ERROR; | ||
| 743 | } else { | 496 | } else { |
| 744 | pc->actually_transferred = pc->request_transfer; | 497 | pc->actually_transferred = pc->request_transfer; |
| 745 | idefloppy_update_buffers(drive, pc); | 498 | idefloppy_update_buffers(drive, pc); |
| 746 | } | 499 | } |
| 747 | debug_log(KERN_INFO "ide-floppy: DMA finished\n"); | 500 | debug_log("DMA finished\n"); |
| 748 | } | 501 | } |
| 749 | 502 | ||
| 750 | /* Clear the interrupt */ | 503 | /* Clear the interrupt */ |
| 751 | stat = drive->hwif->INB(IDE_STATUS_REG); | 504 | stat = drive->hwif->INB(IDE_STATUS_REG); |
| 752 | 505 | ||
| 753 | if ((stat & DRQ_STAT) == 0) { /* No more interrupts */ | 506 | /* No more interrupts */ |
| 754 | debug_log(KERN_INFO "Packet command completed, %d bytes " | 507 | if ((stat & DRQ_STAT) == 0) { |
| 755 | "transferred\n", pc->actually_transferred); | 508 | debug_log("Packet command completed, %d bytes transferred\n", |
| 756 | clear_bit(PC_DMA_IN_PROGRESS, &pc->flags); | 509 | pc->actually_transferred); |
| 510 | pc->flags &= ~PC_FLAG_DMA_IN_PROGRESS; | ||
| 757 | 511 | ||
| 758 | local_irq_enable_in_hardirq(); | 512 | local_irq_enable_in_hardirq(); |
| 759 | 513 | ||
| 760 | if ((stat & ERR_STAT) || test_bit(PC_DMA_ERROR, &pc->flags)) { | 514 | if ((stat & ERR_STAT) || (pc->flags & PC_FLAG_DMA_ERROR)) { |
| 761 | /* Error detected */ | 515 | /* Error detected */ |
| 762 | debug_log(KERN_INFO "ide-floppy: %s: I/O error\n", | 516 | debug_log("%s: I/O error\n", drive->name); |
| 763 | drive->name); | ||
| 764 | rq->errors++; | 517 | rq->errors++; |
| 765 | if (pc->c[0] == IDEFLOPPY_REQUEST_SENSE_CMD) { | 518 | if (pc->c[0] == GPCMD_REQUEST_SENSE) { |
| 766 | printk(KERN_ERR "ide-floppy: I/O error in " | 519 | printk(KERN_ERR "ide-floppy: I/O error in " |
| 767 | "request sense command\n"); | 520 | "request sense command\n"); |
| 768 | return ide_do_reset(drive); | 521 | return ide_do_reset(drive); |
| @@ -780,7 +533,8 @@ static ide_startstop_t idefloppy_pc_intr (ide_drive_t *drive) | |||
| 780 | return ide_stopped; | 533 | return ide_stopped; |
| 781 | } | 534 | } |
| 782 | 535 | ||
| 783 | if (test_and_clear_bit(PC_DMA_IN_PROGRESS, &pc->flags)) { | 536 | if (pc->flags & PC_FLAG_DMA_IN_PROGRESS) { |
| 537 | pc->flags &= ~PC_FLAG_DMA_IN_PROGRESS; | ||
| 784 | printk(KERN_ERR "ide-floppy: The floppy wants to issue " | 538 | printk(KERN_ERR "ide-floppy: The floppy wants to issue " |
| 785 | "more interrupts in DMA mode\n"); | 539 | "more interrupts in DMA mode\n"); |
| 786 | ide_dma_off(drive); | 540 | ide_dma_off(drive); |
| @@ -794,10 +548,10 @@ static ide_startstop_t idefloppy_pc_intr (ide_drive_t *drive) | |||
| 794 | ireason = hwif->INB(IDE_IREASON_REG); | 548 | ireason = hwif->INB(IDE_IREASON_REG); |
| 795 | 549 | ||
| 796 | if (ireason & CD) { | 550 | if (ireason & CD) { |
| 797 | printk(KERN_ERR "ide-floppy: CoD != 0 in idefloppy_pc_intr\n"); | 551 | printk(KERN_ERR "ide-floppy: CoD != 0 in %s\n", __func__); |
| 798 | return ide_do_reset(drive); | 552 | return ide_do_reset(drive); |
| 799 | } | 553 | } |
| 800 | if (((ireason & IO) == IO) == test_bit(PC_WRITING, &pc->flags)) { | 554 | if (((ireason & IO) == IO) == !!(pc->flags & PC_FLAG_WRITING)) { |
| 801 | /* Hopefully, we will never get here */ | 555 | /* Hopefully, we will never get here */ |
| 802 | printk(KERN_ERR "ide-floppy: We wanted to %s, ", | 556 | printk(KERN_ERR "ide-floppy: We wanted to %s, ", |
| 803 | (ireason & IO) ? "Write" : "Read"); | 557 | (ireason & IO) ? "Write" : "Read"); |
| @@ -805,7 +559,7 @@ static ide_startstop_t idefloppy_pc_intr (ide_drive_t *drive) | |||
| 805 | (ireason & IO) ? "Read" : "Write"); | 559 | (ireason & IO) ? "Read" : "Write"); |
| 806 | return ide_do_reset(drive); | 560 | return ide_do_reset(drive); |
| 807 | } | 561 | } |
| 808 | if (!test_bit(PC_WRITING, &pc->flags)) { | 562 | if (!(pc->flags & PC_FLAG_WRITING)) { |
| 809 | /* Reading - Check that we have enough space */ | 563 | /* Reading - Check that we have enough space */ |
| 810 | temp = pc->actually_transferred + bcount; | 564 | temp = pc->actually_transferred + bcount; |
| 811 | if (temp > pc->request_transfer) { | 565 | if (temp > pc->request_transfer) { |
| @@ -814,39 +568,34 @@ static ide_startstop_t idefloppy_pc_intr (ide_drive_t *drive) | |||
| 814 | "to send us more data than expected " | 568 | "to send us more data than expected " |
| 815 | "- discarding data\n"); | 569 | "- discarding data\n"); |
| 816 | idefloppy_discard_data(drive, bcount); | 570 | idefloppy_discard_data(drive, bcount); |
| 817 | BUG_ON(HWGROUP(drive)->handler != NULL); | 571 | |
| 818 | ide_set_handler(drive, | 572 | ide_set_handler(drive, |
| 819 | &idefloppy_pc_intr, | 573 | &idefloppy_pc_intr, |
| 820 | IDEFLOPPY_WAIT_CMD, | 574 | IDEFLOPPY_WAIT_CMD, |
| 821 | NULL); | 575 | NULL); |
| 822 | return ide_started; | 576 | return ide_started; |
| 823 | } | 577 | } |
| 824 | debug_log(KERN_NOTICE "ide-floppy: The floppy wants to " | 578 | debug_log("The floppy wants to send us more data than" |
| 825 | "send us more data than expected - " | 579 | " expected - allowing transfer\n"); |
| 826 | "allowing transfer\n"); | ||
| 827 | } | 580 | } |
| 828 | } | 581 | } |
| 829 | if (test_bit(PC_WRITING, &pc->flags)) { | 582 | if (pc->flags & PC_FLAG_WRITING) |
| 830 | if (pc->buffer != NULL) | 583 | xferfunc = hwif->atapi_output_bytes; |
| 831 | /* Write the current buffer */ | 584 | else |
| 832 | hwif->atapi_output_bytes(drive, pc->current_position, | 585 | xferfunc = hwif->atapi_input_bytes; |
| 833 | bcount); | 586 | |
| 834 | else | 587 | if (pc->buffer) |
| 835 | idefloppy_output_buffers(drive, pc, bcount); | 588 | xferfunc(drive, pc->current_position, bcount); |
| 836 | } else { | 589 | else |
| 837 | if (pc->buffer != NULL) | 590 | ide_floppy_io_buffers(drive, pc, bcount, |
| 838 | /* Read the current buffer */ | 591 | !!(pc->flags & PC_FLAG_WRITING)); |
| 839 | hwif->atapi_input_bytes(drive, pc->current_position, | 592 | |
| 840 | bcount); | ||
| 841 | else | ||
| 842 | idefloppy_input_buffers(drive, pc, bcount); | ||
| 843 | } | ||
| 844 | /* Update the current position */ | 593 | /* Update the current position */ |
| 845 | pc->actually_transferred += bcount; | 594 | pc->actually_transferred += bcount; |
| 846 | pc->current_position += bcount; | 595 | pc->current_position += bcount; |
| 847 | 596 | ||
| 848 | BUG_ON(HWGROUP(drive)->handler != NULL); | 597 | /* And set the interrupt handler again */ |
| 849 | ide_set_handler(drive, &idefloppy_pc_intr, IDEFLOPPY_WAIT_CMD, NULL); /* And set the interrupt handler again */ | 598 | ide_set_handler(drive, &idefloppy_pc_intr, IDEFLOPPY_WAIT_CMD, NULL); |
| 850 | return ide_started; | 599 | return ide_started; |
| 851 | } | 600 | } |
| 852 | 601 | ||
| @@ -855,7 +604,7 @@ static ide_startstop_t idefloppy_pc_intr (ide_drive_t *drive) | |||
| 855 | * It fails at high speeds on the Iomega ZIP drive, so there's a slower version | 604 | * It fails at high speeds on the Iomega ZIP drive, so there's a slower version |
| 856 | * for that drive below. The algorithm is chosen based on drive type | 605 | * for that drive below. The algorithm is chosen based on drive type |
| 857 | */ | 606 | */ |
| 858 | static ide_startstop_t idefloppy_transfer_pc (ide_drive_t *drive) | 607 | static ide_startstop_t idefloppy_transfer_pc(ide_drive_t *drive) |
| 859 | { | 608 | { |
| 860 | ide_startstop_t startstop; | 609 | ide_startstop_t startstop; |
| 861 | idefloppy_floppy_t *floppy = drive->driver_data; | 610 | idefloppy_floppy_t *floppy = drive->driver_data; |
| @@ -872,7 +621,7 @@ static ide_startstop_t idefloppy_transfer_pc (ide_drive_t *drive) | |||
| 872 | "issuing a packet command\n"); | 621 | "issuing a packet command\n"); |
| 873 | return ide_do_reset(drive); | 622 | return ide_do_reset(drive); |
| 874 | } | 623 | } |
| 875 | BUG_ON(HWGROUP(drive)->handler != NULL); | 624 | |
| 876 | /* Set the interrupt routine */ | 625 | /* Set the interrupt routine */ |
| 877 | ide_set_handler(drive, &idefloppy_pc_intr, IDEFLOPPY_WAIT_CMD, NULL); | 626 | ide_set_handler(drive, &idefloppy_pc_intr, IDEFLOPPY_WAIT_CMD, NULL); |
| 878 | /* Send the actual packet */ | 627 | /* Send the actual packet */ |
| @@ -882,18 +631,16 @@ static ide_startstop_t idefloppy_transfer_pc (ide_drive_t *drive) | |||
| 882 | 631 | ||
| 883 | 632 | ||
| 884 | /* | 633 | /* |
| 885 | * What we have here is a classic case of a top half / bottom half | 634 | * What we have here is a classic case of a top half / bottom half interrupt |
| 886 | * interrupt service routine. In interrupt mode, the device sends | 635 | * service routine. In interrupt mode, the device sends an interrupt to signal |
| 887 | * an interrupt to signal it's ready to receive a packet. However, | 636 | * that it is ready to receive a packet. However, we need to delay about 2-3 |
| 888 | * we need to delay about 2-3 ticks before issuing the packet or we | 637 | * ticks before issuing the packet or we gets in trouble. |
| 889 | * gets in trouble. | ||
| 890 | * | 638 | * |
| 891 | * So, follow carefully. transfer_pc1 is called as an interrupt (or | 639 | * So, follow carefully. transfer_pc1 is called as an interrupt (or directly). |
| 892 | * directly). In either case, when the device says it's ready for a | 640 | * In either case, when the device says it's ready for a packet, we schedule |
| 893 | * packet, we schedule the packet transfer to occur about 2-3 ticks | 641 | * the packet transfer to occur about 2-3 ticks later in transfer_pc2. |
| 894 | * later in transfer_pc2. | ||
| 895 | */ | 642 | */ |
| 896 | static int idefloppy_transfer_pc2 (ide_drive_t *drive) | 643 | static int idefloppy_transfer_pc2(ide_drive_t *drive) |
| 897 | { | 644 | { |
| 898 | idefloppy_floppy_t *floppy = drive->driver_data; | 645 | idefloppy_floppy_t *floppy = drive->driver_data; |
| 899 | 646 | ||
| @@ -903,7 +650,7 @@ static int idefloppy_transfer_pc2 (ide_drive_t *drive) | |||
| 903 | return IDEFLOPPY_WAIT_CMD; | 650 | return IDEFLOPPY_WAIT_CMD; |
| 904 | } | 651 | } |
| 905 | 652 | ||
| 906 | static ide_startstop_t idefloppy_transfer_pc1 (ide_drive_t *drive) | 653 | static ide_startstop_t idefloppy_transfer_pc1(ide_drive_t *drive) |
| 907 | { | 654 | { |
| 908 | idefloppy_floppy_t *floppy = drive->driver_data; | 655 | idefloppy_floppy_t *floppy = drive->driver_data; |
| 909 | ide_startstop_t startstop; | 656 | ide_startstop_t startstop; |
| @@ -920,7 +667,7 @@ static ide_startstop_t idefloppy_transfer_pc1 (ide_drive_t *drive) | |||
| 920 | "while issuing a packet command\n"); | 667 | "while issuing a packet command\n"); |
| 921 | return ide_do_reset(drive); | 668 | return ide_do_reset(drive); |
| 922 | } | 669 | } |
| 923 | /* | 670 | /* |
| 924 | * The following delay solves a problem with ATAPI Zip 100 drives | 671 | * The following delay solves a problem with ATAPI Zip 100 drives |
| 925 | * where the Busy flag was apparently being deasserted before the | 672 | * where the Busy flag was apparently being deasserted before the |
| 926 | * unit was ready to receive data. This was happening on a | 673 | * unit was ready to receive data. This was happening on a |
| @@ -928,32 +675,30 @@ static ide_startstop_t idefloppy_transfer_pc1 (ide_drive_t *drive) | |||
| 928 | * 40 and 50msec work well. idefloppy_pc_intr will not be actually | 675 | * 40 and 50msec work well. idefloppy_pc_intr will not be actually |
| 929 | * used until after the packet is moved in about 50 msec. | 676 | * used until after the packet is moved in about 50 msec. |
| 930 | */ | 677 | */ |
| 931 | BUG_ON(HWGROUP(drive)->handler != NULL); | 678 | |
| 932 | ide_set_handler(drive, | 679 | ide_set_handler(drive, &idefloppy_pc_intr, floppy->ticks, |
| 933 | &idefloppy_pc_intr, /* service routine for packet command */ | 680 | &idefloppy_transfer_pc2); |
| 934 | floppy->ticks, /* wait this long before "failing" */ | ||
| 935 | &idefloppy_transfer_pc2); /* fail == transfer_pc2 */ | ||
| 936 | return ide_started; | 681 | return ide_started; |
| 937 | } | 682 | } |
| 938 | 683 | ||
| 939 | /** | 684 | static void ide_floppy_report_error(idefloppy_floppy_t *floppy, |
| 940 | * idefloppy_should_report_error() | 685 | idefloppy_pc_t *pc) |
| 941 | * | ||
| 942 | * Supresses error messages resulting from Medium not present | ||
| 943 | */ | ||
| 944 | static inline int idefloppy_should_report_error(idefloppy_floppy_t *floppy) | ||
| 945 | { | 686 | { |
| 687 | /* supress error messages resulting from Medium not present */ | ||
| 946 | if (floppy->sense_key == 0x02 && | 688 | if (floppy->sense_key == 0x02 && |
| 947 | floppy->asc == 0x3a && | 689 | floppy->asc == 0x3a && |
| 948 | floppy->ascq == 0x00) | 690 | floppy->ascq == 0x00) |
| 949 | return 0; | 691 | return; |
| 950 | return 1; | 692 | |
| 693 | printk(KERN_ERR "ide-floppy: %s: I/O error, pc = %2x, key = %2x, " | ||
| 694 | "asc = %2x, ascq = %2x\n", | ||
| 695 | floppy->drive->name, pc->c[0], floppy->sense_key, | ||
| 696 | floppy->asc, floppy->ascq); | ||
| 697 | |||
| 951 | } | 698 | } |
| 952 | 699 | ||
| 953 | /* | 700 | static ide_startstop_t idefloppy_issue_pc(ide_drive_t *drive, |
| 954 | * Issue a packet command | 701 | idefloppy_pc_t *pc) |
| 955 | */ | ||
| 956 | static ide_startstop_t idefloppy_issue_pc (ide_drive_t *drive, idefloppy_pc_t *pc) | ||
| 957 | { | 702 | { |
| 958 | idefloppy_floppy_t *floppy = drive->driver_data; | 703 | idefloppy_floppy_t *floppy = drive->driver_data; |
| 959 | ide_hwif_t *hwif = drive->hwif; | 704 | ide_hwif_t *hwif = drive->hwif; |
| @@ -962,36 +707,23 @@ static ide_startstop_t idefloppy_issue_pc (ide_drive_t *drive, idefloppy_pc_t *p | |||
| 962 | u8 dma; | 707 | u8 dma; |
| 963 | 708 | ||
| 964 | if (floppy->failed_pc == NULL && | 709 | if (floppy->failed_pc == NULL && |
| 965 | pc->c[0] != IDEFLOPPY_REQUEST_SENSE_CMD) | 710 | pc->c[0] != GPCMD_REQUEST_SENSE) |
| 966 | floppy->failed_pc = pc; | 711 | floppy->failed_pc = pc; |
| 967 | /* Set the current packet command */ | 712 | /* Set the current packet command */ |
| 968 | floppy->pc = pc; | 713 | floppy->pc = pc; |
| 969 | 714 | ||
| 970 | if (pc->retries > IDEFLOPPY_MAX_PC_RETRIES || | 715 | if (pc->retries > IDEFLOPPY_MAX_PC_RETRIES) { |
| 971 | test_bit(PC_ABORT, &pc->flags)) { | 716 | if (!(pc->flags & PC_FLAG_SUPPRESS_ERROR)) |
| 972 | /* | 717 | ide_floppy_report_error(floppy, pc); |
| 973 | * We will "abort" retrying a packet command in case | 718 | /* Giving up */ |
| 974 | * a legitimate error code was received. | 719 | pc->error = IDEFLOPPY_ERROR_GENERAL; |
| 975 | */ | 720 | |
| 976 | if (!test_bit(PC_ABORT, &pc->flags)) { | ||
| 977 | if (!test_bit(PC_SUPPRESS_ERROR, &pc->flags)) { | ||
| 978 | if (idefloppy_should_report_error(floppy)) | ||
| 979 | printk(KERN_ERR "ide-floppy: %s: I/O error, " | ||
| 980 | "pc = %2x, key = %2x, " | ||
| 981 | "asc = %2x, ascq = %2x\n", | ||
| 982 | drive->name, pc->c[0], | ||
| 983 | floppy->sense_key, | ||
| 984 | floppy->asc, floppy->ascq); | ||
| 985 | } | ||
| 986 | /* Giving up */ | ||
| 987 | pc->error = IDEFLOPPY_ERROR_GENERAL; | ||
| 988 | } | ||
| 989 | floppy->failed_pc = NULL; | 721 | floppy->failed_pc = NULL; |
| 990 | pc->callback(drive); | 722 | pc->callback(drive); |
| 991 | return ide_stopped; | 723 | return ide_stopped; |
| 992 | } | 724 | } |
| 993 | 725 | ||
| 994 | debug_log(KERN_INFO "Retry number - %d\n",pc->retries); | 726 | debug_log("Retry number - %d\n", pc->retries); |
| 995 | 727 | ||
| 996 | pc->retries++; | 728 | pc->retries++; |
| 997 | /* We haven't transferred any data yet */ | 729 | /* We haven't transferred any data yet */ |
| @@ -999,24 +731,26 @@ static ide_startstop_t idefloppy_issue_pc (ide_drive_t *drive, idefloppy_pc_t *p | |||
| 999 | pc->current_position = pc->buffer; | 731 | pc->current_position = pc->buffer; |
| 1000 | bcount = min(pc->request_transfer, 63 * 1024); | 732 | bcount = min(pc->request_transfer, 63 * 1024); |
| 1001 | 733 | ||
| 1002 | if (test_and_clear_bit(PC_DMA_ERROR, &pc->flags)) | 734 | if (pc->flags & PC_FLAG_DMA_ERROR) { |
| 735 | pc->flags &= ~PC_FLAG_DMA_ERROR; | ||
| 1003 | ide_dma_off(drive); | 736 | ide_dma_off(drive); |
| 1004 | 737 | } | |
| 1005 | dma = 0; | 738 | dma = 0; |
| 1006 | 739 | ||
| 1007 | if (test_bit(PC_DMA_RECOMMENDED, &pc->flags) && drive->using_dma) | 740 | if ((pc->flags & PC_FLAG_DMA_RECOMMENDED) && drive->using_dma) |
| 1008 | dma = !hwif->dma_setup(drive); | 741 | dma = !hwif->dma_setup(drive); |
| 1009 | 742 | ||
| 1010 | ide_pktcmd_tf_load(drive, IDE_TFLAG_NO_SELECT_MASK | | 743 | ide_pktcmd_tf_load(drive, IDE_TFLAG_NO_SELECT_MASK | |
| 1011 | IDE_TFLAG_OUT_DEVICE, bcount, dma); | 744 | IDE_TFLAG_OUT_DEVICE, bcount, dma); |
| 1012 | 745 | ||
| 1013 | if (dma) { /* Begin DMA, if necessary */ | 746 | if (dma) { |
| 1014 | set_bit(PC_DMA_IN_PROGRESS, &pc->flags); | 747 | /* Begin DMA, if necessary */ |
| 748 | pc->flags |= PC_FLAG_DMA_IN_PROGRESS; | ||
| 1015 | hwif->dma_start(drive); | 749 | hwif->dma_start(drive); |
| 1016 | } | 750 | } |
| 1017 | 751 | ||
| 1018 | /* Can we transfer the packet when we get the interrupt or wait? */ | 752 | /* Can we transfer the packet when we get the interrupt or wait? */ |
| 1019 | if (test_bit(IDEFLOPPY_ZIP_DRIVE, &floppy->flags)) { | 753 | if (floppy->flags & IDEFLOPPY_FLAG_ZIP_DRIVE) { |
| 1020 | /* wait */ | 754 | /* wait */ |
| 1021 | pkt_xfer_routine = &idefloppy_transfer_pc1; | 755 | pkt_xfer_routine = &idefloppy_transfer_pc1; |
| 1022 | } else { | 756 | } else { |
| @@ -1024,7 +758,7 @@ static ide_startstop_t idefloppy_issue_pc (ide_drive_t *drive, idefloppy_pc_t *p | |||
| 1024 | pkt_xfer_routine = &idefloppy_transfer_pc; | 758 | pkt_xfer_routine = &idefloppy_transfer_pc; |
| 1025 | } | 759 | } |
| 1026 | 760 | ||
| 1027 | if (test_bit (IDEFLOPPY_DRQ_INTERRUPT, &floppy->flags)) { | 761 | if (floppy->flags & IDEFLOPPY_FLAG_DRQ_INTERRUPT) { |
| 1028 | /* Issue the packet command */ | 762 | /* Issue the packet command */ |
| 1029 | ide_execute_command(drive, WIN_PACKETCMD, | 763 | ide_execute_command(drive, WIN_PACKETCMD, |
| 1030 | pkt_xfer_routine, | 764 | pkt_xfer_routine, |
| @@ -1038,38 +772,37 @@ static ide_startstop_t idefloppy_issue_pc (ide_drive_t *drive, idefloppy_pc_t *p | |||
| 1038 | } | 772 | } |
| 1039 | } | 773 | } |
| 1040 | 774 | ||
| 1041 | static void idefloppy_rw_callback (ide_drive_t *drive) | 775 | static void idefloppy_rw_callback(ide_drive_t *drive) |
| 1042 | { | 776 | { |
| 1043 | debug_log(KERN_INFO "ide-floppy: Reached idefloppy_rw_callback\n"); | 777 | debug_log("Reached %s\n", __func__); |
| 1044 | 778 | ||
| 1045 | idefloppy_do_end_request(drive, 1, 0); | 779 | idefloppy_do_end_request(drive, 1, 0); |
| 1046 | return; | 780 | return; |
| 1047 | } | 781 | } |
| 1048 | 782 | ||
| 1049 | static void idefloppy_create_prevent_cmd (idefloppy_pc_t *pc, int prevent) | 783 | static void idefloppy_create_prevent_cmd(idefloppy_pc_t *pc, int prevent) |
| 1050 | { | 784 | { |
| 1051 | debug_log(KERN_INFO "ide-floppy: creating prevent removal command, " | 785 | debug_log("creating prevent removal command, prevent = %d\n", prevent); |
| 1052 | "prevent = %d\n", prevent); | ||
| 1053 | 786 | ||
| 1054 | idefloppy_init_pc(pc); | 787 | idefloppy_init_pc(pc); |
| 1055 | pc->c[0] = IDEFLOPPY_PREVENT_REMOVAL_CMD; | 788 | pc->c[0] = GPCMD_PREVENT_ALLOW_MEDIUM_REMOVAL; |
| 1056 | pc->c[4] = prevent; | 789 | pc->c[4] = prevent; |
| 1057 | } | 790 | } |
| 1058 | 791 | ||
| 1059 | static void idefloppy_create_read_capacity_cmd (idefloppy_pc_t *pc) | 792 | static void idefloppy_create_read_capacity_cmd(idefloppy_pc_t *pc) |
| 1060 | { | 793 | { |
| 1061 | idefloppy_init_pc(pc); | 794 | idefloppy_init_pc(pc); |
| 1062 | pc->c[0] = IDEFLOPPY_READ_CAPACITY_CMD; | 795 | pc->c[0] = GPCMD_READ_FORMAT_CAPACITIES; |
| 1063 | pc->c[7] = 255; | 796 | pc->c[7] = 255; |
| 1064 | pc->c[8] = 255; | 797 | pc->c[8] = 255; |
| 1065 | pc->request_transfer = 255; | 798 | pc->request_transfer = 255; |
| 1066 | } | 799 | } |
| 1067 | 800 | ||
| 1068 | static void idefloppy_create_format_unit_cmd (idefloppy_pc_t *pc, int b, int l, | 801 | static void idefloppy_create_format_unit_cmd(idefloppy_pc_t *pc, int b, int l, |
| 1069 | int flags) | 802 | int flags) |
| 1070 | { | 803 | { |
| 1071 | idefloppy_init_pc(pc); | 804 | idefloppy_init_pc(pc); |
| 1072 | pc->c[0] = IDEFLOPPY_FORMAT_UNIT_CMD; | 805 | pc->c[0] = GPCMD_FORMAT_UNIT; |
| 1073 | pc->c[1] = 0x17; | 806 | pc->c[1] = 0x17; |
| 1074 | 807 | ||
| 1075 | memset(pc->buffer, 0, 12); | 808 | memset(pc->buffer, 0, 12); |
| @@ -1080,83 +813,79 @@ static void idefloppy_create_format_unit_cmd (idefloppy_pc_t *pc, int b, int l, | |||
| 1080 | pc->buffer[1] ^= 0x20; /* ... turn off DCRT bit */ | 813 | pc->buffer[1] ^= 0x20; /* ... turn off DCRT bit */ |
| 1081 | pc->buffer[3] = 8; | 814 | pc->buffer[3] = 8; |
| 1082 | 815 | ||
| 1083 | put_unaligned(htonl(b), (unsigned int *)(&pc->buffer[4])); | 816 | put_unaligned(cpu_to_be32(b), (unsigned int *)(&pc->buffer[4])); |
| 1084 | put_unaligned(htonl(l), (unsigned int *)(&pc->buffer[8])); | 817 | put_unaligned(cpu_to_be32(l), (unsigned int *)(&pc->buffer[8])); |
| 1085 | pc->buffer_size=12; | 818 | pc->buffer_size = 12; |
| 1086 | set_bit(PC_WRITING, &pc->flags); | 819 | pc->flags |= PC_FLAG_WRITING; |
| 1087 | } | 820 | } |
| 1088 | 821 | ||
| 1089 | /* | 822 | /* A mode sense command is used to "sense" floppy parameters. */ |
| 1090 | * A mode sense command is used to "sense" floppy parameters. | 823 | static void idefloppy_create_mode_sense_cmd(idefloppy_pc_t *pc, u8 page_code, |
| 1091 | */ | 824 | u8 type) |
| 1092 | static void idefloppy_create_mode_sense_cmd (idefloppy_pc_t *pc, u8 page_code, u8 type) | ||
| 1093 | { | 825 | { |
| 1094 | u16 length = sizeof(idefloppy_mode_parameter_header_t); | 826 | u16 length = 8; /* sizeof(Mode Parameter Header) = 8 Bytes */ |
| 1095 | 827 | ||
| 1096 | idefloppy_init_pc(pc); | 828 | idefloppy_init_pc(pc); |
| 1097 | pc->c[0] = IDEFLOPPY_MODE_SENSE_CMD; | 829 | pc->c[0] = GPCMD_MODE_SENSE_10; |
| 1098 | pc->c[1] = 0; | 830 | pc->c[1] = 0; |
| 1099 | pc->c[2] = page_code + (type << 6); | 831 | pc->c[2] = page_code + (type << 6); |
| 1100 | 832 | ||
| 1101 | switch (page_code) { | 833 | switch (page_code) { |
| 1102 | case IDEFLOPPY_CAPABILITIES_PAGE: | 834 | case IDEFLOPPY_CAPABILITIES_PAGE: |
| 1103 | length += 12; | 835 | length += 12; |
| 1104 | break; | 836 | break; |
| 1105 | case IDEFLOPPY_FLEXIBLE_DISK_PAGE: | 837 | case IDEFLOPPY_FLEXIBLE_DISK_PAGE: |
| 1106 | length += 32; | 838 | length += 32; |
| 1107 | break; | 839 | break; |
| 1108 | default: | 840 | default: |
| 1109 | printk(KERN_ERR "ide-floppy: unsupported page code " | 841 | printk(KERN_ERR "ide-floppy: unsupported page code " |
| 1110 | "in create_mode_sense_cmd\n"); | 842 | "in create_mode_sense_cmd\n"); |
| 1111 | } | 843 | } |
| 1112 | put_unaligned(htons(length), (u16 *) &pc->c[7]); | 844 | put_unaligned(cpu_to_be16(length), (u16 *) &pc->c[7]); |
| 1113 | pc->request_transfer = length; | 845 | pc->request_transfer = length; |
| 1114 | } | 846 | } |
| 1115 | 847 | ||
| 1116 | static void idefloppy_create_start_stop_cmd (idefloppy_pc_t *pc, int start) | 848 | static void idefloppy_create_start_stop_cmd(idefloppy_pc_t *pc, int start) |
| 1117 | { | 849 | { |
| 1118 | idefloppy_init_pc(pc); | 850 | idefloppy_init_pc(pc); |
| 1119 | pc->c[0] = IDEFLOPPY_START_STOP_CMD; | 851 | pc->c[0] = GPCMD_START_STOP_UNIT; |
| 1120 | pc->c[4] = start; | 852 | pc->c[4] = start; |
| 1121 | } | 853 | } |
| 1122 | 854 | ||
| 1123 | static void idefloppy_create_test_unit_ready_cmd(idefloppy_pc_t *pc) | 855 | static void idefloppy_create_test_unit_ready_cmd(idefloppy_pc_t *pc) |
| 1124 | { | 856 | { |
| 1125 | idefloppy_init_pc(pc); | 857 | idefloppy_init_pc(pc); |
| 1126 | pc->c[0] = IDEFLOPPY_TEST_UNIT_READY_CMD; | 858 | pc->c[0] = GPCMD_TEST_UNIT_READY; |
| 1127 | } | 859 | } |
| 1128 | 860 | ||
| 1129 | static void idefloppy_create_rw_cmd (idefloppy_floppy_t *floppy, idefloppy_pc_t *pc, struct request *rq, unsigned long sector) | 861 | static void idefloppy_create_rw_cmd(idefloppy_floppy_t *floppy, |
| 862 | idefloppy_pc_t *pc, struct request *rq, | ||
| 863 | unsigned long sector) | ||
| 1130 | { | 864 | { |
| 1131 | int block = sector / floppy->bs_factor; | 865 | int block = sector / floppy->bs_factor; |
| 1132 | int blocks = rq->nr_sectors / floppy->bs_factor; | 866 | int blocks = rq->nr_sectors / floppy->bs_factor; |
| 1133 | int cmd = rq_data_dir(rq); | 867 | int cmd = rq_data_dir(rq); |
| 1134 | 868 | ||
| 1135 | debug_log("create_rw1%d_cmd: block == %d, blocks == %d\n", | 869 | debug_log("create_rw10_cmd: block == %d, blocks == %d\n", |
| 1136 | 2 * test_bit (IDEFLOPPY_USE_READ12, &floppy->flags), | ||
| 1137 | block, blocks); | 870 | block, blocks); |
| 1138 | 871 | ||
| 1139 | idefloppy_init_pc(pc); | 872 | idefloppy_init_pc(pc); |
| 1140 | if (test_bit(IDEFLOPPY_USE_READ12, &floppy->flags)) { | 873 | pc->c[0] = cmd == READ ? GPCMD_READ_10 : GPCMD_WRITE_10; |
| 1141 | pc->c[0] = cmd == READ ? IDEFLOPPY_READ12_CMD : IDEFLOPPY_WRITE12_CMD; | 874 | put_unaligned(cpu_to_be16(blocks), (unsigned short *)&pc->c[7]); |
| 1142 | put_unaligned(htonl(blocks), (unsigned int *) &pc->c[6]); | 875 | put_unaligned(cpu_to_be32(block), (unsigned int *) &pc->c[2]); |
| 1143 | } else { | 876 | |
| 1144 | pc->c[0] = cmd == READ ? IDEFLOPPY_READ10_CMD : IDEFLOPPY_WRITE10_CMD; | ||
| 1145 | put_unaligned(htons(blocks), (unsigned short *) &pc->c[7]); | ||
| 1146 | } | ||
| 1147 | put_unaligned(htonl(block), (unsigned int *) &pc->c[2]); | ||
| 1148 | pc->callback = &idefloppy_rw_callback; | 877 | pc->callback = &idefloppy_rw_callback; |
| 1149 | pc->rq = rq; | 878 | pc->rq = rq; |
| 1150 | pc->b_count = cmd == READ ? 0 : rq->bio->bi_size; | 879 | pc->b_count = cmd == READ ? 0 : rq->bio->bi_size; |
| 1151 | if (rq->cmd_flags & REQ_RW) | 880 | if (rq->cmd_flags & REQ_RW) |
| 1152 | set_bit(PC_WRITING, &pc->flags); | 881 | pc->flags |= PC_FLAG_WRITING; |
| 1153 | pc->buffer = NULL; | 882 | pc->buffer = NULL; |
| 1154 | pc->request_transfer = pc->buffer_size = blocks * floppy->block_size; | 883 | pc->request_transfer = pc->buffer_size = blocks * floppy->block_size; |
| 1155 | set_bit(PC_DMA_RECOMMENDED, &pc->flags); | 884 | pc->flags |= PC_FLAG_DMA_RECOMMENDED; |
| 1156 | } | 885 | } |
| 1157 | 886 | ||
| 1158 | static void | 887 | static void idefloppy_blockpc_cmd(idefloppy_floppy_t *floppy, |
| 1159 | idefloppy_blockpc_cmd(idefloppy_floppy_t *floppy, idefloppy_pc_t *pc, struct request *rq) | 888 | idefloppy_pc_t *pc, struct request *rq) |
| 1160 | { | 889 | { |
| 1161 | idefloppy_init_pc(pc); | 890 | idefloppy_init_pc(pc); |
| 1162 | pc->callback = &idefloppy_rw_callback; | 891 | pc->callback = &idefloppy_rw_callback; |
| @@ -1164,11 +893,10 @@ idefloppy_blockpc_cmd(idefloppy_floppy_t *floppy, idefloppy_pc_t *pc, struct req | |||
| 1164 | pc->rq = rq; | 893 | pc->rq = rq; |
| 1165 | pc->b_count = rq->data_len; | 894 | pc->b_count = rq->data_len; |
| 1166 | if (rq->data_len && rq_data_dir(rq) == WRITE) | 895 | if (rq->data_len && rq_data_dir(rq) == WRITE) |
| 1167 | set_bit(PC_WRITING, &pc->flags); | 896 | pc->flags |= PC_FLAG_WRITING; |
| 1168 | pc->buffer = rq->data; | 897 | pc->buffer = rq->data; |
| 1169 | if (rq->bio) | 898 | if (rq->bio) |
| 1170 | set_bit(PC_DMA_RECOMMENDED, &pc->flags); | 899 | pc->flags |= PC_FLAG_DMA_RECOMMENDED; |
| 1171 | |||
| 1172 | /* | 900 | /* |
| 1173 | * possibly problematic, doesn't look like ide-floppy correctly | 901 | * possibly problematic, doesn't look like ide-floppy correctly |
| 1174 | * handled scattered requests if dma fails... | 902 | * handled scattered requests if dma fails... |
| @@ -1176,30 +904,23 @@ idefloppy_blockpc_cmd(idefloppy_floppy_t *floppy, idefloppy_pc_t *pc, struct req | |||
| 1176 | pc->request_transfer = pc->buffer_size = rq->data_len; | 904 | pc->request_transfer = pc->buffer_size = rq->data_len; |
| 1177 | } | 905 | } |
| 1178 | 906 | ||
| 1179 | /* | 907 | static ide_startstop_t idefloppy_do_request(ide_drive_t *drive, |
| 1180 | * idefloppy_do_request is our request handling function. | 908 | struct request *rq, sector_t block_s) |
| 1181 | */ | ||
| 1182 | static ide_startstop_t idefloppy_do_request (ide_drive_t *drive, struct request *rq, sector_t block_s) | ||
| 1183 | { | 909 | { |
| 1184 | idefloppy_floppy_t *floppy = drive->driver_data; | 910 | idefloppy_floppy_t *floppy = drive->driver_data; |
| 1185 | idefloppy_pc_t *pc; | 911 | idefloppy_pc_t *pc; |
| 1186 | unsigned long block = (unsigned long)block_s; | 912 | unsigned long block = (unsigned long)block_s; |
| 1187 | 913 | ||
| 1188 | debug_log(KERN_INFO "dev: %s, flags: %lx, errors: %d\n", | 914 | debug_log("dev: %s, cmd_type: %x, errors: %d\n", |
| 1189 | rq->rq_disk ? rq->rq_disk->disk_name : "?", | 915 | rq->rq_disk ? rq->rq_disk->disk_name : "?", |
| 1190 | rq->flags, rq->errors); | 916 | rq->cmd_type, rq->errors); |
| 1191 | debug_log(KERN_INFO "sector: %ld, nr_sectors: %ld, " | 917 | debug_log("sector: %ld, nr_sectors: %ld, " |
| 1192 | "current_nr_sectors: %d\n", (long)rq->sector, | 918 | "current_nr_sectors: %d\n", (long)rq->sector, |
| 1193 | rq->nr_sectors, rq->current_nr_sectors); | 919 | rq->nr_sectors, rq->current_nr_sectors); |
| 1194 | 920 | ||
| 1195 | if (rq->errors >= ERROR_MAX) { | 921 | if (rq->errors >= ERROR_MAX) { |
| 1196 | if (floppy->failed_pc != NULL) { | 922 | if (floppy->failed_pc) |
| 1197 | if (idefloppy_should_report_error(floppy)) | 923 | ide_floppy_report_error(floppy, floppy->failed_pc); |
| 1198 | printk(KERN_ERR "ide-floppy: %s: I/O error, pc = %2x," | ||
| 1199 | " key = %2x, asc = %2x, ascq = %2x\n", | ||
| 1200 | drive->name, floppy->failed_pc->c[0], | ||
| 1201 | floppy->sense_key, floppy->asc, floppy->ascq); | ||
| 1202 | } | ||
| 1203 | else | 924 | else |
| 1204 | printk(KERN_ERR "ide-floppy: %s: I/O error\n", | 925 | printk(KERN_ERR "ide-floppy: %s: I/O error\n", |
| 1205 | drive->name); | 926 | drive->name); |
| @@ -1209,8 +930,8 @@ static ide_startstop_t idefloppy_do_request (ide_drive_t *drive, struct request | |||
| 1209 | if (blk_fs_request(rq)) { | 930 | if (blk_fs_request(rq)) { |
| 1210 | if (((long)rq->sector % floppy->bs_factor) || | 931 | if (((long)rq->sector % floppy->bs_factor) || |
| 1211 | (rq->nr_sectors % floppy->bs_factor)) { | 932 | (rq->nr_sectors % floppy->bs_factor)) { |
| 1212 | printk("%s: unsupported r/w request size\n", | 933 | printk(KERN_ERR "%s: unsupported r/w request size\n", |
| 1213 | drive->name); | 934 | drive->name); |
| 1214 | idefloppy_do_end_request(drive, 0, 0); | 935 | idefloppy_do_end_request(drive, 0, 0); |
| 1215 | return ide_stopped; | 936 | return ide_stopped; |
| 1216 | } | 937 | } |
| @@ -1233,15 +954,15 @@ static ide_startstop_t idefloppy_do_request (ide_drive_t *drive, struct request | |||
| 1233 | } | 954 | } |
| 1234 | 955 | ||
| 1235 | /* | 956 | /* |
| 1236 | * idefloppy_queue_pc_tail adds a special packet command request to the | 957 | * Add a special packet command request to the tail of the request queue, |
| 1237 | * tail of the request queue, and waits for it to be serviced. | 958 | * and wait for it to be serviced. |
| 1238 | */ | 959 | */ |
| 1239 | static int idefloppy_queue_pc_tail (ide_drive_t *drive,idefloppy_pc_t *pc) | 960 | static int idefloppy_queue_pc_tail(ide_drive_t *drive, idefloppy_pc_t *pc) |
| 1240 | { | 961 | { |
| 1241 | struct ide_floppy_obj *floppy = drive->driver_data; | 962 | struct ide_floppy_obj *floppy = drive->driver_data; |
| 1242 | struct request rq; | 963 | struct request rq; |
| 1243 | 964 | ||
| 1244 | ide_init_drive_cmd (&rq); | 965 | ide_init_drive_cmd(&rq); |
| 1245 | rq.buffer = (char *) pc; | 966 | rq.buffer = (char *) pc; |
| 1246 | rq.cmd_type = REQ_TYPE_SPECIAL; | 967 | rq.cmd_type = REQ_TYPE_SPECIAL; |
| 1247 | rq.rq_disk = floppy->disk; | 968 | rq.rq_disk = floppy->disk; |
| @@ -1250,88 +971,90 @@ static int idefloppy_queue_pc_tail (ide_drive_t *drive,idefloppy_pc_t *pc) | |||
| 1250 | } | 971 | } |
| 1251 | 972 | ||
| 1252 | /* | 973 | /* |
| 1253 | * Look at the flexible disk page parameters. We will ignore the CHS | 974 | * Look at the flexible disk page parameters. We ignore the CHS capacity |
| 1254 | * capacity parameters and use the LBA parameters instead. | 975 | * parameters and use the LBA parameters instead. |
| 1255 | */ | 976 | */ |
| 1256 | static int idefloppy_get_flexible_disk_page (ide_drive_t *drive) | 977 | static int ide_floppy_get_flexible_disk_page(ide_drive_t *drive) |
| 1257 | { | 978 | { |
| 1258 | idefloppy_floppy_t *floppy = drive->driver_data; | 979 | idefloppy_floppy_t *floppy = drive->driver_data; |
| 1259 | idefloppy_pc_t pc; | 980 | idefloppy_pc_t pc; |
| 1260 | idefloppy_mode_parameter_header_t *header; | 981 | u8 *page; |
| 1261 | idefloppy_flexible_disk_page_t *page; | ||
| 1262 | int capacity, lba_capacity; | 982 | int capacity, lba_capacity; |
| 983 | u16 transfer_rate, sector_size, cyls, rpm; | ||
| 984 | u8 heads, sectors; | ||
| 985 | |||
| 986 | idefloppy_create_mode_sense_cmd(&pc, IDEFLOPPY_FLEXIBLE_DISK_PAGE, | ||
| 987 | MODE_SENSE_CURRENT); | ||
| 1263 | 988 | ||
| 1264 | idefloppy_create_mode_sense_cmd(&pc, IDEFLOPPY_FLEXIBLE_DISK_PAGE, MODE_SENSE_CURRENT); | 989 | if (idefloppy_queue_pc_tail(drive, &pc)) { |
| 1265 | if (idefloppy_queue_pc_tail(drive,&pc)) { | 990 | printk(KERN_ERR "ide-floppy: Can't get flexible disk page" |
| 1266 | printk(KERN_ERR "ide-floppy: Can't get flexible disk " | 991 | " parameters\n"); |
| 1267 | "page parameters\n"); | ||
| 1268 | return 1; | 992 | return 1; |
| 1269 | } | 993 | } |
| 1270 | header = (idefloppy_mode_parameter_header_t *) pc.buffer; | 994 | floppy->wp = !!(pc.buffer[3] & 0x80); |
| 1271 | floppy->wp = header->wp; | ||
| 1272 | set_disk_ro(floppy->disk, floppy->wp); | 995 | set_disk_ro(floppy->disk, floppy->wp); |
| 1273 | page = (idefloppy_flexible_disk_page_t *) (header + 1); | 996 | page = &pc.buffer[8]; |
| 1274 | 997 | ||
| 1275 | page->transfer_rate = ntohs(page->transfer_rate); | 998 | transfer_rate = be16_to_cpu(*(u16 *)&pc.buffer[8 + 2]); |
| 1276 | page->sector_size = ntohs(page->sector_size); | 999 | sector_size = be16_to_cpu(*(u16 *)&pc.buffer[8 + 6]); |
| 1277 | page->cyls = ntohs(page->cyls); | 1000 | cyls = be16_to_cpu(*(u16 *)&pc.buffer[8 + 8]); |
| 1278 | page->rpm = ntohs(page->rpm); | 1001 | rpm = be16_to_cpu(*(u16 *)&pc.buffer[8 + 28]); |
| 1279 | capacity = page->cyls * page->heads * page->sectors * page->sector_size; | 1002 | heads = pc.buffer[8 + 4]; |
| 1280 | if (memcmp (page, &floppy->flexible_disk_page, sizeof (idefloppy_flexible_disk_page_t))) | 1003 | sectors = pc.buffer[8 + 5]; |
| 1004 | |||
| 1005 | capacity = cyls * heads * sectors * sector_size; | ||
| 1006 | |||
| 1007 | if (memcmp(page, &floppy->flexible_disk_page, 32)) | ||
| 1281 | printk(KERN_INFO "%s: %dkB, %d/%d/%d CHS, %d kBps, " | 1008 | printk(KERN_INFO "%s: %dkB, %d/%d/%d CHS, %d kBps, " |
| 1282 | "%d sector size, %d rpm\n", | 1009 | "%d sector size, %d rpm\n", |
| 1283 | drive->name, capacity / 1024, page->cyls, | 1010 | drive->name, capacity / 1024, cyls, heads, |
| 1284 | page->heads, page->sectors, | 1011 | sectors, transfer_rate / 8, sector_size, rpm); |
| 1285 | page->transfer_rate / 8, page->sector_size, page->rpm); | 1012 | |
| 1286 | 1013 | memcpy(&floppy->flexible_disk_page, page, 32); | |
| 1287 | floppy->flexible_disk_page = *page; | 1014 | drive->bios_cyl = cyls; |
| 1288 | drive->bios_cyl = page->cyls; | 1015 | drive->bios_head = heads; |
| 1289 | drive->bios_head = page->heads; | 1016 | drive->bios_sect = sectors; |
| 1290 | drive->bios_sect = page->sectors; | ||
| 1291 | lba_capacity = floppy->blocks * floppy->block_size; | 1017 | lba_capacity = floppy->blocks * floppy->block_size; |
| 1018 | |||
| 1292 | if (capacity < lba_capacity) { | 1019 | if (capacity < lba_capacity) { |
| 1293 | printk(KERN_NOTICE "%s: The disk reports a capacity of %d " | 1020 | printk(KERN_NOTICE "%s: The disk reports a capacity of %d " |
| 1294 | "bytes, but the drive only handles %d\n", | 1021 | "bytes, but the drive only handles %d\n", |
| 1295 | drive->name, lba_capacity, capacity); | 1022 | drive->name, lba_capacity, capacity); |
| 1296 | floppy->blocks = floppy->block_size ? capacity / floppy->block_size : 0; | 1023 | floppy->blocks = floppy->block_size ? |
| 1024 | capacity / floppy->block_size : 0; | ||
| 1297 | } | 1025 | } |
| 1298 | return 0; | 1026 | return 0; |
| 1299 | } | 1027 | } |
| 1300 | 1028 | ||
| 1301 | static int idefloppy_get_capability_page(ide_drive_t *drive) | 1029 | static int idefloppy_get_sfrp_bit(ide_drive_t *drive) |
| 1302 | { | 1030 | { |
| 1303 | idefloppy_floppy_t *floppy = drive->driver_data; | 1031 | idefloppy_floppy_t *floppy = drive->driver_data; |
| 1304 | idefloppy_pc_t pc; | 1032 | idefloppy_pc_t pc; |
| 1305 | idefloppy_mode_parameter_header_t *header; | ||
| 1306 | idefloppy_capabilities_page_t *page; | ||
| 1307 | 1033 | ||
| 1308 | floppy->srfp = 0; | 1034 | floppy->srfp = 0; |
| 1309 | idefloppy_create_mode_sense_cmd(&pc, IDEFLOPPY_CAPABILITIES_PAGE, | 1035 | idefloppy_create_mode_sense_cmd(&pc, IDEFLOPPY_CAPABILITIES_PAGE, |
| 1310 | MODE_SENSE_CURRENT); | 1036 | MODE_SENSE_CURRENT); |
| 1311 | 1037 | ||
| 1312 | set_bit(PC_SUPPRESS_ERROR, &pc.flags); | 1038 | pc.flags |= PC_FLAG_SUPPRESS_ERROR; |
| 1313 | if (idefloppy_queue_pc_tail(drive,&pc)) { | 1039 | if (idefloppy_queue_pc_tail(drive, &pc)) |
| 1314 | return 1; | 1040 | return 1; |
| 1315 | } | ||
| 1316 | 1041 | ||
| 1317 | header = (idefloppy_mode_parameter_header_t *) pc.buffer; | 1042 | floppy->srfp = pc.buffer[8 + 2] & 0x40; |
| 1318 | page= (idefloppy_capabilities_page_t *)(header+1); | ||
| 1319 | floppy->srfp = page->srfp; | ||
| 1320 | return (0); | 1043 | return (0); |
| 1321 | } | 1044 | } |
| 1322 | 1045 | ||
| 1323 | /* | 1046 | /* |
| 1324 | * Determine if a media is present in the floppy drive, and if so, | 1047 | * Determine if a media is present in the floppy drive, and if so, its LBA |
| 1325 | * its LBA capacity. | 1048 | * capacity. |
| 1326 | */ | 1049 | */ |
| 1327 | static int idefloppy_get_capacity (ide_drive_t *drive) | 1050 | static int ide_floppy_get_capacity(ide_drive_t *drive) |
| 1328 | { | 1051 | { |
| 1329 | idefloppy_floppy_t *floppy = drive->driver_data; | 1052 | idefloppy_floppy_t *floppy = drive->driver_data; |
| 1330 | idefloppy_pc_t pc; | 1053 | idefloppy_pc_t pc; |
| 1331 | idefloppy_capacity_header_t *header; | 1054 | u8 *cap_desc; |
| 1332 | idefloppy_capacity_descriptor_t *descriptor; | 1055 | u8 header_len, desc_cnt; |
| 1333 | int i, descriptors, rc = 1, blocks, length; | 1056 | int i, rc = 1, blocks, length; |
| 1334 | 1057 | ||
| 1335 | drive->bios_cyl = 0; | 1058 | drive->bios_cyl = 0; |
| 1336 | drive->bios_head = drive->bios_sect = 0; | 1059 | drive->bios_head = drive->bios_sect = 0; |
| 1337 | floppy->blocks = 0; | 1060 | floppy->blocks = 0; |
| @@ -1343,44 +1066,55 @@ static int idefloppy_get_capacity (ide_drive_t *drive) | |||
| 1343 | printk(KERN_ERR "ide-floppy: Can't get floppy parameters\n"); | 1066 | printk(KERN_ERR "ide-floppy: Can't get floppy parameters\n"); |
| 1344 | return 1; | 1067 | return 1; |
| 1345 | } | 1068 | } |
| 1346 | header = (idefloppy_capacity_header_t *) pc.buffer; | 1069 | header_len = pc.buffer[3]; |
| 1347 | descriptors = header->length / sizeof(idefloppy_capacity_descriptor_t); | 1070 | cap_desc = &pc.buffer[4]; |
| 1348 | descriptor = (idefloppy_capacity_descriptor_t *) (header + 1); | 1071 | desc_cnt = header_len / 8; /* capacity descriptor of 8 bytes */ |
| 1072 | |||
| 1073 | for (i = 0; i < desc_cnt; i++) { | ||
| 1074 | unsigned int desc_start = 4 + i*8; | ||
| 1075 | |||
| 1076 | blocks = be32_to_cpu(*(u32 *)&pc.buffer[desc_start]); | ||
| 1077 | length = be16_to_cpu(*(u16 *)&pc.buffer[desc_start + 6]); | ||
| 1349 | 1078 | ||
| 1350 | for (i = 0; i < descriptors; i++, descriptor++) { | 1079 | debug_log("Descriptor %d: %dkB, %d blocks, %d sector size\n", |
| 1351 | blocks = descriptor->blocks = ntohl(descriptor->blocks); | 1080 | i, blocks * length / 1024, blocks, length); |
| 1352 | length = descriptor->length = ntohs(descriptor->length); | ||
| 1353 | 1081 | ||
| 1354 | if (!i) | 1082 | if (i) |
| 1355 | { | 1083 | continue; |
| 1356 | switch (descriptor->dc) { | 1084 | /* |
| 1085 | * the code below is valid only for the 1st descriptor, ie i=0 | ||
| 1086 | */ | ||
| 1087 | |||
| 1088 | switch (pc.buffer[desc_start + 4] & 0x03) { | ||
| 1357 | /* Clik! drive returns this instead of CAPACITY_CURRENT */ | 1089 | /* Clik! drive returns this instead of CAPACITY_CURRENT */ |
| 1358 | case CAPACITY_UNFORMATTED: | 1090 | case CAPACITY_UNFORMATTED: |
| 1359 | if (!test_bit(IDEFLOPPY_CLIK_DRIVE, &floppy->flags)) | 1091 | if (!(floppy->flags & IDEFLOPPY_FLAG_CLIK_DRIVE)) |
| 1360 | /* | 1092 | /* |
| 1361 | * If it is not a clik drive, break out | 1093 | * If it is not a clik drive, break out |
| 1362 | * (maintains previous driver behaviour) | 1094 | * (maintains previous driver behaviour) |
| 1363 | */ | 1095 | */ |
| 1364 | break; | 1096 | break; |
| 1365 | case CAPACITY_CURRENT: | 1097 | case CAPACITY_CURRENT: |
| 1366 | /* Normal Zip/LS-120 disks */ | 1098 | /* Normal Zip/LS-120 disks */ |
| 1367 | if (memcmp(descriptor, &floppy->capacity, sizeof (idefloppy_capacity_descriptor_t))) | 1099 | if (memcmp(cap_desc, &floppy->cap_desc, 8)) |
| 1368 | printk(KERN_INFO "%s: %dkB, %d blocks, %d " | 1100 | printk(KERN_INFO "%s: %dkB, %d blocks, %d " |
| 1369 | "sector size\n", drive->name, | 1101 | "sector size\n", drive->name, |
| 1370 | blocks * length / 1024, blocks, length); | 1102 | blocks * length / 1024, blocks, length); |
| 1371 | floppy->capacity = *descriptor; | 1103 | memcpy(&floppy->cap_desc, cap_desc, 8); |
| 1104 | |||
| 1372 | if (!length || length % 512) { | 1105 | if (!length || length % 512) { |
| 1373 | printk(KERN_NOTICE "%s: %d bytes block size " | 1106 | printk(KERN_NOTICE "%s: %d bytes block size " |
| 1374 | "not supported\n", drive->name, length); | 1107 | "not supported\n", drive->name, length); |
| 1375 | } else { | 1108 | } else { |
| 1376 | floppy->blocks = blocks; | 1109 | floppy->blocks = blocks; |
| 1377 | floppy->block_size = length; | 1110 | floppy->block_size = length; |
| 1378 | if ((floppy->bs_factor = length / 512) != 1) | 1111 | floppy->bs_factor = length / 512; |
| 1379 | printk(KERN_NOTICE "%s: warning: non " | 1112 | if (floppy->bs_factor != 1) |
| 1113 | printk(KERN_NOTICE "%s: warning: non " | ||
| 1380 | "512 bytes block size not " | 1114 | "512 bytes block size not " |
| 1381 | "fully supported\n", | 1115 | "fully supported\n", |
| 1382 | drive->name); | 1116 | drive->name); |
| 1383 | rc = 0; | 1117 | rc = 0; |
| 1384 | } | 1118 | } |
| 1385 | break; | 1119 | break; |
| 1386 | case CAPACITY_NO_CARTRIDGE: | 1120 | case CAPACITY_NO_CARTRIDGE: |
| @@ -1395,54 +1129,42 @@ static int idefloppy_get_capacity (ide_drive_t *drive) | |||
| 1395 | "in drive\n", drive->name); | 1129 | "in drive\n", drive->name); |
| 1396 | break; | 1130 | break; |
| 1397 | } | 1131 | } |
| 1398 | } | 1132 | debug_log("Descriptor 0 Code: %d\n", |
| 1399 | if (!i) { | 1133 | pc.buffer[desc_start + 4] & 0x03); |
| 1400 | debug_log( "Descriptor 0 Code: %d\n", | ||
| 1401 | descriptor->dc); | ||
| 1402 | } | ||
| 1403 | debug_log( "Descriptor %d: %dkB, %d blocks, %d " | ||
| 1404 | "sector size\n", i, blocks * length / 1024, blocks, | ||
| 1405 | length); | ||
| 1406 | } | 1134 | } |
| 1407 | 1135 | ||
| 1408 | /* Clik! disk does not support get_flexible_disk_page */ | 1136 | /* Clik! disk does not support get_flexible_disk_page */ |
| 1409 | if (!test_bit(IDEFLOPPY_CLIK_DRIVE, &floppy->flags)) { | 1137 | if (!(floppy->flags & IDEFLOPPY_FLAG_CLIK_DRIVE)) |
| 1410 | (void) idefloppy_get_flexible_disk_page(drive); | 1138 | (void) ide_floppy_get_flexible_disk_page(drive); |
| 1411 | } | ||
| 1412 | 1139 | ||
| 1413 | set_capacity(floppy->disk, floppy->blocks * floppy->bs_factor); | 1140 | set_capacity(floppy->disk, floppy->blocks * floppy->bs_factor); |
| 1414 | return rc; | 1141 | return rc; |
| 1415 | } | 1142 | } |
| 1416 | 1143 | ||
| 1417 | /* | 1144 | /* |
| 1418 | ** Obtain the list of formattable capacities. | 1145 | * Obtain the list of formattable capacities. |
| 1419 | ** Very similar to idefloppy_get_capacity, except that we push the capacity | 1146 | * Very similar to ide_floppy_get_capacity, except that we push the capacity |
| 1420 | ** descriptors to userland, instead of our own structures. | 1147 | * descriptors to userland, instead of our own structures. |
| 1421 | ** | 1148 | * |
| 1422 | ** Userland gives us the following structure: | 1149 | * Userland gives us the following structure: |
| 1423 | ** | 1150 | * |
| 1424 | ** struct idefloppy_format_capacities { | 1151 | * struct idefloppy_format_capacities { |
| 1425 | ** int nformats; | 1152 | * int nformats; |
| 1426 | ** struct { | 1153 | * struct { |
| 1427 | ** int nblocks; | 1154 | * int nblocks; |
| 1428 | ** int blocksize; | 1155 | * int blocksize; |
| 1429 | ** } formats[]; | 1156 | * } formats[]; |
| 1430 | ** } ; | 1157 | * }; |
| 1431 | ** | 1158 | * |
| 1432 | ** userland initializes nformats to the number of allocated formats[] | 1159 | * userland initializes nformats to the number of allocated formats[] records. |
| 1433 | ** records. On exit we set nformats to the number of records we've | 1160 | * On exit we set nformats to the number of records we've actually initialized. |
| 1434 | ** actually initialized. | 1161 | */ |
| 1435 | ** | 1162 | |
| 1436 | */ | 1163 | static int ide_floppy_get_format_capacities(ide_drive_t *drive, int __user *arg) |
| 1437 | |||
| 1438 | static int idefloppy_get_format_capacities(ide_drive_t *drive, int __user *arg) | ||
| 1439 | { | 1164 | { |
| 1440 | idefloppy_pc_t pc; | 1165 | idefloppy_pc_t pc; |
| 1441 | idefloppy_capacity_header_t *header; | 1166 | u8 header_len, desc_cnt; |
| 1442 | idefloppy_capacity_descriptor_t *descriptor; | 1167 | int i, blocks, length, u_array_size, u_index; |
| 1443 | int i, descriptors, blocks, length; | ||
| 1444 | int u_array_size; | ||
| 1445 | int u_index; | ||
| 1446 | int __user *argp; | 1168 | int __user *argp; |
| 1447 | 1169 | ||
| 1448 | if (get_user(u_array_size, arg)) | 1170 | if (get_user(u_array_size, arg)) |
| @@ -1454,30 +1176,27 @@ static int idefloppy_get_format_capacities(ide_drive_t *drive, int __user *arg) | |||
| 1454 | idefloppy_create_read_capacity_cmd(&pc); | 1176 | idefloppy_create_read_capacity_cmd(&pc); |
| 1455 | if (idefloppy_queue_pc_tail(drive, &pc)) { | 1177 | if (idefloppy_queue_pc_tail(drive, &pc)) { |
| 1456 | printk(KERN_ERR "ide-floppy: Can't get floppy parameters\n"); | 1178 | printk(KERN_ERR "ide-floppy: Can't get floppy parameters\n"); |
| 1457 | return (-EIO); | 1179 | return (-EIO); |
| 1458 | } | 1180 | } |
| 1459 | header = (idefloppy_capacity_header_t *) pc.buffer; | 1181 | header_len = pc.buffer[3]; |
| 1460 | descriptors = header->length / | 1182 | desc_cnt = header_len / 8; /* capacity descriptor of 8 bytes */ |
| 1461 | sizeof(idefloppy_capacity_descriptor_t); | ||
| 1462 | descriptor = (idefloppy_capacity_descriptor_t *) (header + 1); | ||
| 1463 | 1183 | ||
| 1464 | u_index = 0; | 1184 | u_index = 0; |
| 1465 | argp = arg + 1; | 1185 | argp = arg + 1; |
| 1466 | 1186 | ||
| 1467 | /* | 1187 | /* |
| 1468 | ** We always skip the first capacity descriptor. That's the | 1188 | * We always skip the first capacity descriptor. That's the current |
| 1469 | ** current capacity. We are interested in the remaining descriptors, | 1189 | * capacity. We are interested in the remaining descriptors, the |
| 1470 | ** the formattable capacities. | 1190 | * formattable capacities. |
| 1471 | */ | 1191 | */ |
| 1192 | for (i = 1; i < desc_cnt; i++) { | ||
| 1193 | unsigned int desc_start = 4 + i*8; | ||
| 1472 | 1194 | ||
| 1473 | for (i=0; i<descriptors; i++, descriptor++) { | ||
| 1474 | if (u_index >= u_array_size) | 1195 | if (u_index >= u_array_size) |
| 1475 | break; /* User-supplied buffer too small */ | 1196 | break; /* User-supplied buffer too small */ |
| 1476 | if (i == 0) | ||
| 1477 | continue; /* Skip the first descriptor */ | ||
| 1478 | 1197 | ||
| 1479 | blocks = ntohl(descriptor->blocks); | 1198 | blocks = be32_to_cpu(*(u32 *)&pc.buffer[desc_start]); |
| 1480 | length = ntohs(descriptor->length); | 1199 | length = be16_to_cpu(*(u16 *)&pc.buffer[desc_start + 6]); |
| 1481 | 1200 | ||
| 1482 | if (put_user(blocks, argp)) | 1201 | if (put_user(blocks, argp)) |
| 1483 | return(-EFAULT); | 1202 | return(-EFAULT); |
| @@ -1496,53 +1215,14 @@ static int idefloppy_get_format_capacities(ide_drive_t *drive, int __user *arg) | |||
| 1496 | } | 1215 | } |
| 1497 | 1216 | ||
| 1498 | /* | 1217 | /* |
| 1499 | ** Send ATAPI_FORMAT_UNIT to the drive. | 1218 | * Get ATAPI_FORMAT_UNIT progress indication. |
| 1500 | ** | 1219 | * |
| 1501 | ** Userland gives us the following structure: | 1220 | * Userland gives a pointer to an int. The int is set to a progress |
| 1502 | ** | 1221 | * indicator 0-65536, with 65536=100%. |
| 1503 | ** struct idefloppy_format_command { | 1222 | * |
| 1504 | ** int nblocks; | 1223 | * If the drive does not support format progress indication, we just check |
| 1505 | ** int blocksize; | 1224 | * the dsc bit, and return either 0 or 65536. |
| 1506 | ** int flags; | 1225 | */ |
| 1507 | ** } ; | ||
| 1508 | ** | ||
| 1509 | ** flags is a bitmask, currently, the only defined flag is: | ||
| 1510 | ** | ||
| 1511 | ** 0x01 - verify media after format. | ||
| 1512 | */ | ||
| 1513 | |||
| 1514 | static int idefloppy_begin_format(ide_drive_t *drive, int __user *arg) | ||
| 1515 | { | ||
| 1516 | int blocks; | ||
| 1517 | int length; | ||
| 1518 | int flags; | ||
| 1519 | idefloppy_pc_t pc; | ||
| 1520 | |||
| 1521 | if (get_user(blocks, arg) || | ||
| 1522 | get_user(length, arg+1) || | ||
| 1523 | get_user(flags, arg+2)) { | ||
| 1524 | return (-EFAULT); | ||
| 1525 | } | ||
| 1526 | |||
| 1527 | /* Get the SFRP bit */ | ||
| 1528 | (void) idefloppy_get_capability_page(drive); | ||
| 1529 | idefloppy_create_format_unit_cmd(&pc, blocks, length, flags); | ||
| 1530 | if (idefloppy_queue_pc_tail(drive, &pc)) { | ||
| 1531 | return (-EIO); | ||
| 1532 | } | ||
| 1533 | |||
| 1534 | return (0); | ||
| 1535 | } | ||
| 1536 | |||
| 1537 | /* | ||
| 1538 | ** Get ATAPI_FORMAT_UNIT progress indication. | ||
| 1539 | ** | ||
| 1540 | ** Userland gives a pointer to an int. The int is set to a progress | ||
| 1541 | ** indicator 0-65536, with 65536=100%. | ||
| 1542 | ** | ||
| 1543 | ** If the drive does not support format progress indication, we just check | ||
| 1544 | ** the dsc bit, and return either 0 or 65536. | ||
| 1545 | */ | ||
| 1546 | 1226 | ||
| 1547 | static int idefloppy_get_format_progress(ide_drive_t *drive, int __user *arg) | 1227 | static int idefloppy_get_format_progress(ide_drive_t *drive, int __user *arg) |
| 1548 | { | 1228 | { |
| @@ -1552,17 +1232,15 @@ static int idefloppy_get_format_progress(ide_drive_t *drive, int __user *arg) | |||
| 1552 | 1232 | ||
| 1553 | if (floppy->srfp) { | 1233 | if (floppy->srfp) { |
| 1554 | idefloppy_create_request_sense_cmd(&pc); | 1234 | idefloppy_create_request_sense_cmd(&pc); |
| 1555 | if (idefloppy_queue_pc_tail(drive, &pc)) { | 1235 | if (idefloppy_queue_pc_tail(drive, &pc)) |
| 1556 | return (-EIO); | 1236 | return (-EIO); |
| 1557 | } | ||
| 1558 | 1237 | ||
| 1559 | if (floppy->sense_key == 2 && | 1238 | if (floppy->sense_key == 2 && |
| 1560 | floppy->asc == 4 && | 1239 | floppy->asc == 4 && |
| 1561 | floppy->ascq == 4) { | 1240 | floppy->ascq == 4) |
| 1562 | progress_indication = floppy->progress_indication; | 1241 | progress_indication = floppy->progress_indication; |
| 1563 | } | 1242 | |
| 1564 | /* Else assume format_unit has finished, and we're | 1243 | /* Else assume format_unit has finished, and we're at 0x10000 */ |
| 1565 | ** at 0x10000 */ | ||
| 1566 | } else { | 1244 | } else { |
| 1567 | unsigned long flags; | 1245 | unsigned long flags; |
| 1568 | u8 stat; | 1246 | u8 stat; |
| @@ -1579,10 +1257,7 @@ static int idefloppy_get_format_progress(ide_drive_t *drive, int __user *arg) | |||
| 1579 | return (0); | 1257 | return (0); |
| 1580 | } | 1258 | } |
| 1581 | 1259 | ||
| 1582 | /* | 1260 | static sector_t idefloppy_capacity(ide_drive_t *drive) |
| 1583 | * Return the current floppy capacity. | ||
| 1584 | */ | ||
| 1585 | static sector_t idefloppy_capacity (ide_drive_t *drive) | ||
| 1586 | { | 1261 | { |
| 1587 | idefloppy_floppy_t *floppy = drive->driver_data; | 1262 | idefloppy_floppy_t *floppy = drive->driver_data; |
| 1588 | unsigned long capacity = floppy->blocks * floppy->bs_factor; | 1263 | unsigned long capacity = floppy->blocks * floppy->bs_factor; |
| @@ -1591,15 +1266,12 @@ static sector_t idefloppy_capacity (ide_drive_t *drive) | |||
| 1591 | } | 1266 | } |
| 1592 | 1267 | ||
| 1593 | /* | 1268 | /* |
| 1594 | * idefloppy_identify_device checks if we can support a drive, | 1269 | * Check whether we can support a drive, based on the ATAPI IDENTIFY command |
| 1595 | * based on the ATAPI IDENTIFY command results. | 1270 | * results. |
| 1596 | */ | 1271 | */ |
| 1597 | static int idefloppy_identify_device (ide_drive_t *drive,struct hd_driveid *id) | 1272 | static int idefloppy_identify_device(ide_drive_t *drive, struct hd_driveid *id) |
| 1598 | { | 1273 | { |
| 1599 | struct idefloppy_id_gcw gcw; | 1274 | struct idefloppy_id_gcw gcw; |
| 1600 | #if IDEFLOPPY_DEBUG_INFO | ||
| 1601 | char buffer[80]; | ||
| 1602 | #endif /* IDEFLOPPY_DEBUG_INFO */ | ||
| 1603 | 1275 | ||
| 1604 | *((u16 *) &gcw) = id->config; | 1276 | *((u16 *) &gcw) = id->config; |
| 1605 | 1277 | ||
| @@ -1608,54 +1280,23 @@ static int idefloppy_identify_device (ide_drive_t *drive,struct hd_driveid *id) | |||
| 1608 | if ((gcw.device_type == 5) && | 1280 | if ((gcw.device_type == 5) && |
| 1609 | !strstr(id->model, "CD-ROM") && | 1281 | !strstr(id->model, "CD-ROM") && |
| 1610 | strstr(id->model, "ZIP")) | 1282 | strstr(id->model, "ZIP")) |
| 1611 | gcw.device_type = 0; | 1283 | gcw.device_type = 0; |
| 1612 | #endif | 1284 | #endif |
| 1613 | 1285 | ||
| 1614 | #if IDEFLOPPY_DEBUG_INFO | ||
| 1615 | printk(KERN_INFO "Dumping ATAPI Identify Device floppy parameters\n"); | ||
| 1616 | switch (gcw.protocol) { | ||
| 1617 | case 0: case 1: sprintf(buffer, "ATA");break; | ||
| 1618 | case 2: sprintf(buffer, "ATAPI");break; | ||
| 1619 | case 3: sprintf(buffer, "Reserved (Unknown to ide-floppy)");break; | ||
| 1620 | } | ||
| 1621 | printk(KERN_INFO "Protocol Type: %s\n", buffer); | ||
| 1622 | switch (gcw.device_type) { | ||
| 1623 | case 0: sprintf(buffer, "Direct-access Device");break; | ||
| 1624 | case 1: sprintf(buffer, "Streaming Tape Device");break; | ||
| 1625 | case 2: case 3: case 4: sprintf (buffer, "Reserved");break; | ||
| 1626 | case 5: sprintf(buffer, "CD-ROM Device");break; | ||
| 1627 | case 6: sprintf(buffer, "Reserved"); | ||
| 1628 | case 7: sprintf(buffer, "Optical memory Device");break; | ||
| 1629 | case 0x1f: sprintf(buffer, "Unknown or no Device type");break; | ||
| 1630 | default: sprintf(buffer, "Reserved"); | ||
| 1631 | } | ||
| 1632 | printk(KERN_INFO "Device Type: %x - %s\n", gcw.device_type, buffer); | ||
| 1633 | printk(KERN_INFO "Removable: %s\n",gcw.removable ? "Yes":"No"); | ||
| 1634 | switch (gcw.drq_type) { | ||
| 1635 | case 0: sprintf(buffer, "Microprocessor DRQ");break; | ||
| 1636 | case 1: sprintf(buffer, "Interrupt DRQ");break; | ||
| 1637 | case 2: sprintf(buffer, "Accelerated DRQ");break; | ||
| 1638 | case 3: sprintf(buffer, "Reserved");break; | ||
| 1639 | } | ||
| 1640 | printk(KERN_INFO "Command Packet DRQ Type: %s\n", buffer); | ||
| 1641 | switch (gcw.packet_size) { | ||
| 1642 | case 0: sprintf(buffer, "12 bytes");break; | ||
| 1643 | case 1: sprintf(buffer, "16 bytes");break; | ||
| 1644 | default: sprintf(buffer, "Reserved");break; | ||
| 1645 | } | ||
| 1646 | printk(KERN_INFO "Command Packet Size: %s\n", buffer); | ||
| 1647 | #endif /* IDEFLOPPY_DEBUG_INFO */ | ||
| 1648 | |||
| 1649 | if (gcw.protocol != 2) | 1286 | if (gcw.protocol != 2) |
| 1650 | printk(KERN_ERR "ide-floppy: Protocol is not ATAPI\n"); | 1287 | printk(KERN_ERR "ide-floppy: Protocol (0x%02x) is not ATAPI\n", |
| 1288 | gcw.protocol); | ||
| 1651 | else if (gcw.device_type != 0) | 1289 | else if (gcw.device_type != 0) |
| 1652 | printk(KERN_ERR "ide-floppy: Device type is not set to floppy\n"); | 1290 | printk(KERN_ERR "ide-floppy: Device type (0x%02x) is not set " |
| 1291 | "to floppy\n", gcw.device_type); | ||
| 1653 | else if (!gcw.removable) | 1292 | else if (!gcw.removable) |
| 1654 | printk(KERN_ERR "ide-floppy: The removable flag is not set\n"); | 1293 | printk(KERN_ERR "ide-floppy: The removable flag is not set\n"); |
| 1655 | else if (gcw.drq_type == 3) { | 1294 | else if (gcw.drq_type == 3) { |
| 1656 | printk(KERN_ERR "ide-floppy: Sorry, DRQ type %d not supported\n", gcw.drq_type); | 1295 | printk(KERN_ERR "ide-floppy: Sorry, DRQ type (0x%02x) not " |
| 1296 | "supported\n", gcw.drq_type); | ||
| 1657 | } else if (gcw.packet_size != 0) { | 1297 | } else if (gcw.packet_size != 0) { |
| 1658 | printk(KERN_ERR "ide-floppy: Packet size is not 12 bytes long\n"); | 1298 | printk(KERN_ERR "ide-floppy: Packet size (0x%02x) is not 12 " |
| 1299 | "bytes long\n", gcw.packet_size); | ||
| 1659 | } else | 1300 | } else |
| 1660 | return 1; | 1301 | return 1; |
| 1661 | return 0; | 1302 | return 0; |
| @@ -1666,59 +1307,53 @@ static void idefloppy_add_settings(ide_drive_t *drive) | |||
| 1666 | { | 1307 | { |
| 1667 | idefloppy_floppy_t *floppy = drive->driver_data; | 1308 | idefloppy_floppy_t *floppy = drive->driver_data; |
| 1668 | 1309 | ||
| 1669 | /* | 1310 | ide_add_setting(drive, "bios_cyl", SETTING_RW, TYPE_INT, 0, 1023, 1, 1, |
| 1670 | * drive setting name read/write data type min max mul_factor div_factor data pointer set function | 1311 | &drive->bios_cyl, NULL); |
| 1671 | */ | 1312 | ide_add_setting(drive, "bios_head", SETTING_RW, TYPE_BYTE, 0, 255, 1, 1, |
| 1672 | ide_add_setting(drive, "bios_cyl", SETTING_RW, TYPE_INT, 0, 1023, 1, 1, &drive->bios_cyl, NULL); | 1313 | &drive->bios_head, NULL); |
| 1673 | ide_add_setting(drive, "bios_head", SETTING_RW, TYPE_BYTE, 0, 255, 1, 1, &drive->bios_head, NULL); | 1314 | ide_add_setting(drive, "bios_sect", SETTING_RW, TYPE_BYTE, 0, 63, 1, 1, |
| 1674 | ide_add_setting(drive, "bios_sect", SETTING_RW, TYPE_BYTE, 0, 63, 1, 1, &drive->bios_sect, NULL); | 1315 | &drive->bios_sect, NULL); |
| 1675 | ide_add_setting(drive, "ticks", SETTING_RW, TYPE_BYTE, 0, 255, 1, 1, &floppy->ticks, NULL); | 1316 | ide_add_setting(drive, "ticks", SETTING_RW, TYPE_BYTE, 0, 255, 1, 1, |
| 1317 | &floppy->ticks, NULL); | ||
| 1676 | } | 1318 | } |
| 1677 | #else | 1319 | #else |
| 1678 | static inline void idefloppy_add_settings(ide_drive_t *drive) { ; } | 1320 | static inline void idefloppy_add_settings(ide_drive_t *drive) { ; } |
| 1679 | #endif | 1321 | #endif |
| 1680 | 1322 | ||
| 1681 | /* | 1323 | static void idefloppy_setup(ide_drive_t *drive, idefloppy_floppy_t *floppy) |
| 1682 | * Driver initialization. | ||
| 1683 | */ | ||
| 1684 | static void idefloppy_setup (ide_drive_t *drive, idefloppy_floppy_t *floppy) | ||
| 1685 | { | 1324 | { |
| 1686 | struct idefloppy_id_gcw gcw; | 1325 | struct idefloppy_id_gcw gcw; |
| 1687 | 1326 | ||
| 1688 | *((u16 *) &gcw) = drive->id->config; | 1327 | *((u16 *) &gcw) = drive->id->config; |
| 1689 | floppy->pc = floppy->pc_stack; | 1328 | floppy->pc = floppy->pc_stack; |
| 1690 | if (gcw.drq_type == 1) | 1329 | if (gcw.drq_type == 1) |
| 1691 | set_bit(IDEFLOPPY_DRQ_INTERRUPT, &floppy->flags); | 1330 | floppy->flags |= IDEFLOPPY_FLAG_DRQ_INTERRUPT; |
| 1692 | /* | 1331 | /* |
| 1693 | * We used to check revisions here. At this point however | 1332 | * We used to check revisions here. At this point however I'm giving up. |
| 1694 | * I'm giving up. Just assume they are all broken, its easier. | 1333 | * Just assume they are all broken, its easier. |
| 1695 | * | 1334 | * |
| 1696 | * The actual reason for the workarounds was likely | 1335 | * The actual reason for the workarounds was likely a driver bug after |
| 1697 | * a driver bug after all rather than a firmware bug, | 1336 | * all rather than a firmware bug, and the workaround below used to hide |
| 1698 | * and the workaround below used to hide it. It should | 1337 | * it. It should be fixed as of version 1.9, but to be on the safe side |
| 1699 | * be fixed as of version 1.9, but to be on the safe side | 1338 | * we'll leave the limitation below for the 2.2.x tree. |
| 1700 | * we'll leave the limitation below for the 2.2.x tree. | ||
| 1701 | */ | 1339 | */ |
| 1702 | |||
| 1703 | if (!strncmp(drive->id->model, "IOMEGA ZIP 100 ATAPI", 20)) { | 1340 | if (!strncmp(drive->id->model, "IOMEGA ZIP 100 ATAPI", 20)) { |
| 1704 | set_bit(IDEFLOPPY_ZIP_DRIVE, &floppy->flags); | 1341 | floppy->flags |= IDEFLOPPY_FLAG_ZIP_DRIVE; |
| 1705 | /* This value will be visible in the /proc/ide/hdx/settings */ | 1342 | /* This value will be visible in the /proc/ide/hdx/settings */ |
| 1706 | floppy->ticks = IDEFLOPPY_TICKS_DELAY; | 1343 | floppy->ticks = IDEFLOPPY_TICKS_DELAY; |
| 1707 | blk_queue_max_sectors(drive->queue, 64); | 1344 | blk_queue_max_sectors(drive->queue, 64); |
| 1708 | } | 1345 | } |
| 1709 | 1346 | ||
| 1710 | /* | 1347 | /* |
| 1711 | * Guess what? The IOMEGA Clik! drive also needs the | 1348 | * Guess what? The IOMEGA Clik! drive also needs the above fix. It makes |
| 1712 | * above fix. It makes nasty clicking noises without | 1349 | * nasty clicking noises without it, so please don't remove this. |
| 1713 | * it, so please don't remove this. | 1350 | */ |
| 1714 | */ | ||
| 1715 | if (strncmp(drive->id->model, "IOMEGA Clik!", 11) == 0) { | 1351 | if (strncmp(drive->id->model, "IOMEGA Clik!", 11) == 0) { |
| 1716 | blk_queue_max_sectors(drive->queue, 64); | 1352 | blk_queue_max_sectors(drive->queue, 64); |
| 1717 | set_bit(IDEFLOPPY_CLIK_DRIVE, &floppy->flags); | 1353 | floppy->flags |= IDEFLOPPY_FLAG_CLIK_DRIVE; |
| 1718 | } | 1354 | } |
| 1719 | 1355 | ||
| 1720 | 1356 | (void) ide_floppy_get_capacity(drive); | |
| 1721 | (void) idefloppy_get_capacity(drive); | ||
| 1722 | idefloppy_add_settings(drive); | 1357 | idefloppy_add_settings(drive); |
| 1723 | } | 1358 | } |
| 1724 | 1359 | ||
| @@ -1734,7 +1369,7 @@ static void ide_floppy_remove(ide_drive_t *drive) | |||
| 1734 | ide_floppy_put(floppy); | 1369 | ide_floppy_put(floppy); |
| 1735 | } | 1370 | } |
| 1736 | 1371 | ||
| 1737 | static void ide_floppy_release(struct kref *kref) | 1372 | static void idefloppy_cleanup_obj(struct kref *kref) |
| 1738 | { | 1373 | { |
| 1739 | struct ide_floppy_obj *floppy = to_ide_floppy(kref); | 1374 | struct ide_floppy_obj *floppy = to_ide_floppy(kref); |
| 1740 | ide_drive_t *drive = floppy->drive; | 1375 | ide_drive_t *drive = floppy->drive; |
| @@ -1747,19 +1382,19 @@ static void ide_floppy_release(struct kref *kref) | |||
| 1747 | } | 1382 | } |
| 1748 | 1383 | ||
| 1749 | #ifdef CONFIG_IDE_PROC_FS | 1384 | #ifdef CONFIG_IDE_PROC_FS |
| 1750 | static int proc_idefloppy_read_capacity | 1385 | static int proc_idefloppy_read_capacity(char *page, char **start, off_t off, |
| 1751 | (char *page, char **start, off_t off, int count, int *eof, void *data) | 1386 | int count, int *eof, void *data) |
| 1752 | { | 1387 | { |
| 1753 | ide_drive_t*drive = (ide_drive_t *)data; | 1388 | ide_drive_t*drive = (ide_drive_t *)data; |
| 1754 | int len; | 1389 | int len; |
| 1755 | 1390 | ||
| 1756 | len = sprintf(page,"%llu\n", (long long)idefloppy_capacity(drive)); | 1391 | len = sprintf(page, "%llu\n", (long long)idefloppy_capacity(drive)); |
| 1757 | PROC_IDE_READ_RETURN(page,start,off,count,eof,len); | 1392 | PROC_IDE_READ_RETURN(page, start, off, count, eof, len); |
| 1758 | } | 1393 | } |
| 1759 | 1394 | ||
| 1760 | static ide_proc_entry_t idefloppy_proc[] = { | 1395 | static ide_proc_entry_t idefloppy_proc[] = { |
| 1761 | { "capacity", S_IFREG|S_IRUGO, proc_idefloppy_read_capacity, NULL }, | 1396 | { "capacity", S_IFREG|S_IRUGO, proc_idefloppy_read_capacity, NULL }, |
| 1762 | { "geometry", S_IFREG|S_IRUGO, proc_ide_read_geometry, NULL }, | 1397 | { "geometry", S_IFREG|S_IRUGO, proc_ide_read_geometry, NULL }, |
| 1763 | { NULL, 0, NULL, NULL } | 1398 | { NULL, 0, NULL, NULL } |
| 1764 | }; | 1399 | }; |
| 1765 | #endif /* CONFIG_IDE_PROC_FS */ | 1400 | #endif /* CONFIG_IDE_PROC_FS */ |
| @@ -1794,9 +1429,10 @@ static int idefloppy_open(struct inode *inode, struct file *filp) | |||
| 1794 | idefloppy_pc_t pc; | 1429 | idefloppy_pc_t pc; |
| 1795 | int ret = 0; | 1430 | int ret = 0; |
| 1796 | 1431 | ||
| 1797 | debug_log(KERN_INFO "Reached idefloppy_open\n"); | 1432 | debug_log("Reached %s\n", __func__); |
| 1798 | 1433 | ||
| 1799 | if (!(floppy = ide_floppy_get(disk))) | 1434 | floppy = ide_floppy_get(disk); |
| 1435 | if (!floppy) | ||
| 1800 | return -ENXIO; | 1436 | return -ENXIO; |
| 1801 | 1437 | ||
| 1802 | drive = floppy->drive; | 1438 | drive = floppy->drive; |
| @@ -1804,7 +1440,7 @@ static int idefloppy_open(struct inode *inode, struct file *filp) | |||
| 1804 | floppy->openers++; | 1440 | floppy->openers++; |
| 1805 | 1441 | ||
| 1806 | if (floppy->openers == 1) { | 1442 | if (floppy->openers == 1) { |
| 1807 | clear_bit(IDEFLOPPY_FORMAT_IN_PROGRESS, &floppy->flags); | 1443 | floppy->flags &= ~IDEFLOPPY_FLAG_FORMAT_IN_PROGRESS; |
| 1808 | /* Just in case */ | 1444 | /* Just in case */ |
| 1809 | 1445 | ||
| 1810 | idefloppy_create_test_unit_ready_cmd(&pc); | 1446 | idefloppy_create_test_unit_ready_cmd(&pc); |
| @@ -1813,13 +1449,13 @@ static int idefloppy_open(struct inode *inode, struct file *filp) | |||
| 1813 | (void) idefloppy_queue_pc_tail(drive, &pc); | 1449 | (void) idefloppy_queue_pc_tail(drive, &pc); |
| 1814 | } | 1450 | } |
| 1815 | 1451 | ||
| 1816 | if (idefloppy_get_capacity (drive) | 1452 | if (ide_floppy_get_capacity(drive) |
| 1817 | && (filp->f_flags & O_NDELAY) == 0 | 1453 | && (filp->f_flags & O_NDELAY) == 0 |
| 1818 | /* | 1454 | /* |
| 1819 | ** Allow O_NDELAY to open a drive without a disk, or with | 1455 | * Allow O_NDELAY to open a drive without a disk, or with an |
| 1820 | ** an unreadable disk, so that we can get the format | 1456 | * unreadable disk, so that we can get the format capacity |
| 1821 | ** capacity of the drive or begin the format - Sam | 1457 | * of the drive or begin the format - Sam |
| 1822 | */ | 1458 | */ |
| 1823 | ) { | 1459 | ) { |
| 1824 | ret = -EIO; | 1460 | ret = -EIO; |
| 1825 | goto out_put_floppy; | 1461 | goto out_put_floppy; |
| @@ -1829,14 +1465,14 @@ static int idefloppy_open(struct inode *inode, struct file *filp) | |||
| 1829 | ret = -EROFS; | 1465 | ret = -EROFS; |
| 1830 | goto out_put_floppy; | 1466 | goto out_put_floppy; |
| 1831 | } | 1467 | } |
| 1832 | set_bit(IDEFLOPPY_MEDIA_CHANGED, &floppy->flags); | 1468 | floppy->flags |= IDEFLOPPY_FLAG_MEDIA_CHANGED; |
| 1833 | /* IOMEGA Clik! drives do not support lock/unlock commands */ | 1469 | /* IOMEGA Clik! drives do not support lock/unlock commands */ |
| 1834 | if (!test_bit(IDEFLOPPY_CLIK_DRIVE, &floppy->flags)) { | 1470 | if (!(floppy->flags & IDEFLOPPY_FLAG_CLIK_DRIVE)) { |
| 1835 | idefloppy_create_prevent_cmd(&pc, 1); | 1471 | idefloppy_create_prevent_cmd(&pc, 1); |
| 1836 | (void) idefloppy_queue_pc_tail(drive, &pc); | 1472 | (void) idefloppy_queue_pc_tail(drive, &pc); |
| 1837 | } | 1473 | } |
| 1838 | check_disk_change(inode->i_bdev); | 1474 | check_disk_change(inode->i_bdev); |
| 1839 | } else if (test_bit(IDEFLOPPY_FORMAT_IN_PROGRESS, &floppy->flags)) { | 1475 | } else if (floppy->flags & IDEFLOPPY_FLAG_FORMAT_IN_PROGRESS) { |
| 1840 | ret = -EBUSY; | 1476 | ret = -EBUSY; |
| 1841 | goto out_put_floppy; | 1477 | goto out_put_floppy; |
| 1842 | } | 1478 | } |
| @@ -1854,17 +1490,17 @@ static int idefloppy_release(struct inode *inode, struct file *filp) | |||
| 1854 | struct ide_floppy_obj *floppy = ide_floppy_g(disk); | 1490 | struct ide_floppy_obj *floppy = ide_floppy_g(disk); |
| 1855 | ide_drive_t *drive = floppy->drive; | 1491 | ide_drive_t *drive = floppy->drive; |
| 1856 | idefloppy_pc_t pc; | 1492 | idefloppy_pc_t pc; |
| 1857 | 1493 | ||
| 1858 | debug_log(KERN_INFO "Reached idefloppy_release\n"); | 1494 | debug_log("Reached %s\n", __func__); |
| 1859 | 1495 | ||
| 1860 | if (floppy->openers == 1) { | 1496 | if (floppy->openers == 1) { |
| 1861 | /* IOMEGA Clik! drives do not support lock/unlock commands */ | 1497 | /* IOMEGA Clik! drives do not support lock/unlock commands */ |
| 1862 | if (!test_bit(IDEFLOPPY_CLIK_DRIVE, &floppy->flags)) { | 1498 | if (!(floppy->flags & IDEFLOPPY_FLAG_CLIK_DRIVE)) { |
| 1863 | idefloppy_create_prevent_cmd(&pc, 0); | 1499 | idefloppy_create_prevent_cmd(&pc, 0); |
| 1864 | (void) idefloppy_queue_pc_tail(drive, &pc); | 1500 | (void) idefloppy_queue_pc_tail(drive, &pc); |
| 1865 | } | 1501 | } |
| 1866 | 1502 | ||
| 1867 | clear_bit(IDEFLOPPY_FORMAT_IN_PROGRESS, &floppy->flags); | 1503 | floppy->flags &= ~IDEFLOPPY_FLAG_FORMAT_IN_PROGRESS; |
| 1868 | } | 1504 | } |
| 1869 | 1505 | ||
| 1870 | floppy->openers--; | 1506 | floppy->openers--; |
| @@ -1885,64 +1521,105 @@ static int idefloppy_getgeo(struct block_device *bdev, struct hd_geometry *geo) | |||
| 1885 | return 0; | 1521 | return 0; |
| 1886 | } | 1522 | } |
| 1887 | 1523 | ||
| 1524 | static int ide_floppy_lockdoor(idefloppy_floppy_t *floppy, idefloppy_pc_t *pc, | ||
| 1525 | unsigned long arg, unsigned int cmd) | ||
| 1526 | { | ||
| 1527 | if (floppy->openers > 1) | ||
| 1528 | return -EBUSY; | ||
| 1529 | |||
| 1530 | /* The IOMEGA Clik! Drive doesn't support this command - | ||
| 1531 | * no room for an eject mechanism */ | ||
| 1532 | if (!(floppy->flags & IDEFLOPPY_FLAG_CLIK_DRIVE)) { | ||
| 1533 | int prevent = arg ? 1 : 0; | ||
| 1534 | |||
| 1535 | if (cmd == CDROMEJECT) | ||
| 1536 | prevent = 0; | ||
| 1537 | |||
| 1538 | idefloppy_create_prevent_cmd(pc, prevent); | ||
| 1539 | (void) idefloppy_queue_pc_tail(floppy->drive, pc); | ||
| 1540 | } | ||
| 1541 | |||
| 1542 | if (cmd == CDROMEJECT) { | ||
| 1543 | idefloppy_create_start_stop_cmd(pc, 2); | ||
| 1544 | (void) idefloppy_queue_pc_tail(floppy->drive, pc); | ||
| 1545 | } | ||
| 1546 | |||
| 1547 | return 0; | ||
| 1548 | } | ||
| 1549 | |||
| 1550 | static int ide_floppy_format_unit(idefloppy_floppy_t *floppy, | ||
| 1551 | int __user *arg) | ||
| 1552 | { | ||
| 1553 | int blocks, length, flags, err = 0; | ||
| 1554 | idefloppy_pc_t pc; | ||
| 1555 | |||
| 1556 | if (floppy->openers > 1) { | ||
| 1557 | /* Don't format if someone is using the disk */ | ||
| 1558 | floppy->flags &= ~IDEFLOPPY_FLAG_FORMAT_IN_PROGRESS; | ||
| 1559 | return -EBUSY; | ||
| 1560 | } | ||
| 1561 | |||
| 1562 | floppy->flags |= IDEFLOPPY_FLAG_FORMAT_IN_PROGRESS; | ||
| 1563 | |||
| 1564 | /* | ||
| 1565 | * Send ATAPI_FORMAT_UNIT to the drive. | ||
| 1566 | * | ||
| 1567 | * Userland gives us the following structure: | ||
| 1568 | * | ||
| 1569 | * struct idefloppy_format_command { | ||
| 1570 | * int nblocks; | ||
| 1571 | * int blocksize; | ||
| 1572 | * int flags; | ||
| 1573 | * } ; | ||
| 1574 | * | ||
| 1575 | * flags is a bitmask, currently, the only defined flag is: | ||
| 1576 | * | ||
| 1577 | * 0x01 - verify media after format. | ||
| 1578 | */ | ||
| 1579 | if (get_user(blocks, arg) || | ||
| 1580 | get_user(length, arg+1) || | ||
| 1581 | get_user(flags, arg+2)) { | ||
| 1582 | err = -EFAULT; | ||
| 1583 | goto out; | ||
| 1584 | } | ||
| 1585 | |||
| 1586 | (void) idefloppy_get_sfrp_bit(floppy->drive); | ||
| 1587 | idefloppy_create_format_unit_cmd(&pc, blocks, length, flags); | ||
| 1588 | |||
| 1589 | if (idefloppy_queue_pc_tail(floppy->drive, &pc)) | ||
| 1590 | err = -EIO; | ||
| 1591 | |||
| 1592 | out: | ||
| 1593 | if (err) | ||
| 1594 | floppy->flags &= ~IDEFLOPPY_FLAG_FORMAT_IN_PROGRESS; | ||
| 1595 | return err; | ||
| 1596 | } | ||
| 1597 | |||
| 1598 | |||
| 1888 | static int idefloppy_ioctl(struct inode *inode, struct file *file, | 1599 | static int idefloppy_ioctl(struct inode *inode, struct file *file, |
| 1889 | unsigned int cmd, unsigned long arg) | 1600 | unsigned int cmd, unsigned long arg) |
| 1890 | { | 1601 | { |
| 1891 | struct block_device *bdev = inode->i_bdev; | 1602 | struct block_device *bdev = inode->i_bdev; |
| 1892 | struct ide_floppy_obj *floppy = ide_floppy_g(bdev->bd_disk); | 1603 | struct ide_floppy_obj *floppy = ide_floppy_g(bdev->bd_disk); |
| 1893 | ide_drive_t *drive = floppy->drive; | 1604 | ide_drive_t *drive = floppy->drive; |
| 1605 | idefloppy_pc_t pc; | ||
| 1894 | void __user *argp = (void __user *)arg; | 1606 | void __user *argp = (void __user *)arg; |
| 1895 | int err; | 1607 | int err; |
| 1896 | int prevent = (arg) ? 1 : 0; | ||
| 1897 | idefloppy_pc_t pc; | ||
| 1898 | 1608 | ||
| 1899 | switch (cmd) { | 1609 | switch (cmd) { |
| 1900 | case CDROMEJECT: | 1610 | case CDROMEJECT: |
| 1901 | prevent = 0; | ||
| 1902 | /* fall through */ | 1611 | /* fall through */ |
| 1903 | case CDROM_LOCKDOOR: | 1612 | case CDROM_LOCKDOOR: |
| 1904 | if (floppy->openers > 1) | 1613 | return ide_floppy_lockdoor(floppy, &pc, arg, cmd); |
| 1905 | return -EBUSY; | ||
| 1906 | |||
| 1907 | /* The IOMEGA Clik! Drive doesn't support this command - no room for an eject mechanism */ | ||
| 1908 | if (!test_bit(IDEFLOPPY_CLIK_DRIVE, &floppy->flags)) { | ||
| 1909 | idefloppy_create_prevent_cmd(&pc, prevent); | ||
| 1910 | (void) idefloppy_queue_pc_tail(drive, &pc); | ||
| 1911 | } | ||
| 1912 | if (cmd == CDROMEJECT) { | ||
| 1913 | idefloppy_create_start_stop_cmd(&pc, 2); | ||
| 1914 | (void) idefloppy_queue_pc_tail(drive, &pc); | ||
| 1915 | } | ||
| 1916 | return 0; | ||
| 1917 | case IDEFLOPPY_IOCTL_FORMAT_SUPPORTED: | 1614 | case IDEFLOPPY_IOCTL_FORMAT_SUPPORTED: |
| 1918 | return 0; | 1615 | return 0; |
| 1919 | case IDEFLOPPY_IOCTL_FORMAT_GET_CAPACITY: | 1616 | case IDEFLOPPY_IOCTL_FORMAT_GET_CAPACITY: |
| 1920 | return idefloppy_get_format_capacities(drive, argp); | 1617 | return ide_floppy_get_format_capacities(drive, argp); |
| 1921 | case IDEFLOPPY_IOCTL_FORMAT_START: | 1618 | case IDEFLOPPY_IOCTL_FORMAT_START: |
| 1922 | |||
| 1923 | if (!(file->f_mode & 2)) | 1619 | if (!(file->f_mode & 2)) |
| 1924 | return -EPERM; | 1620 | return -EPERM; |
| 1925 | 1621 | ||
| 1926 | if (floppy->openers > 1) { | 1622 | return ide_floppy_format_unit(floppy, (int __user *)arg); |
| 1927 | /* Don't format if someone is using the disk */ | ||
| 1928 | |||
| 1929 | clear_bit(IDEFLOPPY_FORMAT_IN_PROGRESS, | ||
| 1930 | &floppy->flags); | ||
| 1931 | return -EBUSY; | ||
| 1932 | } | ||
| 1933 | |||
| 1934 | set_bit(IDEFLOPPY_FORMAT_IN_PROGRESS, &floppy->flags); | ||
| 1935 | |||
| 1936 | err = idefloppy_begin_format(drive, argp); | ||
| 1937 | if (err) | ||
| 1938 | clear_bit(IDEFLOPPY_FORMAT_IN_PROGRESS, &floppy->flags); | ||
| 1939 | return err; | ||
| 1940 | /* | ||
| 1941 | ** Note, the bit will be cleared when the device is | ||
| 1942 | ** closed. This is the cleanest way to handle the | ||
| 1943 | ** situation where the drive does not support | ||
| 1944 | ** format progress reporting. | ||
| 1945 | */ | ||
| 1946 | case IDEFLOPPY_IOCTL_FORMAT_GET_PROGRESS: | 1623 | case IDEFLOPPY_IOCTL_FORMAT_GET_PROGRESS: |
| 1947 | return idefloppy_get_format_progress(drive, argp); | 1624 | return idefloppy_get_format_progress(drive, argp); |
| 1948 | } | 1625 | } |
| @@ -1967,13 +1644,16 @@ static int idefloppy_media_changed(struct gendisk *disk) | |||
| 1967 | { | 1644 | { |
| 1968 | struct ide_floppy_obj *floppy = ide_floppy_g(disk); | 1645 | struct ide_floppy_obj *floppy = ide_floppy_g(disk); |
| 1969 | ide_drive_t *drive = floppy->drive; | 1646 | ide_drive_t *drive = floppy->drive; |
| 1647 | int ret; | ||
| 1970 | 1648 | ||
| 1971 | /* do not scan partitions twice if this is a removable device */ | 1649 | /* do not scan partitions twice if this is a removable device */ |
| 1972 | if (drive->attach) { | 1650 | if (drive->attach) { |
| 1973 | drive->attach = 0; | 1651 | drive->attach = 0; |
| 1974 | return 0; | 1652 | return 0; |
| 1975 | } | 1653 | } |
| 1976 | return test_and_clear_bit(IDEFLOPPY_MEDIA_CHANGED, &floppy->flags); | 1654 | ret = !!(floppy->flags & IDEFLOPPY_FLAG_MEDIA_CHANGED); |
| 1655 | floppy->flags &= ~IDEFLOPPY_FLAG_MEDIA_CHANGED; | ||
| 1656 | return ret; | ||
| 1977 | } | 1657 | } |
| 1978 | 1658 | ||
| 1979 | static int idefloppy_revalidate_disk(struct gendisk *disk) | 1659 | static int idefloppy_revalidate_disk(struct gendisk *disk) |
| @@ -2004,16 +1684,20 @@ static int ide_floppy_probe(ide_drive_t *drive) | |||
| 2004 | goto failed; | 1684 | goto failed; |
| 2005 | if (drive->media != ide_floppy) | 1685 | if (drive->media != ide_floppy) |
| 2006 | goto failed; | 1686 | goto failed; |
| 2007 | if (!idefloppy_identify_device (drive, drive->id)) { | 1687 | if (!idefloppy_identify_device(drive, drive->id)) { |
| 2008 | printk (KERN_ERR "ide-floppy: %s: not supported by this version of ide-floppy\n", drive->name); | 1688 | printk(KERN_ERR "ide-floppy: %s: not supported by this version" |
| 1689 | " of ide-floppy\n", drive->name); | ||
| 2009 | goto failed; | 1690 | goto failed; |
| 2010 | } | 1691 | } |
| 2011 | if (drive->scsi) { | 1692 | if (drive->scsi) { |
| 2012 | printk("ide-floppy: passing drive %s to ide-scsi emulation.\n", drive->name); | 1693 | printk(KERN_INFO "ide-floppy: passing drive %s to ide-scsi" |
| 1694 | " emulation.\n", drive->name); | ||
| 2013 | goto failed; | 1695 | goto failed; |
| 2014 | } | 1696 | } |
| 2015 | if ((floppy = kzalloc(sizeof (idefloppy_floppy_t), GFP_KERNEL)) == NULL) { | 1697 | floppy = kzalloc(sizeof(idefloppy_floppy_t), GFP_KERNEL); |
| 2016 | printk (KERN_ERR "ide-floppy: %s: Can't allocate a floppy structure\n", drive->name); | 1698 | if (!floppy) { |
| 1699 | printk(KERN_ERR "ide-floppy: %s: Can't allocate a floppy" | ||
| 1700 | " structure\n", drive->name); | ||
| 2017 | goto failed; | 1701 | goto failed; |
| 2018 | } | 1702 | } |
| 2019 | 1703 | ||
| @@ -2035,7 +1719,7 @@ static int ide_floppy_probe(ide_drive_t *drive) | |||
| 2035 | 1719 | ||
| 2036 | drive->driver_data = floppy; | 1720 | drive->driver_data = floppy; |
| 2037 | 1721 | ||
| 2038 | idefloppy_setup (drive, floppy); | 1722 | idefloppy_setup(drive, floppy); |
| 2039 | 1723 | ||
| 2040 | g->minors = 1 << PARTN_BITS; | 1724 | g->minors = 1 << PARTN_BITS; |
| 2041 | g->driverfs_dev = &drive->gendev; | 1725 | g->driverfs_dev = &drive->gendev; |
| @@ -2051,9 +1735,7 @@ failed: | |||
| 2051 | return -ENODEV; | 1735 | return -ENODEV; |
| 2052 | } | 1736 | } |
| 2053 | 1737 | ||
| 2054 | MODULE_DESCRIPTION("ATAPI FLOPPY Driver"); | 1738 | static void __exit idefloppy_exit(void) |
| 2055 | |||
| 2056 | static void __exit idefloppy_exit (void) | ||
| 2057 | { | 1739 | { |
| 2058 | driver_unregister(&idefloppy_driver.gen_driver); | 1740 | driver_unregister(&idefloppy_driver.gen_driver); |
| 2059 | } | 1741 | } |
| @@ -2068,3 +1750,5 @@ MODULE_ALIAS("ide:*m-floppy*"); | |||
| 2068 | module_init(idefloppy_init); | 1750 | module_init(idefloppy_init); |
| 2069 | module_exit(idefloppy_exit); | 1751 | module_exit(idefloppy_exit); |
| 2070 | MODULE_LICENSE("GPL"); | 1752 | MODULE_LICENSE("GPL"); |
| 1753 | MODULE_DESCRIPTION("ATAPI FLOPPY Driver"); | ||
| 1754 | |||
diff --git a/drivers/ide/ide-generic.c b/drivers/ide/ide-generic.c index bb30c29f6ec0..be469dbbe8fb 100644 --- a/drivers/ide/ide-generic.c +++ b/drivers/ide/ide-generic.c | |||
| @@ -23,7 +23,7 @@ static int __init ide_generic_init(void) | |||
| 23 | for (i = 0; i < MAX_HWIFS; i++) | 23 | for (i = 0; i < MAX_HWIFS; i++) |
| 24 | idx[i] = ide_hwifs[i].present ? 0xff : i; | 24 | idx[i] = ide_hwifs[i].present ? 0xff : i; |
| 25 | 25 | ||
| 26 | ide_device_add_all(idx); | 26 | ide_device_add_all(idx, NULL); |
| 27 | 27 | ||
| 28 | if (ide_hwifs[0].io_ports[IDE_DATA_OFFSET]) | 28 | if (ide_hwifs[0].io_ports[IDE_DATA_OFFSET]) |
| 29 | ide_release_lock(); /* for atari only */ | 29 | ide_release_lock(); /* for atari only */ |
diff --git a/drivers/ide/ide-iops.c b/drivers/ide/ide-iops.c index 16b1f6e12781..a95178f5e1bb 100644 --- a/drivers/ide/ide-iops.c +++ b/drivers/ide/ide-iops.c | |||
| @@ -163,8 +163,6 @@ void SELECT_DRIVE (ide_drive_t *drive) | |||
| 163 | HWIF(drive)->OUTB(drive->select.all, IDE_SELECT_REG); | 163 | HWIF(drive)->OUTB(drive->select.all, IDE_SELECT_REG); |
| 164 | } | 164 | } |
| 165 | 165 | ||
| 166 | EXPORT_SYMBOL(SELECT_DRIVE); | ||
| 167 | |||
| 168 | void SELECT_MASK (ide_drive_t *drive, int mask) | 166 | void SELECT_MASK (ide_drive_t *drive, int mask) |
| 169 | { | 167 | { |
| 170 | if (HWIF(drive)->maskproc) | 168 | if (HWIF(drive)->maskproc) |
| @@ -614,66 +612,6 @@ no_80w: | |||
| 614 | return 0; | 612 | return 0; |
| 615 | } | 613 | } |
| 616 | 614 | ||
| 617 | int ide_ata66_check (ide_drive_t *drive, ide_task_t *args) | ||
| 618 | { | ||
| 619 | if (args->tf.command == WIN_SETFEATURES && | ||
| 620 | args->tf.nsect > XFER_UDMA_2 && | ||
| 621 | args->tf.feature == SETFEATURES_XFER) { | ||
| 622 | if (eighty_ninty_three(drive) == 0) { | ||
| 623 | printk(KERN_WARNING "%s: UDMA speeds >UDMA33 cannot " | ||
| 624 | "be set\n", drive->name); | ||
| 625 | return 1; | ||
| 626 | } | ||
| 627 | } | ||
| 628 | |||
| 629 | return 0; | ||
| 630 | } | ||
| 631 | |||
| 632 | /* | ||
| 633 | * Backside of HDIO_DRIVE_CMD call of SETFEATURES_XFER. | ||
| 634 | * 1 : Safe to update drive->id DMA registers. | ||
| 635 | * 0 : OOPs not allowed. | ||
| 636 | */ | ||
| 637 | int set_transfer (ide_drive_t *drive, ide_task_t *args) | ||
| 638 | { | ||
| 639 | if (args->tf.command == WIN_SETFEATURES && | ||
| 640 | args->tf.nsect >= XFER_SW_DMA_0 && | ||
| 641 | args->tf.feature == SETFEATURES_XFER && | ||
| 642 | (drive->id->dma_ultra || | ||
| 643 | drive->id->dma_mword || | ||
| 644 | drive->id->dma_1word)) | ||
| 645 | return 1; | ||
| 646 | |||
| 647 | return 0; | ||
| 648 | } | ||
| 649 | |||
| 650 | #ifdef CONFIG_BLK_DEV_IDEDMA | ||
| 651 | static u8 ide_auto_reduce_xfer (ide_drive_t *drive) | ||
| 652 | { | ||
| 653 | if (!drive->crc_count) | ||
| 654 | return drive->current_speed; | ||
| 655 | drive->crc_count = 0; | ||
| 656 | |||
| 657 | switch(drive->current_speed) { | ||
| 658 | case XFER_UDMA_7: return XFER_UDMA_6; | ||
| 659 | case XFER_UDMA_6: return XFER_UDMA_5; | ||
| 660 | case XFER_UDMA_5: return XFER_UDMA_4; | ||
| 661 | case XFER_UDMA_4: return XFER_UDMA_3; | ||
| 662 | case XFER_UDMA_3: return XFER_UDMA_2; | ||
| 663 | case XFER_UDMA_2: return XFER_UDMA_1; | ||
| 664 | case XFER_UDMA_1: return XFER_UDMA_0; | ||
| 665 | /* | ||
| 666 | * OOPS we do not goto non Ultra DMA modes | ||
| 667 | * without iCRC's available we force | ||
| 668 | * the system to PIO and make the user | ||
| 669 | * invoke the ATA-1 ATA-2 DMA modes. | ||
| 670 | */ | ||
| 671 | case XFER_UDMA_0: | ||
| 672 | default: return XFER_PIO_4; | ||
| 673 | } | ||
| 674 | } | ||
| 675 | #endif /* CONFIG_BLK_DEV_IDEDMA */ | ||
| 676 | |||
| 677 | int ide_driveid_update(ide_drive_t *drive) | 615 | int ide_driveid_update(ide_drive_t *drive) |
| 678 | { | 616 | { |
| 679 | ide_hwif_t *hwif = drive->hwif; | 617 | ide_hwif_t *hwif = drive->hwif; |
| @@ -882,22 +820,17 @@ void ide_execute_command(ide_drive_t *drive, u8 cmd, ide_handler_t *handler, | |||
| 882 | unsigned long flags; | 820 | unsigned long flags; |
| 883 | ide_hwgroup_t *hwgroup = HWGROUP(drive); | 821 | ide_hwgroup_t *hwgroup = HWGROUP(drive); |
| 884 | ide_hwif_t *hwif = HWIF(drive); | 822 | ide_hwif_t *hwif = HWIF(drive); |
| 885 | 823 | ||
| 886 | spin_lock_irqsave(&ide_lock, flags); | 824 | spin_lock_irqsave(&ide_lock, flags); |
| 887 | |||
| 888 | BUG_ON(hwgroup->handler); | 825 | BUG_ON(hwgroup->handler); |
| 889 | hwgroup->handler = handler; | 826 | __ide_set_handler(drive, handler, timeout, expiry); |
| 890 | hwgroup->expiry = expiry; | ||
| 891 | hwgroup->timer.expires = jiffies + timeout; | ||
| 892 | hwgroup->req_gen_timer = hwgroup->req_gen; | ||
| 893 | add_timer(&hwgroup->timer); | ||
| 894 | hwif->OUTBSYNC(drive, cmd, IDE_COMMAND_REG); | 827 | hwif->OUTBSYNC(drive, cmd, IDE_COMMAND_REG); |
| 895 | /* Drive takes 400nS to respond, we must avoid the IRQ being | 828 | /* |
| 896 | serviced before that. | 829 | * Drive takes 400nS to respond, we must avoid the IRQ being |
| 897 | 830 | * serviced before that. | |
| 898 | FIXME: we could skip this delay with care on non shared | 831 | * |
| 899 | devices | 832 | * FIXME: we could skip this delay with care on non shared devices |
| 900 | */ | 833 | */ |
| 901 | ndelay(400); | 834 | ndelay(400); |
| 902 | spin_unlock_irqrestore(&ide_lock, flags); | 835 | spin_unlock_irqrestore(&ide_lock, flags); |
| 903 | } | 836 | } |
| @@ -1005,19 +938,6 @@ static ide_startstop_t reset_pollfunc (ide_drive_t *drive) | |||
| 1005 | return ide_stopped; | 938 | return ide_stopped; |
| 1006 | } | 939 | } |
| 1007 | 940 | ||
| 1008 | static void check_dma_crc(ide_drive_t *drive) | ||
| 1009 | { | ||
| 1010 | #ifdef CONFIG_BLK_DEV_IDEDMA | ||
| 1011 | if (drive->crc_count) { | ||
| 1012 | ide_dma_off_quietly(drive); | ||
| 1013 | ide_set_xfer_rate(drive, ide_auto_reduce_xfer(drive)); | ||
| 1014 | if (drive->current_speed >= XFER_SW_DMA_0) | ||
| 1015 | ide_dma_on(drive); | ||
| 1016 | } else | ||
| 1017 | ide_dma_off(drive); | ||
| 1018 | #endif | ||
| 1019 | } | ||
| 1020 | |||
| 1021 | static void ide_disk_pre_reset(ide_drive_t *drive) | 941 | static void ide_disk_pre_reset(ide_drive_t *drive) |
| 1022 | { | 942 | { |
| 1023 | int legacy = (drive->id->cfs_enable_2 & 0x0400) ? 0 : 1; | 943 | int legacy = (drive->id->cfs_enable_2 & 0x0400) ? 0 : 1; |
| @@ -1039,17 +959,20 @@ static void pre_reset(ide_drive_t *drive) | |||
| 1039 | else | 959 | else |
| 1040 | drive->post_reset = 1; | 960 | drive->post_reset = 1; |
| 1041 | 961 | ||
| 962 | if (drive->using_dma) { | ||
| 963 | if (drive->crc_count) | ||
| 964 | ide_check_dma_crc(drive); | ||
| 965 | else | ||
| 966 | ide_dma_off(drive); | ||
| 967 | } | ||
| 968 | |||
| 1042 | if (!drive->keep_settings) { | 969 | if (!drive->keep_settings) { |
| 1043 | if (drive->using_dma) { | 970 | if (!drive->using_dma) { |
| 1044 | check_dma_crc(drive); | ||
| 1045 | } else { | ||
| 1046 | drive->unmask = 0; | 971 | drive->unmask = 0; |
| 1047 | drive->io_32bit = 0; | 972 | drive->io_32bit = 0; |
| 1048 | } | 973 | } |
| 1049 | return; | 974 | return; |
| 1050 | } | 975 | } |
| 1051 | if (drive->using_dma) | ||
| 1052 | check_dma_crc(drive); | ||
| 1053 | 976 | ||
| 1054 | if (HWIF(drive)->pre_reset != NULL) | 977 | if (HWIF(drive)->pre_reset != NULL) |
| 1055 | HWIF(drive)->pre_reset(drive); | 978 | HWIF(drive)->pre_reset(drive); |
diff --git a/drivers/ide/ide-pnp.c b/drivers/ide/ide-pnp.c index 4bda5cf2be37..b163b2e52212 100644 --- a/drivers/ide/ide-pnp.c +++ b/drivers/ide/ide-pnp.c | |||
| @@ -49,7 +49,7 @@ static int idepnp_probe(struct pnp_dev * dev, const struct pnp_device_id *dev_id | |||
| 49 | printk(KERN_INFO "ide%d: generic PnP IDE interface\n", index); | 49 | printk(KERN_INFO "ide%d: generic PnP IDE interface\n", index); |
| 50 | pnp_set_drvdata(dev,hwif); | 50 | pnp_set_drvdata(dev,hwif); |
| 51 | 51 | ||
| 52 | ide_device_add(idx); | 52 | ide_device_add(idx, NULL); |
| 53 | 53 | ||
| 54 | return 0; | 54 | return 0; |
| 55 | } | 55 | } |
| @@ -60,9 +60,10 @@ static int idepnp_probe(struct pnp_dev * dev, const struct pnp_device_id *dev_id | |||
| 60 | static void idepnp_remove(struct pnp_dev * dev) | 60 | static void idepnp_remove(struct pnp_dev * dev) |
| 61 | { | 61 | { |
| 62 | ide_hwif_t *hwif = pnp_get_drvdata(dev); | 62 | ide_hwif_t *hwif = pnp_get_drvdata(dev); |
| 63 | if (hwif) { | 63 | |
| 64 | ide_unregister(hwif->index); | 64 | if (hwif) |
| 65 | } else | 65 | ide_unregister(hwif->index, 0, 0); |
| 66 | else | ||
| 66 | printk(KERN_ERR "idepnp: Unable to remove device, please report.\n"); | 67 | printk(KERN_ERR "idepnp: Unable to remove device, please report.\n"); |
| 67 | } | 68 | } |
| 68 | 69 | ||
diff --git a/drivers/ide/ide-probe.c b/drivers/ide/ide-probe.c index 98a8af44bf64..9c07bdb68d1a 100644 --- a/drivers/ide/ide-probe.c +++ b/drivers/ide/ide-probe.c | |||
| @@ -423,8 +423,9 @@ static int ide_busy_sleep(ide_hwif_t *hwif) | |||
| 423 | 423 | ||
| 424 | static int do_probe (ide_drive_t *drive, u8 cmd) | 424 | static int do_probe (ide_drive_t *drive, u8 cmd) |
| 425 | { | 425 | { |
| 426 | int rc; | ||
| 427 | ide_hwif_t *hwif = HWIF(drive); | 426 | ide_hwif_t *hwif = HWIF(drive); |
| 427 | int rc; | ||
| 428 | u8 stat; | ||
| 428 | 429 | ||
| 429 | if (drive->present) { | 430 | if (drive->present) { |
| 430 | /* avoid waiting for inappropriate probes */ | 431 | /* avoid waiting for inappropriate probes */ |
| @@ -461,15 +462,17 @@ static int do_probe (ide_drive_t *drive, u8 cmd) | |||
| 461 | /* failed: try again */ | 462 | /* failed: try again */ |
| 462 | rc = try_to_identify(drive,cmd); | 463 | rc = try_to_identify(drive,cmd); |
| 463 | } | 464 | } |
| 464 | if (hwif->INB(IDE_STATUS_REG) == (BUSY_STAT|READY_STAT)) | 465 | |
| 466 | stat = hwif->INB(IDE_STATUS_REG); | ||
| 467 | |||
| 468 | if (stat == (BUSY_STAT | READY_STAT)) | ||
| 465 | return 4; | 469 | return 4; |
| 466 | 470 | ||
| 467 | if ((rc == 1 && cmd == WIN_PIDENTIFY) && | 471 | if ((rc == 1 && cmd == WIN_PIDENTIFY) && |
| 468 | ((drive->autotune == IDE_TUNE_DEFAULT) || | 472 | ((drive->autotune == IDE_TUNE_DEFAULT) || |
| 469 | (drive->autotune == IDE_TUNE_AUTO))) { | 473 | (drive->autotune == IDE_TUNE_AUTO))) { |
| 470 | printk("%s: no response (status = 0x%02x), " | 474 | printk(KERN_ERR "%s: no response (status = 0x%02x), " |
| 471 | "resetting drive\n", drive->name, | 475 | "resetting drive\n", drive->name, stat); |
| 472 | hwif->INB(IDE_STATUS_REG)); | ||
| 473 | msleep(50); | 476 | msleep(50); |
| 474 | hwif->OUTB(drive->select.all, IDE_SELECT_REG); | 477 | hwif->OUTB(drive->select.all, IDE_SELECT_REG); |
| 475 | msleep(50); | 478 | msleep(50); |
| @@ -477,11 +480,13 @@ static int do_probe (ide_drive_t *drive, u8 cmd) | |||
| 477 | (void)ide_busy_sleep(hwif); | 480 | (void)ide_busy_sleep(hwif); |
| 478 | rc = try_to_identify(drive, cmd); | 481 | rc = try_to_identify(drive, cmd); |
| 479 | } | 482 | } |
| 483 | |||
| 484 | /* ensure drive IRQ is clear */ | ||
| 485 | stat = hwif->INB(IDE_STATUS_REG); | ||
| 486 | |||
| 480 | if (rc == 1) | 487 | if (rc == 1) |
| 481 | printk("%s: no response (status = 0x%02x)\n", | 488 | printk(KERN_ERR "%s: no response (status = 0x%02x)\n", |
| 482 | drive->name, hwif->INB(IDE_STATUS_REG)); | 489 | drive->name, stat); |
| 483 | /* ensure drive irq is clear */ | ||
| 484 | (void) hwif->INB(IDE_STATUS_REG); | ||
| 485 | } else { | 490 | } else { |
| 486 | /* not present or maybe ATAPI */ | 491 | /* not present or maybe ATAPI */ |
| 487 | rc = 3; | 492 | rc = 3; |
| @@ -502,6 +507,7 @@ static int do_probe (ide_drive_t *drive, u8 cmd) | |||
| 502 | static void enable_nest (ide_drive_t *drive) | 507 | static void enable_nest (ide_drive_t *drive) |
| 503 | { | 508 | { |
| 504 | ide_hwif_t *hwif = HWIF(drive); | 509 | ide_hwif_t *hwif = HWIF(drive); |
| 510 | u8 stat; | ||
| 505 | 511 | ||
| 506 | printk("%s: enabling %s -- ", hwif->name, drive->id->model); | 512 | printk("%s: enabling %s -- ", hwif->name, drive->id->model); |
| 507 | SELECT_DRIVE(drive); | 513 | SELECT_DRIVE(drive); |
| @@ -515,11 +521,12 @@ static void enable_nest (ide_drive_t *drive) | |||
| 515 | 521 | ||
| 516 | msleep(50); | 522 | msleep(50); |
| 517 | 523 | ||
| 518 | if (!OK_STAT((hwif->INB(IDE_STATUS_REG)), 0, BAD_STAT)) { | 524 | stat = hwif->INB(IDE_STATUS_REG); |
| 519 | printk("failed (status = 0x%02x)\n", hwif->INB(IDE_STATUS_REG)); | 525 | |
| 520 | } else { | 526 | if (!OK_STAT(stat, 0, BAD_STAT)) |
| 521 | printk("success\n"); | 527 | printk(KERN_CONT "failed (status = 0x%02x)\n", stat); |
| 522 | } | 528 | else |
| 529 | printk(KERN_CONT "success\n"); | ||
| 523 | 530 | ||
| 524 | /* if !(success||timed-out) */ | 531 | /* if !(success||timed-out) */ |
| 525 | if (do_probe(drive, WIN_IDENTIFY) >= 2) { | 532 | if (do_probe(drive, WIN_IDENTIFY) >= 2) { |
| @@ -822,7 +829,7 @@ static void ide_port_tune_devices(ide_hwif_t *hwif) | |||
| 822 | for (unit = 0; unit < MAX_DRIVES; ++unit) { | 829 | for (unit = 0; unit < MAX_DRIVES; ++unit) { |
| 823 | ide_drive_t *drive = &hwif->drives[unit]; | 830 | ide_drive_t *drive = &hwif->drives[unit]; |
| 824 | 831 | ||
| 825 | if (hwif->no_io_32bit) | 832 | if (hwif->host_flags & IDE_HFLAG_NO_IO_32BIT) |
| 826 | drive->no_io_32bit = 1; | 833 | drive->no_io_32bit = 1; |
| 827 | else | 834 | else |
| 828 | drive->no_io_32bit = drive->id->dword_io ? 1 : 0; | 835 | drive->no_io_32bit = drive->id->dword_io ? 1 : 0; |
| @@ -881,13 +888,6 @@ static int ide_init_queue(ide_drive_t *drive) | |||
| 881 | q->queuedata = drive; | 888 | q->queuedata = drive; |
| 882 | blk_queue_segment_boundary(q, 0xffff); | 889 | blk_queue_segment_boundary(q, 0xffff); |
| 883 | 890 | ||
| 884 | if (!hwif->rqsize) { | ||
| 885 | if ((hwif->host_flags & IDE_HFLAG_NO_LBA48) || | ||
| 886 | (hwif->host_flags & IDE_HFLAG_NO_LBA48_DMA)) | ||
| 887 | hwif->rqsize = 256; | ||
| 888 | else | ||
| 889 | hwif->rqsize = 65536; | ||
| 890 | } | ||
| 891 | if (hwif->rqsize < max_sectors) | 891 | if (hwif->rqsize < max_sectors) |
| 892 | max_sectors = hwif->rqsize; | 892 | max_sectors = hwif->rqsize; |
| 893 | blk_queue_max_sectors(q, max_sectors); | 893 | blk_queue_max_sectors(q, max_sectors); |
| @@ -918,6 +918,48 @@ static int ide_init_queue(ide_drive_t *drive) | |||
| 918 | return 0; | 918 | return 0; |
| 919 | } | 919 | } |
| 920 | 920 | ||
| 921 | static void ide_add_drive_to_hwgroup(ide_drive_t *drive) | ||
| 922 | { | ||
| 923 | ide_hwgroup_t *hwgroup = drive->hwif->hwgroup; | ||
| 924 | |||
| 925 | spin_lock_irq(&ide_lock); | ||
| 926 | if (!hwgroup->drive) { | ||
| 927 | /* first drive for hwgroup. */ | ||
| 928 | drive->next = drive; | ||
| 929 | hwgroup->drive = drive; | ||
| 930 | hwgroup->hwif = HWIF(hwgroup->drive); | ||
| 931 | } else { | ||
| 932 | drive->next = hwgroup->drive->next; | ||
| 933 | hwgroup->drive->next = drive; | ||
| 934 | } | ||
| 935 | spin_unlock_irq(&ide_lock); | ||
| 936 | } | ||
| 937 | |||
| 938 | /* | ||
| 939 | * For any present drive: | ||
| 940 | * - allocate the block device queue | ||
| 941 | * - link drive into the hwgroup | ||
| 942 | */ | ||
| 943 | static void ide_port_setup_devices(ide_hwif_t *hwif) | ||
| 944 | { | ||
| 945 | int i; | ||
| 946 | |||
| 947 | for (i = 0; i < MAX_DRIVES; i++) { | ||
| 948 | ide_drive_t *drive = &hwif->drives[i]; | ||
| 949 | |||
| 950 | if (!drive->present) | ||
| 951 | continue; | ||
| 952 | |||
| 953 | if (ide_init_queue(drive)) { | ||
| 954 | printk(KERN_ERR "ide: failed to init %s\n", | ||
| 955 | drive->name); | ||
| 956 | continue; | ||
| 957 | } | ||
| 958 | |||
| 959 | ide_add_drive_to_hwgroup(drive); | ||
| 960 | } | ||
| 961 | } | ||
| 962 | |||
| 921 | /* | 963 | /* |
| 922 | * This routine sets up the irq for an ide interface, and creates a new | 964 | * This routine sets up the irq for an ide interface, and creates a new |
| 923 | * hwgroup for the irq/hwif if none was previously assigned. | 965 | * hwgroup for the irq/hwif if none was previously assigned. |
| @@ -1019,30 +1061,12 @@ static int init_irq (ide_hwif_t *hwif) | |||
| 1019 | goto out_unlink; | 1061 | goto out_unlink; |
| 1020 | } | 1062 | } |
| 1021 | 1063 | ||
| 1022 | /* | 1064 | if (!hwif->rqsize) { |
| 1023 | * For any present drive: | 1065 | if ((hwif->host_flags & IDE_HFLAG_NO_LBA48) || |
| 1024 | * - allocate the block device queue | 1066 | (hwif->host_flags & IDE_HFLAG_NO_LBA48_DMA)) |
| 1025 | * - link drive into the hwgroup | 1067 | hwif->rqsize = 256; |
| 1026 | */ | 1068 | else |
| 1027 | for (index = 0; index < MAX_DRIVES; ++index) { | 1069 | hwif->rqsize = 65536; |
| 1028 | ide_drive_t *drive = &hwif->drives[index]; | ||
| 1029 | if (!drive->present) | ||
| 1030 | continue; | ||
| 1031 | if (ide_init_queue(drive)) { | ||
| 1032 | printk(KERN_ERR "ide: failed to init %s\n",drive->name); | ||
| 1033 | continue; | ||
| 1034 | } | ||
| 1035 | spin_lock_irq(&ide_lock); | ||
| 1036 | if (!hwgroup->drive) { | ||
| 1037 | /* first drive for hwgroup. */ | ||
| 1038 | drive->next = drive; | ||
| 1039 | hwgroup->drive = drive; | ||
| 1040 | hwgroup->hwif = HWIF(hwgroup->drive); | ||
| 1041 | } else { | ||
| 1042 | drive->next = hwgroup->drive->next; | ||
| 1043 | hwgroup->drive->next = drive; | ||
| 1044 | } | ||
| 1045 | spin_unlock_irq(&ide_lock); | ||
| 1046 | } | 1070 | } |
| 1047 | 1071 | ||
| 1048 | #if !defined(__mc68000__) && !defined(CONFIG_APUS) | 1072 | #if !defined(__mc68000__) && !defined(CONFIG_APUS) |
| @@ -1058,6 +1082,9 @@ static int init_irq (ide_hwif_t *hwif) | |||
| 1058 | printk(" (%sed with %s)", | 1082 | printk(" (%sed with %s)", |
| 1059 | hwif->sharing_irq ? "shar" : "serializ", match->name); | 1083 | hwif->sharing_irq ? "shar" : "serializ", match->name); |
| 1060 | printk("\n"); | 1084 | printk("\n"); |
| 1085 | |||
| 1086 | ide_port_setup_devices(hwif); | ||
| 1087 | |||
| 1061 | mutex_unlock(&ide_cfg_mtx); | 1088 | mutex_unlock(&ide_cfg_mtx); |
| 1062 | return 0; | 1089 | return 0; |
| 1063 | out_unlink: | 1090 | out_unlink: |
| @@ -1182,30 +1209,6 @@ static void drive_release_dev (struct device *dev) | |||
| 1182 | complete(&drive->gendev_rel_comp); | 1209 | complete(&drive->gendev_rel_comp); |
| 1183 | } | 1210 | } |
| 1184 | 1211 | ||
| 1185 | /* | ||
| 1186 | * init_gendisk() (as opposed to ide_geninit) is called for each major device, | ||
| 1187 | * after probing for drives, to allocate partition tables and other data | ||
| 1188 | * structures needed for the routines in genhd.c. ide_geninit() gets called | ||
| 1189 | * somewhat later, during the partition check. | ||
| 1190 | */ | ||
| 1191 | static void init_gendisk (ide_hwif_t *hwif) | ||
| 1192 | { | ||
| 1193 | unsigned int unit; | ||
| 1194 | |||
| 1195 | for (unit = 0; unit < MAX_DRIVES; ++unit) { | ||
| 1196 | ide_drive_t * drive = &hwif->drives[unit]; | ||
| 1197 | ide_add_generic_settings(drive); | ||
| 1198 | snprintf(drive->gendev.bus_id,BUS_ID_SIZE,"%u.%u", | ||
| 1199 | hwif->index,unit); | ||
| 1200 | drive->gendev.parent = &hwif->gendev; | ||
| 1201 | drive->gendev.bus = &ide_bus_type; | ||
| 1202 | drive->gendev.driver_data = drive; | ||
| 1203 | drive->gendev.release = drive_release_dev; | ||
| 1204 | } | ||
| 1205 | blk_register_region(MKDEV(hwif->major, 0), MAX_DRIVES << PARTN_BITS, | ||
| 1206 | THIS_MODULE, ata_probe, ata_lock, hwif); | ||
| 1207 | } | ||
| 1208 | |||
| 1209 | static int hwif_init(ide_hwif_t *hwif) | 1212 | static int hwif_init(ide_hwif_t *hwif) |
| 1210 | { | 1213 | { |
| 1211 | int old_irq; | 1214 | int old_irq; |
| @@ -1262,8 +1265,8 @@ static int hwif_init(ide_hwif_t *hwif) | |||
| 1262 | hwif->name, hwif->irq); | 1265 | hwif->name, hwif->irq); |
| 1263 | 1266 | ||
| 1264 | done: | 1267 | done: |
| 1265 | init_gendisk(hwif); | 1268 | blk_register_region(MKDEV(hwif->major, 0), MAX_DRIVES << PARTN_BITS, |
| 1266 | ide_acpi_init(hwif); | 1269 | THIS_MODULE, ata_probe, ata_lock, hwif); |
| 1267 | return 1; | 1270 | return 1; |
| 1268 | 1271 | ||
| 1269 | out: | 1272 | out: |
| @@ -1277,24 +1280,119 @@ static void hwif_register_devices(ide_hwif_t *hwif) | |||
| 1277 | 1280 | ||
| 1278 | for (i = 0; i < MAX_DRIVES; i++) { | 1281 | for (i = 0; i < MAX_DRIVES; i++) { |
| 1279 | ide_drive_t *drive = &hwif->drives[i]; | 1282 | ide_drive_t *drive = &hwif->drives[i]; |
| 1283 | struct device *dev = &drive->gendev; | ||
| 1284 | int ret; | ||
| 1280 | 1285 | ||
| 1281 | if (drive->present) { | 1286 | if (!drive->present) |
| 1282 | int ret = device_register(&drive->gendev); | 1287 | continue; |
| 1283 | 1288 | ||
| 1284 | if (ret < 0) | 1289 | ide_add_generic_settings(drive); |
| 1285 | printk(KERN_WARNING "IDE: %s: " | 1290 | |
| 1286 | "device_register error: %d\n", | 1291 | snprintf(dev->bus_id, BUS_ID_SIZE, "%u.%u", hwif->index, i); |
| 1287 | __FUNCTION__, ret); | 1292 | dev->parent = &hwif->gendev; |
| 1288 | } | 1293 | dev->bus = &ide_bus_type; |
| 1294 | dev->driver_data = drive; | ||
| 1295 | dev->release = drive_release_dev; | ||
| 1296 | |||
| 1297 | ret = device_register(dev); | ||
| 1298 | if (ret < 0) | ||
| 1299 | printk(KERN_WARNING "IDE: %s: device_register error: " | ||
| 1300 | "%d\n", __func__, ret); | ||
| 1301 | } | ||
| 1302 | } | ||
| 1303 | |||
| 1304 | static void ide_port_init_devices(ide_hwif_t *hwif) | ||
| 1305 | { | ||
| 1306 | int i; | ||
| 1307 | |||
| 1308 | for (i = 0; i < MAX_DRIVES; i++) { | ||
| 1309 | ide_drive_t *drive = &hwif->drives[i]; | ||
| 1310 | |||
| 1311 | if (hwif->host_flags & IDE_HFLAG_IO_32BIT) | ||
| 1312 | drive->io_32bit = 1; | ||
| 1313 | if (hwif->host_flags & IDE_HFLAG_UNMASK_IRQS) | ||
| 1314 | drive->unmask = 1; | ||
| 1315 | if (hwif->host_flags & IDE_HFLAG_NO_UNMASK_IRQS) | ||
| 1316 | drive->no_unmask = 1; | ||
| 1317 | if ((hwif->host_flags & IDE_HFLAG_NO_AUTOTUNE) == 0) | ||
| 1318 | drive->autotune = 1; | ||
| 1319 | } | ||
| 1320 | |||
| 1321 | if (hwif->port_init_devs) | ||
| 1322 | hwif->port_init_devs(hwif); | ||
| 1323 | } | ||
| 1324 | |||
| 1325 | static void ide_init_port(ide_hwif_t *hwif, unsigned int port, | ||
| 1326 | const struct ide_port_info *d) | ||
| 1327 | { | ||
| 1328 | if (d->chipset != ide_etrax100) | ||
| 1329 | hwif->channel = port; | ||
| 1330 | |||
| 1331 | if (d->chipset) | ||
| 1332 | hwif->chipset = d->chipset; | ||
| 1333 | |||
| 1334 | if (d->init_iops) | ||
| 1335 | d->init_iops(hwif); | ||
| 1336 | |||
| 1337 | if ((d->host_flags & IDE_HFLAG_NO_DMA) == 0) | ||
| 1338 | ide_hwif_setup_dma(hwif, d); | ||
| 1339 | |||
| 1340 | if ((!hwif->irq && (d->host_flags & IDE_HFLAG_LEGACY_IRQS)) || | ||
| 1341 | (d->host_flags & IDE_HFLAG_FORCE_LEGACY_IRQS)) | ||
| 1342 | hwif->irq = port ? 15 : 14; | ||
| 1343 | |||
| 1344 | hwif->host_flags = d->host_flags; | ||
| 1345 | hwif->pio_mask = d->pio_mask; | ||
| 1346 | |||
| 1347 | if ((d->host_flags & IDE_HFLAG_SERIALIZE) && hwif->mate) | ||
| 1348 | hwif->mate->serialized = hwif->serialized = 1; | ||
| 1349 | |||
| 1350 | hwif->swdma_mask = d->swdma_mask; | ||
| 1351 | hwif->mwdma_mask = d->mwdma_mask; | ||
| 1352 | hwif->ultra_mask = d->udma_mask; | ||
| 1353 | |||
| 1354 | /* reset DMA masks only for SFF-style DMA controllers */ | ||
| 1355 | if ((d->host_flags && IDE_HFLAG_NO_DMA) == 0 && hwif->dma_base == 0) | ||
| 1356 | hwif->swdma_mask = hwif->mwdma_mask = hwif->ultra_mask = 0; | ||
| 1357 | |||
| 1358 | if (d->host_flags & IDE_HFLAG_RQSIZE_256) | ||
| 1359 | hwif->rqsize = 256; | ||
| 1360 | |||
| 1361 | /* call chipset specific routine for each enabled port */ | ||
| 1362 | if (d->init_hwif) | ||
| 1363 | d->init_hwif(hwif); | ||
| 1364 | |||
| 1365 | if (hwif->cable_detect && (hwif->ultra_mask & 0x78)) { | ||
| 1366 | if (hwif->cbl != ATA_CBL_PATA40_SHORT) | ||
| 1367 | hwif->cbl = hwif->cable_detect(hwif); | ||
| 1289 | } | 1368 | } |
| 1290 | } | 1369 | } |
| 1291 | 1370 | ||
| 1292 | int ide_device_add_all(u8 *idx) | 1371 | int ide_device_add_all(u8 *idx, const struct ide_port_info *d) |
| 1293 | { | 1372 | { |
| 1294 | ide_hwif_t *hwif; | 1373 | ide_hwif_t *hwif, *mate = NULL; |
| 1295 | int i, rc = 0; | 1374 | int i, rc = 0; |
| 1296 | 1375 | ||
| 1297 | for (i = 0; i < MAX_HWIFS; i++) { | 1376 | for (i = 0; i < MAX_HWIFS; i++) { |
| 1377 | if (d == NULL || idx[i] == 0xff) { | ||
| 1378 | mate = NULL; | ||
| 1379 | continue; | ||
| 1380 | } | ||
| 1381 | |||
| 1382 | hwif = &ide_hwifs[idx[i]]; | ||
| 1383 | |||
| 1384 | if (d->chipset != ide_etrax100 && (i & 1) && mate) { | ||
| 1385 | hwif->mate = mate; | ||
| 1386 | mate->mate = hwif; | ||
| 1387 | } | ||
| 1388 | |||
| 1389 | mate = (i & 1) ? NULL : hwif; | ||
| 1390 | |||
| 1391 | ide_init_port(hwif, i & 1, d); | ||
| 1392 | ide_port_init_devices(hwif); | ||
| 1393 | } | ||
| 1394 | |||
| 1395 | for (i = 0; i < MAX_HWIFS; i++) { | ||
| 1298 | if (idx[i] == 0xff) | 1396 | if (idx[i] == 0xff) |
| 1299 | continue; | 1397 | continue; |
| 1300 | 1398 | ||
| @@ -1337,6 +1435,9 @@ int ide_device_add_all(u8 *idx) | |||
| 1337 | rc = -1; | 1435 | rc = -1; |
| 1338 | continue; | 1436 | continue; |
| 1339 | } | 1437 | } |
| 1438 | |||
| 1439 | ide_acpi_init(hwif); | ||
| 1440 | ide_acpi_port_init_devices(hwif); | ||
| 1340 | } | 1441 | } |
| 1341 | 1442 | ||
| 1342 | for (i = 0; i < MAX_HWIFS; i++) { | 1443 | for (i = 0; i < MAX_HWIFS; i++) { |
| @@ -1354,15 +1455,22 @@ int ide_device_add_all(u8 *idx) | |||
| 1354 | } | 1455 | } |
| 1355 | 1456 | ||
| 1356 | for (i = 0; i < MAX_HWIFS; i++) { | 1457 | for (i = 0; i < MAX_HWIFS; i++) { |
| 1357 | if (idx[i] != 0xff) | 1458 | if (idx[i] == 0xff) |
| 1358 | ide_proc_register_port(&ide_hwifs[idx[i]]); | 1459 | continue; |
| 1460 | |||
| 1461 | hwif = &ide_hwifs[idx[i]]; | ||
| 1462 | |||
| 1463 | if (hwif->present) { | ||
| 1464 | ide_proc_register_port(hwif); | ||
| 1465 | ide_proc_port_register_devices(hwif); | ||
| 1466 | } | ||
| 1359 | } | 1467 | } |
| 1360 | 1468 | ||
| 1361 | return rc; | 1469 | return rc; |
| 1362 | } | 1470 | } |
| 1363 | EXPORT_SYMBOL_GPL(ide_device_add_all); | 1471 | EXPORT_SYMBOL_GPL(ide_device_add_all); |
| 1364 | 1472 | ||
| 1365 | int ide_device_add(u8 idx[4]) | 1473 | int ide_device_add(u8 idx[4], const struct ide_port_info *d) |
| 1366 | { | 1474 | { |
| 1367 | u8 idx_all[MAX_HWIFS]; | 1475 | u8 idx_all[MAX_HWIFS]; |
| 1368 | int i; | 1476 | int i; |
| @@ -1370,6 +1478,6 @@ int ide_device_add(u8 idx[4]) | |||
| 1370 | for (i = 0; i < MAX_HWIFS; i++) | 1478 | for (i = 0; i < MAX_HWIFS; i++) |
| 1371 | idx_all[i] = (i < 4) ? idx[i] : 0xff; | 1479 | idx_all[i] = (i < 4) ? idx[i] : 0xff; |
| 1372 | 1480 | ||
| 1373 | return ide_device_add_all(idx_all); | 1481 | return ide_device_add_all(idx_all, d); |
| 1374 | } | 1482 | } |
| 1375 | EXPORT_SYMBOL_GPL(ide_device_add); | 1483 | EXPORT_SYMBOL_GPL(ide_device_add); |
diff --git a/drivers/ide/ide-proc.c b/drivers/ide/ide-proc.c index 00c249cba236..975c0ff0f438 100644 --- a/drivers/ide/ide-proc.c +++ b/drivers/ide/ide-proc.c | |||
| @@ -739,7 +739,7 @@ void ide_proc_unregister_driver(ide_drive_t *drive, ide_driver_t *driver) | |||
| 739 | 739 | ||
| 740 | EXPORT_SYMBOL(ide_proc_unregister_driver); | 740 | EXPORT_SYMBOL(ide_proc_unregister_driver); |
| 741 | 741 | ||
| 742 | static void create_proc_ide_drives(ide_hwif_t *hwif) | 742 | void ide_proc_port_register_devices(ide_hwif_t *hwif) |
| 743 | { | 743 | { |
| 744 | int d; | 744 | int d; |
| 745 | struct proc_dir_entry *ent; | 745 | struct proc_dir_entry *ent; |
| @@ -793,9 +793,6 @@ static ide_proc_entry_t hwif_entries[] = { | |||
| 793 | 793 | ||
| 794 | void ide_proc_register_port(ide_hwif_t *hwif) | 794 | void ide_proc_register_port(ide_hwif_t *hwif) |
| 795 | { | 795 | { |
| 796 | if (!hwif->present) | ||
| 797 | return; | ||
| 798 | |||
| 799 | if (!hwif->proc) { | 796 | if (!hwif->proc) { |
| 800 | hwif->proc = proc_mkdir(hwif->name, proc_ide_root); | 797 | hwif->proc = proc_mkdir(hwif->name, proc_ide_root); |
| 801 | 798 | ||
| @@ -804,8 +801,6 @@ void ide_proc_register_port(ide_hwif_t *hwif) | |||
| 804 | 801 | ||
| 805 | ide_add_proc_entries(hwif->proc, hwif_entries, hwif); | 802 | ide_add_proc_entries(hwif->proc, hwif_entries, hwif); |
| 806 | } | 803 | } |
| 807 | |||
| 808 | create_proc_ide_drives(hwif); | ||
| 809 | } | 804 | } |
| 810 | 805 | ||
| 811 | #ifdef CONFIG_BLK_DEV_IDEPCI | 806 | #ifdef CONFIG_BLK_DEV_IDEPCI |
diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c index 5aef63acf1e8..bf40d8c824ad 100644 --- a/drivers/ide/ide-tape.c +++ b/drivers/ide/ide-tape.c | |||
| @@ -1,424 +1,18 @@ | |||
| 1 | /* | 1 | /* |
| 2 | * IDE ATAPI streaming tape driver. | ||
| 3 | * | ||
| 2 | * Copyright (C) 1995-1999 Gadi Oxman <gadio@netvision.net.il> | 4 | * Copyright (C) 1995-1999 Gadi Oxman <gadio@netvision.net.il> |
| 3 | * Copyright (C) 2003-2005 Bartlomiej Zolnierkiewicz | 5 | * Copyright (C) 2003-2005 Bartlomiej Zolnierkiewicz |
| 4 | * | 6 | * |
| 5 | * $Header$ | ||
| 6 | * | ||
| 7 | * This driver was constructed as a student project in the software laboratory | 7 | * This driver was constructed as a student project in the software laboratory |
| 8 | * of the faculty of electrical engineering in the Technion - Israel's | 8 | * of the faculty of electrical engineering in the Technion - Israel's |
| 9 | * Institute Of Technology, with the guide of Avner Lottem and Dr. Ilana David. | 9 | * Institute Of Technology, with the guide of Avner Lottem and Dr. Ilana David. |
| 10 | * | 10 | * |
| 11 | * It is hereby placed under the terms of the GNU general public license. | 11 | * It is hereby placed under the terms of the GNU general public license. |
| 12 | * (See linux/COPYING). | 12 | * (See linux/COPYING). |
| 13 | */ | ||
| 14 | |||
| 15 | /* | ||
| 16 | * IDE ATAPI streaming tape driver. | ||
| 17 | * | ||
| 18 | * This driver is a part of the Linux ide driver and works in co-operation | ||
| 19 | * with linux/drivers/block/ide.c. | ||
| 20 | * | ||
| 21 | * The driver, in co-operation with ide.c, basically traverses the | ||
| 22 | * request-list for the block device interface. The character device | ||
| 23 | * interface, on the other hand, creates new requests, adds them | ||
| 24 | * to the request-list of the block device, and waits for their completion. | ||
| 25 | * | ||
| 26 | * Pipelined operation mode is now supported on both reads and writes. | ||
| 27 | * | ||
| 28 | * The block device major and minor numbers are determined from the | ||
| 29 | * tape's relative position in the ide interfaces, as explained in ide.c. | ||
| 30 | * | ||
| 31 | * The character device interface consists of the following devices: | ||
| 32 | * | ||
| 33 | * ht0 major 37, minor 0 first IDE tape, rewind on close. | ||
| 34 | * ht1 major 37, minor 1 second IDE tape, rewind on close. | ||
| 35 | * ... | ||
| 36 | * nht0 major 37, minor 128 first IDE tape, no rewind on close. | ||
| 37 | * nht1 major 37, minor 129 second IDE tape, no rewind on close. | ||
| 38 | * ... | ||
| 39 | * | ||
| 40 | * Run linux/scripts/MAKEDEV.ide to create the above entries. | ||
| 41 | * | ||
| 42 | * The general magnetic tape commands compatible interface, as defined by | ||
| 43 | * include/linux/mtio.h, is accessible through the character device. | ||
| 44 | * | ||
| 45 | * General ide driver configuration options, such as the interrupt-unmask | ||
| 46 | * flag, can be configured by issuing an ioctl to the block device interface, | ||
| 47 | * as any other ide device. | ||
| 48 | * | ||
| 49 | * Our own ide-tape ioctl's can be issued to either the block device or | ||
| 50 | * the character device interface. | ||
| 51 | * | ||
| 52 | * Maximal throughput with minimal bus load will usually be achieved in the | ||
| 53 | * following scenario: | ||
| 54 | * | ||
| 55 | * 1. ide-tape is operating in the pipelined operation mode. | ||
| 56 | * 2. No buffering is performed by the user backup program. | ||
| 57 | * | ||
| 58 | * Testing was done with a 2 GB CONNER CTMA 4000 IDE ATAPI Streaming Tape Drive. | ||
| 59 | * | ||
| 60 | * Ver 0.1 Nov 1 95 Pre-working code :-) | ||
| 61 | * Ver 0.2 Nov 23 95 A short backup (few megabytes) and restore procedure | ||
| 62 | * was successful ! (Using tar cvf ... on the block | ||
| 63 | * device interface). | ||
| 64 | * A longer backup resulted in major swapping, bad | ||
| 65 | * overall Linux performance and eventually failed as | ||
| 66 | * we received non serial read-ahead requests from the | ||
| 67 | * buffer cache. | ||
| 68 | * Ver 0.3 Nov 28 95 Long backups are now possible, thanks to the | ||
| 69 | * character device interface. Linux's responsiveness | ||
| 70 | * and performance doesn't seem to be much affected | ||
| 71 | * from the background backup procedure. | ||
| 72 | * Some general mtio.h magnetic tape operations are | ||
| 73 | * now supported by our character device. As a result, | ||
| 74 | * popular tape utilities are starting to work with | ||
| 75 | * ide tapes :-) | ||
| 76 | * The following configurations were tested: | ||
| 77 | * 1. An IDE ATAPI TAPE shares the same interface | ||
| 78 | * and irq with an IDE ATAPI CDROM. | ||
| 79 | * 2. An IDE ATAPI TAPE shares the same interface | ||
| 80 | * and irq with a normal IDE disk. | ||
| 81 | * Both configurations seemed to work just fine ! | ||
| 82 | * However, to be on the safe side, it is meanwhile | ||
| 83 | * recommended to give the IDE TAPE its own interface | ||
| 84 | * and irq. | ||
| 85 | * The one thing which needs to be done here is to | ||
| 86 | * add a "request postpone" feature to ide.c, | ||
| 87 | * so that we won't have to wait for the tape to finish | ||
| 88 | * performing a long media access (DSC) request (such | ||
| 89 | * as a rewind) before we can access the other device | ||
| 90 | * on the same interface. This effect doesn't disturb | ||
| 91 | * normal operation most of the time because read/write | ||
| 92 | * requests are relatively fast, and once we are | ||
| 93 | * performing one tape r/w request, a lot of requests | ||
| 94 | * from the other device can be queued and ide.c will | ||
| 95 | * service all of them after this single tape request. | ||
| 96 | * Ver 1.0 Dec 11 95 Integrated into Linux 1.3.46 development tree. | ||
| 97 | * On each read / write request, we now ask the drive | ||
| 98 | * if we can transfer a constant number of bytes | ||
| 99 | * (a parameter of the drive) only to its buffers, | ||
| 100 | * without causing actual media access. If we can't, | ||
| 101 | * we just wait until we can by polling the DSC bit. | ||
| 102 | * This ensures that while we are not transferring | ||
| 103 | * more bytes than the constant referred to above, the | ||
| 104 | * interrupt latency will not become too high and | ||
| 105 | * we won't cause an interrupt timeout, as happened | ||
| 106 | * occasionally in the previous version. | ||
| 107 | * While polling for DSC, the current request is | ||
| 108 | * postponed and ide.c is free to handle requests from | ||
| 109 | * the other device. This is handled transparently to | ||
| 110 | * ide.c. The hwgroup locking method which was used | ||
| 111 | * in the previous version was removed. | ||
| 112 | * Use of new general features which are provided by | ||
| 113 | * ide.c for use with atapi devices. | ||
| 114 | * (Programming done by Mark Lord) | ||
| 115 | * Few potential bug fixes (Again, suggested by Mark) | ||
| 116 | * Single character device data transfers are now | ||
| 117 | * not limited in size, as they were before. | ||
| 118 | * We are asking the tape about its recommended | ||
| 119 | * transfer unit and send a larger data transfer | ||
| 120 | * as several transfers of the above size. | ||
| 121 | * For best results, use an integral number of this | ||
| 122 | * basic unit (which is shown during driver | ||
| 123 | * initialization). I will soon add an ioctl to get | ||
| 124 | * this important parameter. | ||
| 125 | * Our data transfer buffer is allocated on startup, | ||
| 126 | * rather than before each data transfer. This should | ||
| 127 | * ensure that we will indeed have a data buffer. | ||
| 128 | * Ver 1.1 Dec 14 95 Fixed random problems which occurred when the tape | ||
| 129 | * shared an interface with another device. | ||
| 130 | * (poll_for_dsc was a complete mess). | ||
| 131 | * Removed some old (non-active) code which had | ||
| 132 | * to do with supporting buffer cache originated | ||
| 133 | * requests. | ||
| 134 | * The block device interface can now be opened, so | ||
| 135 | * that general ide driver features like the unmask | ||
| 136 | * interrupts flag can be selected with an ioctl. | ||
| 137 | * This is the only use of the block device interface. | ||
| 138 | * New fast pipelined operation mode (currently only on | ||
| 139 | * writes). When using the pipelined mode, the | ||
| 140 | * throughput can potentially reach the maximum | ||
| 141 | * tape supported throughput, regardless of the | ||
| 142 | * user backup program. On my tape drive, it sometimes | ||
| 143 | * boosted performance by a factor of 2. Pipelined | ||
| 144 | * mode is enabled by default, but since it has a few | ||
| 145 | * downfalls as well, you may want to disable it. | ||
| 146 | * A short explanation of the pipelined operation mode | ||
| 147 | * is available below. | ||
| 148 | * Ver 1.2 Jan 1 96 Eliminated pipelined mode race condition. | ||
| 149 | * Added pipeline read mode. As a result, restores | ||
| 150 | * are now as fast as backups. | ||
| 151 | * Optimized shared interface behavior. The new behavior | ||
| 152 | * typically results in better IDE bus efficiency and | ||
| 153 | * higher tape throughput. | ||
| 154 | * Pre-calculation of the expected read/write request | ||
| 155 | * service time, based on the tape's parameters. In | ||
| 156 | * the pipelined operation mode, this allows us to | ||
| 157 | * adjust our polling frequency to a much lower value, | ||
| 158 | * and thus to dramatically reduce our load on Linux, | ||
| 159 | * without any decrease in performance. | ||
| 160 | * Implemented additional mtio.h operations. | ||
| 161 | * The recommended user block size is returned by | ||
| 162 | * the MTIOCGET ioctl. | ||
| 163 | * Additional minor changes. | ||
| 164 | * Ver 1.3 Feb 9 96 Fixed pipelined read mode bug which prevented the | ||
| 165 | * use of some block sizes during a restore procedure. | ||
| 166 | * The character device interface will now present a | ||
| 167 | * continuous view of the media - any mix of block sizes | ||
| 168 | * during a backup/restore procedure is supported. The | ||
| 169 | * driver will buffer the requests internally and | ||
| 170 | * convert them to the tape's recommended transfer | ||
| 171 | * unit, making performance almost independent of the | ||
| 172 | * chosen user block size. | ||
| 173 | * Some improvements in error recovery. | ||
| 174 | * By cooperating with ide-dma.c, bus mastering DMA can | ||
| 175 | * now sometimes be used with IDE tape drives as well. | ||
| 176 | * Bus mastering DMA has the potential to dramatically | ||
| 177 | * reduce the CPU's overhead when accessing the device, | ||
| 178 | * and can be enabled by using hdparm -d1 on the tape's | ||
| 179 | * block device interface. For more info, read the | ||
| 180 | * comments in ide-dma.c. | ||
| 181 | * Ver 1.4 Mar 13 96 Fixed serialize support. | ||
| 182 | * Ver 1.5 Apr 12 96 Fixed shared interface operation, broken in 1.3.85. | ||
| 183 | * Fixed pipelined read mode inefficiency. | ||
| 184 | * Fixed nasty null dereferencing bug. | ||
| 185 | * Ver 1.6 Aug 16 96 Fixed FPU usage in the driver. | ||
| 186 | * Fixed end of media bug. | ||
| 187 | * Ver 1.7 Sep 10 96 Minor changes for the CONNER CTT8000-A model. | ||
| 188 | * Ver 1.8 Sep 26 96 Attempt to find a better balance between good | ||
| 189 | * interactive response and high system throughput. | ||
| 190 | * Ver 1.9 Nov 5 96 Automatically cross encountered filemarks rather | ||
| 191 | * than requiring an explicit FSF command. | ||
| 192 | * Abort pending requests at end of media. | ||
| 193 | * MTTELL was sometimes returning incorrect results. | ||
| 194 | * Return the real block size in the MTIOCGET ioctl. | ||
| 195 | * Some error recovery bug fixes. | ||
| 196 | * Ver 1.10 Nov 5 96 Major reorganization. | ||
| 197 | * Reduced CPU overhead a bit by eliminating internal | ||
| 198 | * bounce buffers. | ||
| 199 | * Added module support. | ||
| 200 | * Added multiple tape drives support. | ||
| 201 | * Added partition support. | ||
| 202 | * Rewrote DSC handling. | ||
| 203 | * Some portability fixes. | ||
| 204 | * Removed ide-tape.h. | ||
| 205 | * Additional minor changes. | ||
| 206 | * Ver 1.11 Dec 2 96 Bug fix in previous DSC timeout handling. | ||
| 207 | * Use ide_stall_queue() for DSC overlap. | ||
| 208 | * Use the maximum speed rather than the current speed | ||
| 209 | * to compute the request service time. | ||
| 210 | * Ver 1.12 Dec 7 97 Fix random memory overwriting and/or last block data | ||
| 211 | * corruption, which could occur if the total number | ||
| 212 | * of bytes written to the tape was not an integral | ||
| 213 | * number of tape blocks. | ||
| 214 | * Add support for INTERRUPT DRQ devices. | ||
| 215 | * Ver 1.13 Jan 2 98 Add "speed == 0" work-around for HP COLORADO 5GB | ||
| 216 | * Ver 1.14 Dec 30 98 Partial fixes for the Sony/AIWA tape drives. | ||
| 217 | * Replace cli()/sti() with hwgroup spinlocks. | ||
| 218 | * Ver 1.15 Mar 25 99 Fix SMP race condition by replacing hwgroup | ||
| 219 | * spinlock with private per-tape spinlock. | ||
| 220 | * Ver 1.16 Sep 1 99 Add OnStream tape support. | ||
| 221 | * Abort read pipeline on EOD. | ||
| 222 | * Wait for the tape to become ready in case it returns | ||
| 223 | * "in the process of becoming ready" on open(). | ||
| 224 | * Fix zero padding of the last written block in | ||
| 225 | * case the tape block size is larger than PAGE_SIZE. | ||
| 226 | * Decrease the default disconnection time to tn. | ||
| 227 | * Ver 1.16e Oct 3 99 Minor fixes. | ||
| 228 | * Ver 1.16e1 Oct 13 99 Patches by Arnold Niessen, | ||
| 229 | * niessen@iae.nl / arnold.niessen@philips.com | ||
| 230 | * GO-1) Undefined code in idetape_read_position | ||
| 231 | * according to Gadi's email | ||
| 232 | * AJN-1) Minor fix asc == 11 should be asc == 0x11 | ||
| 233 | * in idetape_issue_packet_command (did effect | ||
| 234 | * debugging output only) | ||
| 235 | * AJN-2) Added more debugging output, and | ||
| 236 | * added ide-tape: where missing. I would also | ||
| 237 | * like to add tape->name where possible | ||
| 238 | * AJN-3) Added different debug_level's | ||
| 239 | * via /proc/ide/hdc/settings | ||
| 240 | * "debug_level" determines amount of debugging output; | ||
| 241 | * can be changed using /proc/ide/hdx/settings | ||
| 242 | * 0 : almost no debugging output | ||
| 243 | * 1 : 0+output errors only | ||
| 244 | * 2 : 1+output all sensekey/asc | ||
| 245 | * 3 : 2+follow all chrdev related procedures | ||
| 246 | * 4 : 3+follow all procedures | ||
| 247 | * 5 : 4+include pc_stack rq_stack info | ||
| 248 | * 6 : 5+USE_COUNT updates | ||
| 249 | * AJN-4) Fixed timeout for retension in idetape_queue_pc_tail | ||
| 250 | * from 5 to 10 minutes | ||
| 251 | * AJN-5) Changed maximum number of blocks to skip when | ||
| 252 | * reading tapes with multiple consecutive write | ||
| 253 | * errors from 100 to 1000 in idetape_get_logical_blk | ||
| 254 | * Proposed changes to code: | ||
| 255 | * 1) output "logical_blk_num" via /proc | ||
| 256 | * 2) output "current_operation" via /proc | ||
| 257 | * 3) Either solve or document the fact that `mt rewind' is | ||
| 258 | * required after reading from /dev/nhtx to be | ||
| 259 | * able to rmmod the idetape module; | ||
| 260 | * Also, sometimes an application finishes but the | ||
| 261 | * device remains `busy' for some time. Same cause ? | ||
| 262 | * Proposed changes to release-notes: | ||
| 263 | * 4) write a simple `quickstart' section in the | ||
| 264 | * release notes; I volunteer if you don't want to | ||
| 265 | * 5) include a pointer to video4linux in the doc | ||
| 266 | * to stimulate video applications | ||
| 267 | * 6) release notes lines 331 and 362: explain what happens | ||
| 268 | * if the application data rate is higher than 1100 KB/s; | ||
| 269 | * similar approach to lower-than-500 kB/s ? | ||
| 270 | * 7) 6.6 Comparison; wouldn't it be better to allow different | ||
| 271 | * strategies for read and write ? | ||
| 272 | * Wouldn't it be better to control the tape buffer | ||
| 273 | * contents instead of the bandwidth ? | ||
| 274 | * 8) line 536: replace will by would (if I understand | ||
| 275 | * this section correctly, a hypothetical and unwanted situation | ||
| 276 | * is being described) | ||
| 277 | * Ver 1.16f Dec 15 99 Change place of the secondary OnStream header frames. | ||
| 278 | * Ver 1.17 Nov 2000 / Jan 2001 Marcel Mol, marcel@mesa.nl | ||
| 279 | * - Add idetape_onstream_mode_sense_tape_parameter_page | ||
| 280 | * function to get tape capacity in frames: tape->capacity. | ||
| 281 | * - Add support for DI-50 drives( or any DI- drive). | ||
| 282 | * - 'workaround' for read error/blank block around block 3000. | ||
| 283 | * - Implement Early warning for end of media for Onstream. | ||
| 284 | * - Cosmetic code changes for readability. | ||
| 285 | * - Idetape_position_tape should not use SKIP bit during | ||
| 286 | * Onstream read recovery. | ||
| 287 | * - Add capacity, logical_blk_num and first/last_frame_position | ||
| 288 | * to /proc/ide/hd?/settings. | ||
| 289 | * - Module use count was gone in the Linux 2.4 driver. | ||
| 290 | * Ver 1.17a Apr 2001 Willem Riede osst@riede.org | ||
| 291 | * - Get drive's actual block size from mode sense block descriptor | ||
| 292 | * - Limit size of pipeline | ||
| 293 | * Ver 1.17b Oct 2002 Alan Stern <stern@rowland.harvard.edu> | ||
| 294 | * Changed IDETAPE_MIN_PIPELINE_STAGES to 1 and actually used | ||
| 295 | * it in the code! | ||
| 296 | * Actually removed aborted stages in idetape_abort_pipeline | ||
| 297 | * instead of just changing the command code. | ||
| 298 | * Made the transfer byte count for Request Sense equal to the | ||
| 299 | * actual length of the data transfer. | ||
| 300 | * Changed handling of partial data transfers: they do not | ||
| 301 | * cause DMA errors. | ||
| 302 | * Moved initiation of DMA transfers to the correct place. | ||
| 303 | * Removed reference to unallocated memory. | ||
| 304 | * Made __idetape_discard_read_pipeline return the number of | ||
| 305 | * sectors skipped, not the number of stages. | ||
| 306 | * Replaced errant kfree() calls with __idetape_kfree_stage(). | ||
| 307 | * Fixed off-by-one error in testing the pipeline length. | ||
| 308 | * Fixed handling of filemarks in the read pipeline. | ||
| 309 | * Small code optimization for MTBSF and MTBSFM ioctls. | ||
| 310 | * Don't try to unlock the door during device close if is | ||
| 311 | * already unlocked! | ||
| 312 | * Cosmetic fixes to miscellaneous debugging output messages. | ||
| 313 | * Set the minimum /proc/ide/hd?/settings values for "pipeline", | ||
| 314 | * "pipeline_min", and "pipeline_max" to 1. | ||
| 315 | * | ||
| 316 | * Here are some words from the first releases of hd.c, which are quoted | ||
| 317 | * in ide.c and apply here as well: | ||
| 318 | * | ||
| 319 | * | Special care is recommended. Have Fun! | ||
| 320 | * | 13 | * |
| 321 | */ | 14 | * For a historical changelog see |
| 322 | 15 | * Documentation/ide/ChangeLog.ide-tape.1995-2002 | |
| 323 | /* | ||
| 324 | * An overview of the pipelined operation mode. | ||
| 325 | * | ||
| 326 | * In the pipelined write mode, we will usually just add requests to our | ||
| 327 | * pipeline and return immediately, before we even start to service them. The | ||
| 328 | * user program will then have enough time to prepare the next request while | ||
| 329 | * we are still busy servicing previous requests. In the pipelined read mode, | ||
| 330 | * the situation is similar - we add read-ahead requests into the pipeline, | ||
| 331 | * before the user even requested them. | ||
| 332 | * | ||
| 333 | * The pipeline can be viewed as a "safety net" which will be activated when | ||
| 334 | * the system load is high and prevents the user backup program from keeping up | ||
| 335 | * with the current tape speed. At this point, the pipeline will get | ||
| 336 | * shorter and shorter but the tape will still be streaming at the same speed. | ||
| 337 | * Assuming we have enough pipeline stages, the system load will hopefully | ||
| 338 | * decrease before the pipeline is completely empty, and the backup program | ||
| 339 | * will be able to "catch up" and refill the pipeline again. | ||
| 340 | * | ||
| 341 | * When using the pipelined mode, it would be best to disable any type of | ||
| 342 | * buffering done by the user program, as ide-tape already provides all the | ||
| 343 | * benefits in the kernel, where it can be done in a more efficient way. | ||
| 344 | * As we will usually not block the user program on a request, the most | ||
| 345 | * efficient user code will then be a simple read-write-read-... cycle. | ||
| 346 | * Any additional logic will usually just slow down the backup process. | ||
| 347 | * | ||
| 348 | * Using the pipelined mode, I get a constant over 400 KBps throughput, | ||
| 349 | * which seems to be the maximum throughput supported by my tape. | ||
| 350 | * | ||
| 351 | * However, there are some downfalls: | ||
| 352 | * | ||
| 353 | * 1. We use memory (for data buffers) in proportional to the number | ||
| 354 | * of pipeline stages (each stage is about 26 KB with my tape). | ||
| 355 | * 2. In the pipelined write mode, we cheat and postpone error codes | ||
| 356 | * to the user task. In read mode, the actual tape position | ||
| 357 | * will be a bit further than the last requested block. | ||
| 358 | * | ||
| 359 | * Concerning (1): | ||
| 360 | * | ||
| 361 | * 1. We allocate stages dynamically only when we need them. When | ||
| 362 | * we don't need them, we don't consume additional memory. In | ||
| 363 | * case we can't allocate stages, we just manage without them | ||
| 364 | * (at the expense of decreased throughput) so when Linux is | ||
| 365 | * tight in memory, we will not pose additional difficulties. | ||
| 366 | * | ||
| 367 | * 2. The maximum number of stages (which is, in fact, the maximum | ||
| 368 | * amount of memory) which we allocate is limited by the compile | ||
| 369 | * time parameter IDETAPE_MAX_PIPELINE_STAGES. | ||
| 370 | * | ||
| 371 | * 3. The maximum number of stages is a controlled parameter - We | ||
| 372 | * don't start from the user defined maximum number of stages | ||
| 373 | * but from the lower IDETAPE_MIN_PIPELINE_STAGES (again, we | ||
| 374 | * will not even allocate this amount of stages if the user | ||
| 375 | * program can't handle the speed). We then implement a feedback | ||
| 376 | * loop which checks if the pipeline is empty, and if it is, we | ||
| 377 | * increase the maximum number of stages as necessary until we | ||
| 378 | * reach the optimum value which just manages to keep the tape | ||
| 379 | * busy with minimum allocated memory or until we reach | ||
| 380 | * IDETAPE_MAX_PIPELINE_STAGES. | ||
| 381 | * | ||
| 382 | * Concerning (2): | ||
| 383 | * | ||
| 384 | * In pipelined write mode, ide-tape can not return accurate error codes | ||
| 385 | * to the user program since we usually just add the request to the | ||
| 386 | * pipeline without waiting for it to be serviced. In case an error | ||
| 387 | * occurs, I will report it on the next user request. | ||
| 388 | * | ||
| 389 | * In the pipelined read mode, subsequent read requests or forward | ||
| 390 | * filemark spacing will perform correctly, as we preserve all blocks | ||
| 391 | * and filemarks which we encountered during our excess read-ahead. | ||
| 392 | * | ||
| 393 | * For accurate tape positioning and error reporting, disabling | ||
| 394 | * pipelined mode might be the best option. | ||
| 395 | * | ||
| 396 | * You can enable/disable/tune the pipelined operation mode by adjusting | ||
| 397 | * the compile time parameters below. | ||
| 398 | */ | ||
| 399 | |||
| 400 | /* | ||
| 401 | * Possible improvements. | ||
| 402 | * | ||
| 403 | * 1. Support for the ATAPI overlap protocol. | ||
| 404 | * | ||
| 405 | * In order to maximize bus throughput, we currently use the DSC | ||
| 406 | * overlap method which enables ide.c to service requests from the | ||
| 407 | * other device while the tape is busy executing a command. The | ||
| 408 | * DSC overlap method involves polling the tape's status register | ||
| 409 | * for the DSC bit, and servicing the other device while the tape | ||
| 410 | * isn't ready. | ||
| 411 | * | ||
| 412 | * In the current QIC development standard (December 1995), | ||
| 413 | * it is recommended that new tape drives will *in addition* | ||
| 414 | * implement the ATAPI overlap protocol, which is used for the | ||
| 415 | * same purpose - efficient use of the IDE bus, but is interrupt | ||
| 416 | * driven and thus has much less CPU overhead. | ||
| 417 | * | ||
| 418 | * ATAPI overlap is likely to be supported in most new ATAPI | ||
| 419 | * devices, including new ATAPI cdroms, and thus provides us | ||
| 420 | * a method by which we can achieve higher throughput when | ||
| 421 | * sharing a (fast) ATA-2 disk with any (slow) new ATAPI device. | ||
| 422 | */ | 16 | */ |
| 423 | 17 | ||
| 424 | #define IDETAPE_VERSION "1.19" | 18 | #define IDETAPE_VERSION "1.19" |
| @@ -442,49 +36,13 @@ | |||
| 442 | #include <linux/completion.h> | 36 | #include <linux/completion.h> |
| 443 | #include <linux/bitops.h> | 37 | #include <linux/bitops.h> |
| 444 | #include <linux/mutex.h> | 38 | #include <linux/mutex.h> |
| 39 | #include <scsi/scsi.h> | ||
| 445 | 40 | ||
| 446 | #include <asm/byteorder.h> | 41 | #include <asm/byteorder.h> |
| 447 | #include <asm/irq.h> | 42 | #include <asm/irq.h> |
| 448 | #include <asm/uaccess.h> | 43 | #include <asm/uaccess.h> |
| 449 | #include <asm/io.h> | 44 | #include <asm/io.h> |
| 450 | #include <asm/unaligned.h> | 45 | #include <asm/unaligned.h> |
| 451 | |||
| 452 | /* | ||
| 453 | * partition | ||
| 454 | */ | ||
| 455 | typedef struct os_partition_s { | ||
| 456 | __u8 partition_num; | ||
| 457 | __u8 par_desc_ver; | ||
| 458 | __u16 wrt_pass_cntr; | ||
| 459 | __u32 first_frame_addr; | ||
| 460 | __u32 last_frame_addr; | ||
| 461 | __u32 eod_frame_addr; | ||
| 462 | } os_partition_t; | ||
| 463 | |||
| 464 | /* | ||
| 465 | * DAT entry | ||
| 466 | */ | ||
| 467 | typedef struct os_dat_entry_s { | ||
| 468 | __u32 blk_sz; | ||
| 469 | __u16 blk_cnt; | ||
| 470 | __u8 flags; | ||
| 471 | __u8 reserved; | ||
| 472 | } os_dat_entry_t; | ||
| 473 | |||
| 474 | /* | ||
| 475 | * DAT | ||
| 476 | */ | ||
| 477 | #define OS_DAT_FLAGS_DATA (0xc) | ||
| 478 | #define OS_DAT_FLAGS_MARK (0x1) | ||
| 479 | |||
| 480 | typedef struct os_dat_s { | ||
| 481 | __u8 dat_sz; | ||
| 482 | __u8 reserved1; | ||
| 483 | __u8 entry_cnt; | ||
| 484 | __u8 reserved3; | ||
| 485 | os_dat_entry_t dat_list[16]; | ||
| 486 | } os_dat_t; | ||
| 487 | |||
| 488 | #include <linux/mtio.h> | 46 | #include <linux/mtio.h> |
| 489 | 47 | ||
| 490 | /**************************** Tunable parameters *****************************/ | 48 | /**************************** Tunable parameters *****************************/ |
| @@ -512,10 +70,7 @@ typedef struct os_dat_s { | |||
| 512 | /* | 70 | /* |
| 513 | * The following are used to debug the driver: | 71 | * The following are used to debug the driver: |
| 514 | * | 72 | * |
| 515 | * Setting IDETAPE_DEBUG_INFO to 1 will report device capabilities. | ||
| 516 | * Setting IDETAPE_DEBUG_LOG to 1 will log driver flow control. | 73 | * Setting IDETAPE_DEBUG_LOG to 1 will log driver flow control. |
| 517 | * Setting IDETAPE_DEBUG_BUGS to 1 will enable self-sanity checks in | ||
| 518 | * some places. | ||
| 519 | * | 74 | * |
| 520 | * Setting them to 0 will restore normal operation mode: | 75 | * Setting them to 0 will restore normal operation mode: |
| 521 | * | 76 | * |
| @@ -527,9 +82,7 @@ typedef struct os_dat_s { | |||
| 527 | * is verified to be stable enough. This will make it much more | 82 | * is verified to be stable enough. This will make it much more |
| 528 | * esthetic. | 83 | * esthetic. |
| 529 | */ | 84 | */ |
| 530 | #define IDETAPE_DEBUG_INFO 0 | ||
| 531 | #define IDETAPE_DEBUG_LOG 0 | 85 | #define IDETAPE_DEBUG_LOG 0 |
| 532 | #define IDETAPE_DEBUG_BUGS 1 | ||
| 533 | 86 | ||
| 534 | /* | 87 | /* |
| 535 | * After each failed packet command we issue a request sense command | 88 | * After each failed packet command we issue a request sense command |
| @@ -671,65 +224,6 @@ typedef struct idetape_packet_command_s { | |||
| 671 | #define PC_WRITING 5 | 224 | #define PC_WRITING 5 |
| 672 | 225 | ||
| 673 | /* | 226 | /* |
| 674 | * Capabilities and Mechanical Status Page | ||
| 675 | */ | ||
| 676 | typedef struct { | ||
| 677 | unsigned page_code :6; /* Page code - Should be 0x2a */ | ||
| 678 | __u8 reserved0_6 :1; | ||
| 679 | __u8 ps :1; /* parameters saveable */ | ||
| 680 | __u8 page_length; /* Page Length - Should be 0x12 */ | ||
| 681 | __u8 reserved2, reserved3; | ||
| 682 | unsigned ro :1; /* Read Only Mode */ | ||
| 683 | unsigned reserved4_1234 :4; | ||
| 684 | unsigned sprev :1; /* Supports SPACE in the reverse direction */ | ||
| 685 | unsigned reserved4_67 :2; | ||
| 686 | unsigned reserved5_012 :3; | ||
| 687 | unsigned efmt :1; /* Supports ERASE command initiated formatting */ | ||
| 688 | unsigned reserved5_4 :1; | ||
| 689 | unsigned qfa :1; /* Supports the QFA two partition formats */ | ||
| 690 | unsigned reserved5_67 :2; | ||
| 691 | unsigned lock :1; /* Supports locking the volume */ | ||
| 692 | unsigned locked :1; /* The volume is locked */ | ||
| 693 | unsigned prevent :1; /* The device defaults in the prevent state after power up */ | ||
| 694 | unsigned eject :1; /* The device can eject the volume */ | ||
| 695 | __u8 disconnect :1; /* The device can break request > ctl */ | ||
| 696 | __u8 reserved6_5 :1; | ||
| 697 | unsigned ecc :1; /* Supports error correction */ | ||
| 698 | unsigned cmprs :1; /* Supports data compression */ | ||
| 699 | unsigned reserved7_0 :1; | ||
| 700 | unsigned blk512 :1; /* Supports 512 bytes block size */ | ||
| 701 | unsigned blk1024 :1; /* Supports 1024 bytes block size */ | ||
| 702 | unsigned reserved7_3_6 :4; | ||
| 703 | unsigned blk32768 :1; /* slowb - the device restricts the byte count for PIO */ | ||
| 704 | /* transfers for slow buffer memory ??? */ | ||
| 705 | /* Also 32768 block size in some cases */ | ||
| 706 | __u16 max_speed; /* Maximum speed supported in KBps */ | ||
| 707 | __u8 reserved10, reserved11; | ||
| 708 | __u16 ctl; /* Continuous Transfer Limit in blocks */ | ||
| 709 | __u16 speed; /* Current Speed, in KBps */ | ||
| 710 | __u16 buffer_size; /* Buffer Size, in 512 bytes */ | ||
| 711 | __u8 reserved18, reserved19; | ||
| 712 | } idetape_capabilities_page_t; | ||
| 713 | |||
| 714 | /* | ||
| 715 | * Block Size Page | ||
| 716 | */ | ||
| 717 | typedef struct { | ||
| 718 | unsigned page_code :6; /* Page code - Should be 0x30 */ | ||
| 719 | unsigned reserved1_6 :1; | ||
| 720 | unsigned ps :1; | ||
| 721 | __u8 page_length; /* Page Length - Should be 2 */ | ||
| 722 | __u8 reserved2; | ||
| 723 | unsigned play32 :1; | ||
| 724 | unsigned play32_5 :1; | ||
| 725 | unsigned reserved2_23 :2; | ||
| 726 | unsigned record32 :1; | ||
| 727 | unsigned record32_5 :1; | ||
| 728 | unsigned reserved2_6 :1; | ||
| 729 | unsigned one :1; | ||
| 730 | } idetape_block_size_page_t; | ||
| 731 | |||
| 732 | /* | ||
| 733 | * A pipeline stage. | 227 | * A pipeline stage. |
| 734 | */ | 228 | */ |
| 735 | typedef struct idetape_stage_s { | 229 | typedef struct idetape_stage_s { |
| @@ -739,32 +233,6 @@ typedef struct idetape_stage_s { | |||
| 739 | } idetape_stage_t; | 233 | } idetape_stage_t; |
| 740 | 234 | ||
| 741 | /* | 235 | /* |
| 742 | * REQUEST SENSE packet command result - Data Format. | ||
| 743 | */ | ||
| 744 | typedef struct { | ||
| 745 | unsigned error_code :7; /* Current of deferred errors */ | ||
| 746 | unsigned valid :1; /* The information field conforms to QIC-157C */ | ||
| 747 | __u8 reserved1 :8; /* Segment Number - Reserved */ | ||
| 748 | unsigned sense_key :4; /* Sense Key */ | ||
| 749 | unsigned reserved2_4 :1; /* Reserved */ | ||
| 750 | unsigned ili :1; /* Incorrect Length Indicator */ | ||
| 751 | unsigned eom :1; /* End Of Medium */ | ||
| 752 | unsigned filemark :1; /* Filemark */ | ||
| 753 | __u32 information __attribute__ ((packed)); | ||
| 754 | __u8 asl; /* Additional sense length (n-7) */ | ||
| 755 | __u32 command_specific; /* Additional command specific information */ | ||
| 756 | __u8 asc; /* Additional Sense Code */ | ||
| 757 | __u8 ascq; /* Additional Sense Code Qualifier */ | ||
| 758 | __u8 replaceable_unit_code; /* Field Replaceable Unit Code */ | ||
| 759 | unsigned sk_specific1 :7; /* Sense Key Specific */ | ||
| 760 | unsigned sksv :1; /* Sense Key Specific information is valid */ | ||
| 761 | __u8 sk_specific2; /* Sense Key Specific */ | ||
| 762 | __u8 sk_specific3; /* Sense Key Specific */ | ||
| 763 | __u8 pad[2]; /* Padding to 20 bytes */ | ||
| 764 | } idetape_request_sense_result_t; | ||
| 765 | |||
| 766 | |||
| 767 | /* | ||
| 768 | * Most of our global data which we need to save even as we leave the | 236 | * Most of our global data which we need to save even as we leave the |
| 769 | * driver due to an interrupt or a timer event is stored in a variable | 237 | * driver due to an interrupt or a timer event is stored in a variable |
| 770 | * of type idetape_tape_t, defined below. | 238 | * of type idetape_tape_t, defined below. |
| @@ -854,8 +322,9 @@ typedef struct ide_tape_obj { | |||
| 854 | /* Usually 512 or 1024 bytes */ | 322 | /* Usually 512 or 1024 bytes */ |
| 855 | unsigned short tape_block_size; | 323 | unsigned short tape_block_size; |
| 856 | int user_bs_factor; | 324 | int user_bs_factor; |
| 325 | |||
| 857 | /* Copy of the tape's Capabilities and Mechanical Page */ | 326 | /* Copy of the tape's Capabilities and Mechanical Page */ |
| 858 | idetape_capabilities_page_t capabilities; | 327 | u8 caps[20]; |
| 859 | 328 | ||
| 860 | /* | 329 | /* |
| 861 | * Active data transfer request parameters. | 330 | * Active data transfer request parameters. |
| @@ -918,9 +387,6 @@ typedef struct ide_tape_obj { | |||
| 918 | int avg_size; | 387 | int avg_size; |
| 919 | int avg_speed; | 388 | int avg_speed; |
| 920 | 389 | ||
| 921 | /* last sense information */ | ||
| 922 | idetape_request_sense_result_t sense; | ||
| 923 | |||
| 924 | char vendor_id[10]; | 390 | char vendor_id[10]; |
| 925 | char product_id[18]; | 391 | char product_id[18]; |
| 926 | char firmware_revision[6]; | 392 | char firmware_revision[6]; |
| @@ -1052,27 +518,6 @@ static void ide_tape_put(struct ide_tape_obj *tape) | |||
| 1052 | #define IDETAPE_MEDIUM_PRESENT 9 | 518 | #define IDETAPE_MEDIUM_PRESENT 9 |
| 1053 | 519 | ||
| 1054 | /* | 520 | /* |
| 1055 | * Supported ATAPI tape drives packet commands | ||
| 1056 | */ | ||
| 1057 | #define IDETAPE_TEST_UNIT_READY_CMD 0x00 | ||
| 1058 | #define IDETAPE_REWIND_CMD 0x01 | ||
| 1059 | #define IDETAPE_REQUEST_SENSE_CMD 0x03 | ||
| 1060 | #define IDETAPE_READ_CMD 0x08 | ||
| 1061 | #define IDETAPE_WRITE_CMD 0x0a | ||
| 1062 | #define IDETAPE_WRITE_FILEMARK_CMD 0x10 | ||
| 1063 | #define IDETAPE_SPACE_CMD 0x11 | ||
| 1064 | #define IDETAPE_INQUIRY_CMD 0x12 | ||
| 1065 | #define IDETAPE_ERASE_CMD 0x19 | ||
| 1066 | #define IDETAPE_MODE_SENSE_CMD 0x1a | ||
| 1067 | #define IDETAPE_MODE_SELECT_CMD 0x15 | ||
| 1068 | #define IDETAPE_LOAD_UNLOAD_CMD 0x1b | ||
| 1069 | #define IDETAPE_PREVENT_CMD 0x1e | ||
| 1070 | #define IDETAPE_LOCATE_CMD 0x2b | ||
| 1071 | #define IDETAPE_READ_POSITION_CMD 0x34 | ||
| 1072 | #define IDETAPE_READ_BUFFER_CMD 0x3c | ||
| 1073 | #define IDETAPE_SET_SPEED_CMD 0xbb | ||
| 1074 | |||
| 1075 | /* | ||
| 1076 | * Some defines for the READ BUFFER command | 521 | * Some defines for the READ BUFFER command |
| 1077 | */ | 522 | */ |
| 1078 | #define IDETAPE_RETRIEVE_FAULTY_BLOCK 6 | 523 | #define IDETAPE_RETRIEVE_FAULTY_BLOCK 6 |
| @@ -1129,31 +574,6 @@ struct idetape_id_gcw { | |||
| 1129 | }; | 574 | }; |
| 1130 | 575 | ||
| 1131 | /* | 576 | /* |
| 1132 | * INQUIRY packet command - Data Format (From Table 6-8 of QIC-157C) | ||
| 1133 | */ | ||
| 1134 | typedef struct { | ||
| 1135 | unsigned device_type :5; /* Peripheral Device Type */ | ||
| 1136 | unsigned reserved0_765 :3; /* Peripheral Qualifier - Reserved */ | ||
| 1137 | unsigned reserved1_6t0 :7; /* Reserved */ | ||
| 1138 | unsigned rmb :1; /* Removable Medium Bit */ | ||
| 1139 | unsigned ansi_version :3; /* ANSI Version */ | ||
| 1140 | unsigned ecma_version :3; /* ECMA Version */ | ||
| 1141 | unsigned iso_version :2; /* ISO Version */ | ||
| 1142 | unsigned response_format :4; /* Response Data Format */ | ||
| 1143 | unsigned reserved3_45 :2; /* Reserved */ | ||
| 1144 | unsigned reserved3_6 :1; /* TrmIOP - Reserved */ | ||
| 1145 | unsigned reserved3_7 :1; /* AENC - Reserved */ | ||
| 1146 | __u8 additional_length; /* Additional Length (total_length-4) */ | ||
| 1147 | __u8 rsv5, rsv6, rsv7; /* Reserved */ | ||
| 1148 | __u8 vendor_id[8]; /* Vendor Identification */ | ||
| 1149 | __u8 product_id[16]; /* Product Identification */ | ||
| 1150 | __u8 revision_level[4]; /* Revision Level */ | ||
| 1151 | __u8 vendor_specific[20]; /* Vendor Specific - Optional */ | ||
| 1152 | __u8 reserved56t95[40]; /* Reserved - Optional */ | ||
| 1153 | /* Additional information may be returned */ | ||
| 1154 | } idetape_inquiry_result_t; | ||
| 1155 | |||
| 1156 | /* | ||
| 1157 | * READ POSITION packet command - Data Format (From Table 6-57) | 577 | * READ POSITION packet command - Data Format (From Table 6-57) |
| 1158 | */ | 578 | */ |
| 1159 | typedef struct { | 579 | typedef struct { |
| @@ -1171,100 +591,9 @@ typedef struct { | |||
| 1171 | u32 bytes_in_buffer; /* Bytes In Buffer (Optional) */ | 591 | u32 bytes_in_buffer; /* Bytes In Buffer (Optional) */ |
| 1172 | } idetape_read_position_result_t; | 592 | } idetape_read_position_result_t; |
| 1173 | 593 | ||
| 1174 | /* | 594 | /* Structures related to the SELECT SENSE / MODE SENSE packet commands. */ |
| 1175 | * Follows structures which are related to the SELECT SENSE / MODE SENSE | ||
| 1176 | * packet commands. Those packet commands are still not supported | ||
| 1177 | * by ide-tape. | ||
| 1178 | */ | ||
| 1179 | #define IDETAPE_BLOCK_DESCRIPTOR 0 | 595 | #define IDETAPE_BLOCK_DESCRIPTOR 0 |
| 1180 | #define IDETAPE_CAPABILITIES_PAGE 0x2a | 596 | #define IDETAPE_CAPABILITIES_PAGE 0x2a |
| 1181 | #define IDETAPE_PARAMTR_PAGE 0x2b /* Onstream DI-x0 only */ | ||
| 1182 | #define IDETAPE_BLOCK_SIZE_PAGE 0x30 | ||
| 1183 | #define IDETAPE_BUFFER_FILLING_PAGE 0x33 | ||
| 1184 | |||
| 1185 | /* | ||
| 1186 | * Mode Parameter Header for the MODE SENSE packet command | ||
| 1187 | */ | ||
| 1188 | typedef struct { | ||
| 1189 | __u8 mode_data_length; /* Length of the following data transfer */ | ||
| 1190 | __u8 medium_type; /* Medium Type */ | ||
| 1191 | __u8 dsp; /* Device Specific Parameter */ | ||
| 1192 | __u8 bdl; /* Block Descriptor Length */ | ||
| 1193 | #if 0 | ||
| 1194 | /* data transfer page */ | ||
| 1195 | __u8 page_code :6; | ||
| 1196 | __u8 reserved0_6 :1; | ||
| 1197 | __u8 ps :1; /* parameters saveable */ | ||
| 1198 | __u8 page_length; /* page Length == 0x02 */ | ||
| 1199 | __u8 reserved2; | ||
| 1200 | __u8 read32k :1; /* 32k blk size (data only) */ | ||
| 1201 | __u8 read32k5 :1; /* 32.5k blk size (data&AUX) */ | ||
| 1202 | __u8 reserved3_23 :2; | ||
| 1203 | __u8 write32k :1; /* 32k blk size (data only) */ | ||
| 1204 | __u8 write32k5 :1; /* 32.5k blk size (data&AUX) */ | ||
| 1205 | __u8 reserved3_6 :1; | ||
| 1206 | __u8 streaming :1; /* streaming mode enable */ | ||
| 1207 | #endif | ||
| 1208 | } idetape_mode_parameter_header_t; | ||
| 1209 | |||
| 1210 | /* | ||
| 1211 | * Mode Parameter Block Descriptor the MODE SENSE packet command | ||
| 1212 | * | ||
| 1213 | * Support for block descriptors is optional. | ||
| 1214 | */ | ||
| 1215 | typedef struct { | ||
| 1216 | __u8 density_code; /* Medium density code */ | ||
| 1217 | __u8 blocks[3]; /* Number of blocks */ | ||
| 1218 | __u8 reserved4; /* Reserved */ | ||
| 1219 | __u8 length[3]; /* Block Length */ | ||
| 1220 | } idetape_parameter_block_descriptor_t; | ||
| 1221 | |||
| 1222 | /* | ||
| 1223 | * The Data Compression Page, as returned by the MODE SENSE packet command. | ||
| 1224 | */ | ||
| 1225 | typedef struct { | ||
| 1226 | unsigned page_code :6; /* Page Code - Should be 0xf */ | ||
| 1227 | unsigned reserved0 :1; /* Reserved */ | ||
| 1228 | unsigned ps :1; | ||
| 1229 | __u8 page_length; /* Page Length - Should be 14 */ | ||
| 1230 | unsigned reserved2 :6; /* Reserved */ | ||
| 1231 | unsigned dcc :1; /* Data Compression Capable */ | ||
| 1232 | unsigned dce :1; /* Data Compression Enable */ | ||
| 1233 | unsigned reserved3 :5; /* Reserved */ | ||
| 1234 | unsigned red :2; /* Report Exception on Decompression */ | ||
| 1235 | unsigned dde :1; /* Data Decompression Enable */ | ||
| 1236 | __u32 ca; /* Compression Algorithm */ | ||
| 1237 | __u32 da; /* Decompression Algorithm */ | ||
| 1238 | __u8 reserved[4]; /* Reserved */ | ||
| 1239 | } idetape_data_compression_page_t; | ||
| 1240 | |||
| 1241 | /* | ||
| 1242 | * The Medium Partition Page, as returned by the MODE SENSE packet command. | ||
| 1243 | */ | ||
| 1244 | typedef struct { | ||
| 1245 | unsigned page_code :6; /* Page Code - Should be 0x11 */ | ||
| 1246 | unsigned reserved1_6 :1; /* Reserved */ | ||
| 1247 | unsigned ps :1; | ||
| 1248 | __u8 page_length; /* Page Length - Should be 6 */ | ||
| 1249 | __u8 map; /* Maximum Additional Partitions - Should be 0 */ | ||
| 1250 | __u8 apd; /* Additional Partitions Defined - Should be 0 */ | ||
| 1251 | unsigned reserved4_012 :3; /* Reserved */ | ||
| 1252 | unsigned psum :2; /* Should be 0 */ | ||
| 1253 | unsigned idp :1; /* Should be 0 */ | ||
| 1254 | unsigned sdp :1; /* Should be 0 */ | ||
| 1255 | unsigned fdp :1; /* Fixed Data Partitions */ | ||
| 1256 | __u8 mfr; /* Medium Format Recognition */ | ||
| 1257 | __u8 reserved[2]; /* Reserved */ | ||
| 1258 | } idetape_medium_partition_page_t; | ||
| 1259 | |||
| 1260 | /* | ||
| 1261 | * Run time configurable parameters. | ||
| 1262 | */ | ||
| 1263 | typedef struct { | ||
| 1264 | int dsc_rw_frequency; | ||
| 1265 | int dsc_media_access_frequency; | ||
| 1266 | int nr_stages; | ||
| 1267 | } idetape_config_t; | ||
| 1268 | 597 | ||
| 1269 | /* | 598 | /* |
| 1270 | * The variables below are used for the character device interface. | 599 | * The variables below are used for the character device interface. |
| @@ -1309,14 +638,12 @@ static void idetape_input_buffers (ide_drive_t *drive, idetape_pc_t *pc, unsigne | |||
| 1309 | int count; | 638 | int count; |
| 1310 | 639 | ||
| 1311 | while (bcount) { | 640 | while (bcount) { |
| 1312 | #if IDETAPE_DEBUG_BUGS | ||
| 1313 | if (bh == NULL) { | 641 | if (bh == NULL) { |
| 1314 | printk(KERN_ERR "ide-tape: bh == NULL in " | 642 | printk(KERN_ERR "ide-tape: bh == NULL in " |
| 1315 | "idetape_input_buffers\n"); | 643 | "idetape_input_buffers\n"); |
| 1316 | idetape_discard_data(drive, bcount); | 644 | idetape_discard_data(drive, bcount); |
| 1317 | return; | 645 | return; |
| 1318 | } | 646 | } |
| 1319 | #endif /* IDETAPE_DEBUG_BUGS */ | ||
| 1320 | count = min((unsigned int)(bh->b_size - atomic_read(&bh->b_count)), bcount); | 647 | count = min((unsigned int)(bh->b_size - atomic_read(&bh->b_count)), bcount); |
| 1321 | HWIF(drive)->atapi_input_bytes(drive, bh->b_data + atomic_read(&bh->b_count), count); | 648 | HWIF(drive)->atapi_input_bytes(drive, bh->b_data + atomic_read(&bh->b_count), count); |
| 1322 | bcount -= count; | 649 | bcount -= count; |
| @@ -1336,13 +663,11 @@ static void idetape_output_buffers (ide_drive_t *drive, idetape_pc_t *pc, unsign | |||
| 1336 | int count; | 663 | int count; |
| 1337 | 664 | ||
| 1338 | while (bcount) { | 665 | while (bcount) { |
| 1339 | #if IDETAPE_DEBUG_BUGS | ||
| 1340 | if (bh == NULL) { | 666 | if (bh == NULL) { |
| 1341 | printk(KERN_ERR "ide-tape: bh == NULL in " | 667 | printk(KERN_ERR "ide-tape: bh == NULL in " |
| 1342 | "idetape_output_buffers\n"); | 668 | "idetape_output_buffers\n"); |
| 1343 | return; | 669 | return; |
| 1344 | } | 670 | } |
| 1345 | #endif /* IDETAPE_DEBUG_BUGS */ | ||
| 1346 | count = min((unsigned int)pc->b_count, (unsigned int)bcount); | 671 | count = min((unsigned int)pc->b_count, (unsigned int)bcount); |
| 1347 | HWIF(drive)->atapi_output_bytes(drive, pc->b_data, count); | 672 | HWIF(drive)->atapi_output_bytes(drive, pc->b_data, count); |
| 1348 | bcount -= count; | 673 | bcount -= count; |
| @@ -1367,13 +692,11 @@ static void idetape_update_buffers (idetape_pc_t *pc) | |||
| 1367 | if (test_bit(PC_WRITING, &pc->flags)) | 692 | if (test_bit(PC_WRITING, &pc->flags)) |
| 1368 | return; | 693 | return; |
| 1369 | while (bcount) { | 694 | while (bcount) { |
| 1370 | #if IDETAPE_DEBUG_BUGS | ||
| 1371 | if (bh == NULL) { | 695 | if (bh == NULL) { |
| 1372 | printk(KERN_ERR "ide-tape: bh == NULL in " | 696 | printk(KERN_ERR "ide-tape: bh == NULL in " |
| 1373 | "idetape_update_buffers\n"); | 697 | "idetape_update_buffers\n"); |
| 1374 | return; | 698 | return; |
| 1375 | } | 699 | } |
| 1376 | #endif /* IDETAPE_DEBUG_BUGS */ | ||
| 1377 | count = min((unsigned int)bh->b_size, (unsigned int)bcount); | 700 | count = min((unsigned int)bh->b_size, (unsigned int)bcount); |
| 1378 | atomic_set(&bh->b_count, count); | 701 | atomic_set(&bh->b_count, count); |
| 1379 | if (atomic_read(&bh->b_count) == bh->b_size) | 702 | if (atomic_read(&bh->b_count) == bh->b_size) |
| @@ -1446,36 +769,34 @@ static void idetape_init_pc (idetape_pc_t *pc) | |||
| 1446 | } | 769 | } |
| 1447 | 770 | ||
| 1448 | /* | 771 | /* |
| 1449 | * idetape_analyze_error is called on each failed packet command retry | 772 | * called on each failed packet command retry to analyze the request sense. We |
| 1450 | * to analyze the request sense. We currently do not utilize this | 773 | * currently do not utilize this information. |
| 1451 | * information. | ||
| 1452 | */ | 774 | */ |
| 1453 | static void idetape_analyze_error (ide_drive_t *drive, idetape_request_sense_result_t *result) | 775 | static void idetape_analyze_error(ide_drive_t *drive, u8 *sense) |
| 1454 | { | 776 | { |
| 1455 | idetape_tape_t *tape = drive->driver_data; | 777 | idetape_tape_t *tape = drive->driver_data; |
| 1456 | idetape_pc_t *pc = tape->failed_pc; | 778 | idetape_pc_t *pc = tape->failed_pc; |
| 1457 | 779 | ||
| 1458 | tape->sense = *result; | 780 | tape->sense_key = sense[2] & 0xF; |
| 1459 | tape->sense_key = result->sense_key; | 781 | tape->asc = sense[12]; |
| 1460 | tape->asc = result->asc; | 782 | tape->ascq = sense[13]; |
| 1461 | tape->ascq = result->ascq; | ||
| 1462 | #if IDETAPE_DEBUG_LOG | 783 | #if IDETAPE_DEBUG_LOG |
| 1463 | /* | 784 | /* |
| 1464 | * Without debugging, we only log an error if we decided to | 785 | * Without debugging, we only log an error if we decided to give up |
| 1465 | * give up retrying. | 786 | * retrying. |
| 1466 | */ | 787 | */ |
| 1467 | if (tape->debug_level >= 1) | 788 | if (tape->debug_level >= 1) |
| 1468 | printk(KERN_INFO "ide-tape: pc = %x, sense key = %x, " | 789 | printk(KERN_INFO "ide-tape: pc = %x, sense key = %x, " |
| 1469 | "asc = %x, ascq = %x\n", | 790 | "asc = %x, ascq = %x\n", |
| 1470 | pc->c[0], result->sense_key, | 791 | pc->c[0], tape->sense_key, |
| 1471 | result->asc, result->ascq); | 792 | tape->asc, tape->ascq); |
| 1472 | #endif /* IDETAPE_DEBUG_LOG */ | 793 | #endif /* IDETAPE_DEBUG_LOG */ |
| 1473 | 794 | ||
| 1474 | /* | 795 | /* Correct pc->actually_transferred by asking the tape. */ |
| 1475 | * Correct pc->actually_transferred by asking the tape. | ||
| 1476 | */ | ||
| 1477 | if (test_bit(PC_DMA_ERROR, &pc->flags)) { | 796 | if (test_bit(PC_DMA_ERROR, &pc->flags)) { |
| 1478 | pc->actually_transferred = pc->request_transfer - tape->tape_block_size * ntohl(get_unaligned(&result->information)); | 797 | pc->actually_transferred = pc->request_transfer - |
| 798 | tape->tape_block_size * | ||
| 799 | be32_to_cpu(get_unaligned((u32 *)&sense[3])); | ||
| 1479 | idetape_update_buffers(pc); | 800 | idetape_update_buffers(pc); |
| 1480 | } | 801 | } |
| 1481 | 802 | ||
| @@ -1484,29 +805,29 @@ static void idetape_analyze_error (ide_drive_t *drive, idetape_request_sense_res | |||
| 1484 | * with sense key=5, asc=0x22, ascq=0, let it slide. Some drives | 805 | * with sense key=5, asc=0x22, ascq=0, let it slide. Some drives |
| 1485 | * (i.e. Seagate STT3401A Travan) don't support 0-length read/writes. | 806 | * (i.e. Seagate STT3401A Travan) don't support 0-length read/writes. |
| 1486 | */ | 807 | */ |
| 1487 | if ((pc->c[0] == IDETAPE_READ_CMD || pc->c[0] == IDETAPE_WRITE_CMD) | 808 | if ((pc->c[0] == READ_6 || pc->c[0] == WRITE_6) |
| 1488 | && pc->c[4] == 0 && pc->c[3] == 0 && pc->c[2] == 0) { /* length==0 */ | 809 | /* length == 0 */ |
| 1489 | if (result->sense_key == 5) { | 810 | && pc->c[4] == 0 && pc->c[3] == 0 && pc->c[2] == 0) { |
| 811 | if (tape->sense_key == 5) { | ||
| 1490 | /* don't report an error, everything's ok */ | 812 | /* don't report an error, everything's ok */ |
| 1491 | pc->error = 0; | 813 | pc->error = 0; |
| 1492 | /* don't retry read/write */ | 814 | /* don't retry read/write */ |
| 1493 | set_bit(PC_ABORT, &pc->flags); | 815 | set_bit(PC_ABORT, &pc->flags); |
| 1494 | } | 816 | } |
| 1495 | } | 817 | } |
| 1496 | if (pc->c[0] == IDETAPE_READ_CMD && result->filemark) { | 818 | if (pc->c[0] == READ_6 && (sense[2] & 0x80)) { |
| 1497 | pc->error = IDETAPE_ERROR_FILEMARK; | 819 | pc->error = IDETAPE_ERROR_FILEMARK; |
| 1498 | set_bit(PC_ABORT, &pc->flags); | 820 | set_bit(PC_ABORT, &pc->flags); |
| 1499 | } | 821 | } |
| 1500 | if (pc->c[0] == IDETAPE_WRITE_CMD) { | 822 | if (pc->c[0] == WRITE_6) { |
| 1501 | if (result->eom || | 823 | if ((sense[2] & 0x40) || (tape->sense_key == 0xd |
| 1502 | (result->sense_key == 0xd && result->asc == 0x0 && | 824 | && tape->asc == 0x0 && tape->ascq == 0x2)) { |
| 1503 | result->ascq == 0x2)) { | ||
| 1504 | pc->error = IDETAPE_ERROR_EOD; | 825 | pc->error = IDETAPE_ERROR_EOD; |
| 1505 | set_bit(PC_ABORT, &pc->flags); | 826 | set_bit(PC_ABORT, &pc->flags); |
| 1506 | } | 827 | } |
| 1507 | } | 828 | } |
| 1508 | if (pc->c[0] == IDETAPE_READ_CMD || pc->c[0] == IDETAPE_WRITE_CMD) { | 829 | if (pc->c[0] == READ_6 || pc->c[0] == WRITE_6) { |
| 1509 | if (result->sense_key == 8) { | 830 | if (tape->sense_key == 8) { |
| 1510 | pc->error = IDETAPE_ERROR_EOD; | 831 | pc->error = IDETAPE_ERROR_EOD; |
| 1511 | set_bit(PC_ABORT, &pc->flags); | 832 | set_bit(PC_ABORT, &pc->flags); |
| 1512 | } | 833 | } |
| @@ -1516,10 +837,7 @@ static void idetape_analyze_error (ide_drive_t *drive, idetape_request_sense_res | |||
| 1516 | } | 837 | } |
| 1517 | } | 838 | } |
| 1518 | 839 | ||
| 1519 | /* | 840 | static void idetape_activate_next_stage(ide_drive_t *drive) |
| 1520 | * idetape_active_next_stage will declare the next stage as "active". | ||
| 1521 | */ | ||
| 1522 | static void idetape_active_next_stage (ide_drive_t *drive) | ||
| 1523 | { | 841 | { |
| 1524 | idetape_tape_t *tape = drive->driver_data; | 842 | idetape_tape_t *tape = drive->driver_data; |
| 1525 | idetape_stage_t *stage = tape->next_stage; | 843 | idetape_stage_t *stage = tape->next_stage; |
| @@ -1529,12 +847,10 @@ static void idetape_active_next_stage (ide_drive_t *drive) | |||
| 1529 | if (tape->debug_level >= 4) | 847 | if (tape->debug_level >= 4) |
| 1530 | printk(KERN_INFO "ide-tape: Reached idetape_active_next_stage\n"); | 848 | printk(KERN_INFO "ide-tape: Reached idetape_active_next_stage\n"); |
| 1531 | #endif /* IDETAPE_DEBUG_LOG */ | 849 | #endif /* IDETAPE_DEBUG_LOG */ |
| 1532 | #if IDETAPE_DEBUG_BUGS | ||
| 1533 | if (stage == NULL) { | 850 | if (stage == NULL) { |
| 1534 | printk(KERN_ERR "ide-tape: bug: Trying to activate a non existing stage\n"); | 851 | printk(KERN_ERR "ide-tape: bug: Trying to activate a non existing stage\n"); |
| 1535 | return; | 852 | return; |
| 1536 | } | 853 | } |
| 1537 | #endif /* IDETAPE_DEBUG_BUGS */ | ||
| 1538 | 854 | ||
| 1539 | rq->rq_disk = tape->disk; | 855 | rq->rq_disk = tape->disk; |
| 1540 | rq->buffer = NULL; | 856 | rq->buffer = NULL; |
| @@ -1609,28 +925,24 @@ static void idetape_remove_stage_head (ide_drive_t *drive) | |||
| 1609 | if (tape->debug_level >= 4) | 925 | if (tape->debug_level >= 4) |
| 1610 | printk(KERN_INFO "ide-tape: Reached idetape_remove_stage_head\n"); | 926 | printk(KERN_INFO "ide-tape: Reached idetape_remove_stage_head\n"); |
| 1611 | #endif /* IDETAPE_DEBUG_LOG */ | 927 | #endif /* IDETAPE_DEBUG_LOG */ |
| 1612 | #if IDETAPE_DEBUG_BUGS | ||
| 1613 | if (tape->first_stage == NULL) { | 928 | if (tape->first_stage == NULL) { |
| 1614 | printk(KERN_ERR "ide-tape: bug: tape->first_stage is NULL\n"); | 929 | printk(KERN_ERR "ide-tape: bug: tape->first_stage is NULL\n"); |
| 1615 | return; | 930 | return; |
| 1616 | } | 931 | } |
| 1617 | if (tape->active_stage == tape->first_stage) { | 932 | if (tape->active_stage == tape->first_stage) { |
| 1618 | printk(KERN_ERR "ide-tape: bug: Trying to free our active pipeline stage\n"); | 933 | printk(KERN_ERR "ide-tape: bug: Trying to free our active pipeline stage\n"); |
| 1619 | return; | 934 | return; |
| 1620 | } | 935 | } |
| 1621 | #endif /* IDETAPE_DEBUG_BUGS */ | ||
| 1622 | stage = tape->first_stage; | 936 | stage = tape->first_stage; |
| 1623 | tape->first_stage = stage->next; | 937 | tape->first_stage = stage->next; |
| 1624 | idetape_kfree_stage(tape, stage); | 938 | idetape_kfree_stage(tape, stage); |
| 1625 | tape->nr_stages--; | 939 | tape->nr_stages--; |
| 1626 | if (tape->first_stage == NULL) { | 940 | if (tape->first_stage == NULL) { |
| 1627 | tape->last_stage = NULL; | 941 | tape->last_stage = NULL; |
| 1628 | #if IDETAPE_DEBUG_BUGS | ||
| 1629 | if (tape->next_stage != NULL) | 942 | if (tape->next_stage != NULL) |
| 1630 | printk(KERN_ERR "ide-tape: bug: tape->next_stage != NULL\n"); | 943 | printk(KERN_ERR "ide-tape: bug: tape->next_stage != NULL\n"); |
| 1631 | if (tape->nr_stages) | 944 | if (tape->nr_stages) |
| 1632 | printk(KERN_ERR "ide-tape: bug: nr_stages should be 0 now\n"); | 945 | printk(KERN_ERR "ide-tape: bug: nr_stages should be 0 now\n"); |
| 1633 | #endif /* IDETAPE_DEBUG_BUGS */ | ||
| 1634 | } | 946 | } |
| 1635 | } | 947 | } |
| 1636 | 948 | ||
| @@ -1716,7 +1028,7 @@ static int idetape_end_request(ide_drive_t *drive, int uptodate, int nr_sects) | |||
| 1716 | } | 1028 | } |
| 1717 | } | 1029 | } |
| 1718 | if (tape->next_stage != NULL) { | 1030 | if (tape->next_stage != NULL) { |
| 1719 | idetape_active_next_stage(drive); | 1031 | idetape_activate_next_stage(drive); |
| 1720 | 1032 | ||
| 1721 | /* | 1033 | /* |
| 1722 | * Insert the next request into the request queue. | 1034 | * Insert the next request into the request queue. |
| @@ -1748,7 +1060,7 @@ static ide_startstop_t idetape_request_sense_callback (ide_drive_t *drive) | |||
| 1748 | printk(KERN_INFO "ide-tape: Reached idetape_request_sense_callback\n"); | 1060 | printk(KERN_INFO "ide-tape: Reached idetape_request_sense_callback\n"); |
| 1749 | #endif /* IDETAPE_DEBUG_LOG */ | 1061 | #endif /* IDETAPE_DEBUG_LOG */ |
| 1750 | if (!tape->pc->error) { | 1062 | if (!tape->pc->error) { |
| 1751 | idetape_analyze_error(drive, (idetape_request_sense_result_t *) tape->pc->buffer); | 1063 | idetape_analyze_error(drive, tape->pc->buffer); |
| 1752 | idetape_end_request(drive, 1, 0); | 1064 | idetape_end_request(drive, 1, 0); |
| 1753 | } else { | 1065 | } else { |
| 1754 | printk(KERN_ERR "ide-tape: Error in REQUEST SENSE itself - Aborting request!\n"); | 1066 | printk(KERN_ERR "ide-tape: Error in REQUEST SENSE itself - Aborting request!\n"); |
| @@ -1760,7 +1072,7 @@ static ide_startstop_t idetape_request_sense_callback (ide_drive_t *drive) | |||
| 1760 | static void idetape_create_request_sense_cmd (idetape_pc_t *pc) | 1072 | static void idetape_create_request_sense_cmd (idetape_pc_t *pc) |
| 1761 | { | 1073 | { |
| 1762 | idetape_init_pc(pc); | 1074 | idetape_init_pc(pc); |
| 1763 | pc->c[0] = IDETAPE_REQUEST_SENSE_CMD; | 1075 | pc->c[0] = REQUEST_SENSE; |
| 1764 | pc->c[4] = 20; | 1076 | pc->c[4] = 20; |
| 1765 | pc->request_transfer = 20; | 1077 | pc->request_transfer = 20; |
| 1766 | pc->callback = &idetape_request_sense_callback; | 1078 | pc->callback = &idetape_request_sense_callback; |
| @@ -1913,15 +1225,14 @@ static ide_startstop_t idetape_pc_intr (ide_drive_t *drive) | |||
| 1913 | local_irq_enable(); | 1225 | local_irq_enable(); |
| 1914 | 1226 | ||
| 1915 | #if SIMULATE_ERRORS | 1227 | #if SIMULATE_ERRORS |
| 1916 | if ((pc->c[0] == IDETAPE_WRITE_CMD || | 1228 | if ((pc->c[0] == WRITE_6 || pc->c[0] == READ_6) && |
| 1917 | pc->c[0] == IDETAPE_READ_CMD) && | ||
| 1918 | (++error_sim_count % 100) == 0) { | 1229 | (++error_sim_count % 100) == 0) { |
| 1919 | printk(KERN_INFO "ide-tape: %s: simulating error\n", | 1230 | printk(KERN_INFO "ide-tape: %s: simulating error\n", |
| 1920 | tape->name); | 1231 | tape->name); |
| 1921 | stat |= ERR_STAT; | 1232 | stat |= ERR_STAT; |
| 1922 | } | 1233 | } |
| 1923 | #endif | 1234 | #endif |
| 1924 | if ((stat & ERR_STAT) && pc->c[0] == IDETAPE_REQUEST_SENSE_CMD) | 1235 | if ((stat & ERR_STAT) && pc->c[0] == REQUEST_SENSE) |
| 1925 | stat &= ~ERR_STAT; | 1236 | stat &= ~ERR_STAT; |
| 1926 | if ((stat & ERR_STAT) || test_bit(PC_DMA_ERROR, &pc->flags)) { | 1237 | if ((stat & ERR_STAT) || test_bit(PC_DMA_ERROR, &pc->flags)) { |
| 1927 | /* Error detected */ | 1238 | /* Error detected */ |
| @@ -1930,7 +1241,7 @@ static ide_startstop_t idetape_pc_intr (ide_drive_t *drive) | |||
| 1930 | printk(KERN_INFO "ide-tape: %s: I/O error\n", | 1241 | printk(KERN_INFO "ide-tape: %s: I/O error\n", |
| 1931 | tape->name); | 1242 | tape->name); |
| 1932 | #endif /* IDETAPE_DEBUG_LOG */ | 1243 | #endif /* IDETAPE_DEBUG_LOG */ |
| 1933 | if (pc->c[0] == IDETAPE_REQUEST_SENSE_CMD) { | 1244 | if (pc->c[0] == REQUEST_SENSE) { |
| 1934 | printk(KERN_ERR "ide-tape: I/O error in request sense command\n"); | 1245 | printk(KERN_ERR "ide-tape: I/O error in request sense command\n"); |
| 1935 | return ide_do_reset(drive); | 1246 | return ide_do_reset(drive); |
| 1936 | } | 1247 | } |
| @@ -2118,15 +1429,13 @@ static ide_startstop_t idetape_issue_packet_command (ide_drive_t *drive, idetape | |||
| 2118 | int dma_ok = 0; | 1429 | int dma_ok = 0; |
| 2119 | u16 bcount; | 1430 | u16 bcount; |
| 2120 | 1431 | ||
| 2121 | #if IDETAPE_DEBUG_BUGS | 1432 | if (tape->pc->c[0] == REQUEST_SENSE && |
| 2122 | if (tape->pc->c[0] == IDETAPE_REQUEST_SENSE_CMD && | 1433 | pc->c[0] == REQUEST_SENSE) { |
| 2123 | pc->c[0] == IDETAPE_REQUEST_SENSE_CMD) { | ||
| 2124 | printk(KERN_ERR "ide-tape: possible ide-tape.c bug - " | 1434 | printk(KERN_ERR "ide-tape: possible ide-tape.c bug - " |
| 2125 | "Two request sense in serial were issued\n"); | 1435 | "Two request sense in serial were issued\n"); |
| 2126 | } | 1436 | } |
| 2127 | #endif /* IDETAPE_DEBUG_BUGS */ | ||
| 2128 | 1437 | ||
| 2129 | if (tape->failed_pc == NULL && pc->c[0] != IDETAPE_REQUEST_SENSE_CMD) | 1438 | if (tape->failed_pc == NULL && pc->c[0] != REQUEST_SENSE) |
| 2130 | tape->failed_pc = pc; | 1439 | tape->failed_pc = pc; |
| 2131 | /* Set the current packet command */ | 1440 | /* Set the current packet command */ |
| 2132 | tape->pc = pc; | 1441 | tape->pc = pc; |
| @@ -2139,7 +1448,7 @@ static ide_startstop_t idetape_issue_packet_command (ide_drive_t *drive, idetape | |||
| 2139 | * filemark, or end of the media, for example). | 1448 | * filemark, or end of the media, for example). |
| 2140 | */ | 1449 | */ |
| 2141 | if (!test_bit(PC_ABORT, &pc->flags)) { | 1450 | if (!test_bit(PC_ABORT, &pc->flags)) { |
| 2142 | if (!(pc->c[0] == IDETAPE_TEST_UNIT_READY_CMD && | 1451 | if (!(pc->c[0] == TEST_UNIT_READY && |
| 2143 | tape->sense_key == 2 && tape->asc == 4 && | 1452 | tape->sense_key == 2 && tape->asc == 4 && |
| 2144 | (tape->ascq == 1 || tape->ascq == 8))) { | 1453 | (tape->ascq == 1 || tape->ascq == 8))) { |
| 2145 | printk(KERN_ERR "ide-tape: %s: I/O error, " | 1454 | printk(KERN_ERR "ide-tape: %s: I/O error, " |
| @@ -2181,8 +1490,8 @@ static ide_startstop_t idetape_issue_packet_command (ide_drive_t *drive, idetape | |||
| 2181 | if (dma_ok) /* Will begin DMA later */ | 1490 | if (dma_ok) /* Will begin DMA later */ |
| 2182 | set_bit(PC_DMA_IN_PROGRESS, &pc->flags); | 1491 | set_bit(PC_DMA_IN_PROGRESS, &pc->flags); |
| 2183 | if (test_bit(IDETAPE_DRQ_INTERRUPT, &tape->flags)) { | 1492 | if (test_bit(IDETAPE_DRQ_INTERRUPT, &tape->flags)) { |
| 2184 | ide_set_handler(drive, &idetape_transfer_pc, IDETAPE_WAIT_CMD, NULL); | 1493 | ide_execute_command(drive, WIN_PACKETCMD, &idetape_transfer_pc, |
| 2185 | hwif->OUTB(WIN_PACKETCMD, IDE_COMMAND_REG); | 1494 | IDETAPE_WAIT_CMD, NULL); |
| 2186 | return ide_started; | 1495 | return ide_started; |
| 2187 | } else { | 1496 | } else { |
| 2188 | hwif->OUTB(WIN_PACKETCMD, IDE_COMMAND_REG); | 1497 | hwif->OUTB(WIN_PACKETCMD, IDE_COMMAND_REG); |
| @@ -2212,7 +1521,7 @@ static ide_startstop_t idetape_pc_callback (ide_drive_t *drive) | |||
| 2212 | static void idetape_create_mode_sense_cmd (idetape_pc_t *pc, u8 page_code) | 1521 | static void idetape_create_mode_sense_cmd (idetape_pc_t *pc, u8 page_code) |
| 2213 | { | 1522 | { |
| 2214 | idetape_init_pc(pc); | 1523 | idetape_init_pc(pc); |
| 2215 | pc->c[0] = IDETAPE_MODE_SENSE_CMD; | 1524 | pc->c[0] = MODE_SENSE; |
| 2216 | if (page_code != IDETAPE_BLOCK_DESCRIPTOR) | 1525 | if (page_code != IDETAPE_BLOCK_DESCRIPTOR) |
| 2217 | pc->c[1] = 8; /* DBD = 1 - Don't return block descriptors */ | 1526 | pc->c[1] = 8; /* DBD = 1 - Don't return block descriptors */ |
| 2218 | pc->c[2] = page_code; | 1527 | pc->c[2] = page_code; |
| @@ -2293,7 +1602,7 @@ static ide_startstop_t idetape_media_access_finished (ide_drive_t *drive) | |||
| 2293 | if (stat & SEEK_STAT) { | 1602 | if (stat & SEEK_STAT) { |
| 2294 | if (stat & ERR_STAT) { | 1603 | if (stat & ERR_STAT) { |
| 2295 | /* Error detected */ | 1604 | /* Error detected */ |
| 2296 | if (pc->c[0] != IDETAPE_TEST_UNIT_READY_CMD) | 1605 | if (pc->c[0] != TEST_UNIT_READY) |
| 2297 | printk(KERN_ERR "ide-tape: %s: I/O error, ", | 1606 | printk(KERN_ERR "ide-tape: %s: I/O error, ", |
| 2298 | tape->name); | 1607 | tape->name); |
| 2299 | /* Retry operation */ | 1608 | /* Retry operation */ |
| @@ -2350,8 +1659,8 @@ static ide_startstop_t idetape_rw_callback (ide_drive_t *drive) | |||
| 2350 | static void idetape_create_read_cmd(idetape_tape_t *tape, idetape_pc_t *pc, unsigned int length, struct idetape_bh *bh) | 1659 | static void idetape_create_read_cmd(idetape_tape_t *tape, idetape_pc_t *pc, unsigned int length, struct idetape_bh *bh) |
| 2351 | { | 1660 | { |
| 2352 | idetape_init_pc(pc); | 1661 | idetape_init_pc(pc); |
| 2353 | pc->c[0] = IDETAPE_READ_CMD; | 1662 | pc->c[0] = READ_6; |
| 2354 | put_unaligned(htonl(length), (unsigned int *) &pc->c[1]); | 1663 | put_unaligned(cpu_to_be32(length), (unsigned int *) &pc->c[1]); |
| 2355 | pc->c[1] = 1; | 1664 | pc->c[1] = 1; |
| 2356 | pc->callback = &idetape_rw_callback; | 1665 | pc->callback = &idetape_rw_callback; |
| 2357 | pc->bh = bh; | 1666 | pc->bh = bh; |
| @@ -2368,7 +1677,7 @@ static void idetape_create_read_buffer_cmd(idetape_tape_t *tape, idetape_pc_t *p | |||
| 2368 | struct idetape_bh *p = bh; | 1677 | struct idetape_bh *p = bh; |
| 2369 | 1678 | ||
| 2370 | idetape_init_pc(pc); | 1679 | idetape_init_pc(pc); |
| 2371 | pc->c[0] = IDETAPE_READ_BUFFER_CMD; | 1680 | pc->c[0] = READ_BUFFER; |
| 2372 | pc->c[1] = IDETAPE_RETRIEVE_FAULTY_BLOCK; | 1681 | pc->c[1] = IDETAPE_RETRIEVE_FAULTY_BLOCK; |
| 2373 | pc->c[7] = size >> 8; | 1682 | pc->c[7] = size >> 8; |
| 2374 | pc->c[8] = size & 0xff; | 1683 | pc->c[8] = size & 0xff; |
| @@ -2386,8 +1695,8 @@ static void idetape_create_read_buffer_cmd(idetape_tape_t *tape, idetape_pc_t *p | |||
| 2386 | static void idetape_create_write_cmd(idetape_tape_t *tape, idetape_pc_t *pc, unsigned int length, struct idetape_bh *bh) | 1695 | static void idetape_create_write_cmd(idetape_tape_t *tape, idetape_pc_t *pc, unsigned int length, struct idetape_bh *bh) |
| 2387 | { | 1696 | { |
| 2388 | idetape_init_pc(pc); | 1697 | idetape_init_pc(pc); |
| 2389 | pc->c[0] = IDETAPE_WRITE_CMD; | 1698 | pc->c[0] = WRITE_6; |
| 2390 | put_unaligned(htonl(length), (unsigned int *) &pc->c[1]); | 1699 | put_unaligned(cpu_to_be32(length), (unsigned int *) &pc->c[1]); |
| 2391 | pc->c[1] = 1; | 1700 | pc->c[1] = 1; |
| 2392 | pc->callback = &idetape_rw_callback; | 1701 | pc->callback = &idetape_rw_callback; |
| 2393 | set_bit(PC_WRITING, &pc->flags); | 1702 | set_bit(PC_WRITING, &pc->flags); |
| @@ -2412,12 +1721,6 @@ static ide_startstop_t idetape_do_request(ide_drive_t *drive, | |||
| 2412 | u8 stat; | 1721 | u8 stat; |
| 2413 | 1722 | ||
| 2414 | #if IDETAPE_DEBUG_LOG | 1723 | #if IDETAPE_DEBUG_LOG |
| 2415 | #if 0 | ||
| 2416 | if (tape->debug_level >= 5) | ||
| 2417 | printk(KERN_INFO "ide-tape: %d, " | ||
| 2418 | "dev: %s, cmd: %ld, errors: %d\n", | ||
| 2419 | rq->rq_disk->disk_name, rq->cmd[0], rq->errors); | ||
| 2420 | #endif | ||
| 2421 | if (tape->debug_level >= 2) | 1724 | if (tape->debug_level >= 2) |
| 2422 | printk(KERN_INFO "ide-tape: sector: %ld, " | 1725 | printk(KERN_INFO "ide-tape: sector: %ld, " |
| 2423 | "nr_sectors: %ld, current_nr_sectors: %d\n", | 1726 | "nr_sectors: %ld, current_nr_sectors: %d\n", |
| @@ -2438,10 +1741,9 @@ static ide_startstop_t idetape_do_request(ide_drive_t *drive, | |||
| 2438 | * Retry a failed packet command | 1741 | * Retry a failed packet command |
| 2439 | */ | 1742 | */ |
| 2440 | if (tape->failed_pc != NULL && | 1743 | if (tape->failed_pc != NULL && |
| 2441 | tape->pc->c[0] == IDETAPE_REQUEST_SENSE_CMD) { | 1744 | tape->pc->c[0] == REQUEST_SENSE) { |
| 2442 | return idetape_issue_packet_command(drive, tape->failed_pc); | 1745 | return idetape_issue_packet_command(drive, tape->failed_pc); |
| 2443 | } | 1746 | } |
| 2444 | #if IDETAPE_DEBUG_BUGS | ||
| 2445 | if (postponed_rq != NULL) | 1747 | if (postponed_rq != NULL) |
| 2446 | if (rq != postponed_rq) { | 1748 | if (rq != postponed_rq) { |
| 2447 | printk(KERN_ERR "ide-tape: ide-tape.c bug - " | 1749 | printk(KERN_ERR "ide-tape: ide-tape.c bug - " |
| @@ -2449,7 +1751,6 @@ static ide_startstop_t idetape_do_request(ide_drive_t *drive, | |||
| 2449 | idetape_end_request(drive, 0, 0); | 1751 | idetape_end_request(drive, 0, 0); |
| 2450 | return ide_stopped; | 1752 | return ide_stopped; |
| 2451 | } | 1753 | } |
| 2452 | #endif /* IDETAPE_DEBUG_BUGS */ | ||
| 2453 | 1754 | ||
| 2454 | tape->postponed_rq = NULL; | 1755 | tape->postponed_rq = NULL; |
| 2455 | 1756 | ||
| @@ -2636,13 +1937,11 @@ static int idetape_copy_stage_from_user (idetape_tape_t *tape, idetape_stage_t * | |||
| 2636 | int ret = 0; | 1937 | int ret = 0; |
| 2637 | 1938 | ||
| 2638 | while (n) { | 1939 | while (n) { |
| 2639 | #if IDETAPE_DEBUG_BUGS | ||
| 2640 | if (bh == NULL) { | 1940 | if (bh == NULL) { |
| 2641 | printk(KERN_ERR "ide-tape: bh == NULL in " | 1941 | printk(KERN_ERR "ide-tape: bh == NULL in " |
| 2642 | "idetape_copy_stage_from_user\n"); | 1942 | "idetape_copy_stage_from_user\n"); |
| 2643 | return 1; | 1943 | return 1; |
| 2644 | } | 1944 | } |
| 2645 | #endif /* IDETAPE_DEBUG_BUGS */ | ||
| 2646 | count = min((unsigned int)(bh->b_size - atomic_read(&bh->b_count)), (unsigned int)n); | 1945 | count = min((unsigned int)(bh->b_size - atomic_read(&bh->b_count)), (unsigned int)n); |
| 2647 | if (copy_from_user(bh->b_data + atomic_read(&bh->b_count), buf, count)) | 1946 | if (copy_from_user(bh->b_data + atomic_read(&bh->b_count), buf, count)) |
| 2648 | ret = 1; | 1947 | ret = 1; |
| @@ -2666,13 +1965,11 @@ static int idetape_copy_stage_to_user (idetape_tape_t *tape, char __user *buf, i | |||
| 2666 | int ret = 0; | 1965 | int ret = 0; |
| 2667 | 1966 | ||
| 2668 | while (n) { | 1967 | while (n) { |
| 2669 | #if IDETAPE_DEBUG_BUGS | ||
| 2670 | if (bh == NULL) { | 1968 | if (bh == NULL) { |
| 2671 | printk(KERN_ERR "ide-tape: bh == NULL in " | 1969 | printk(KERN_ERR "ide-tape: bh == NULL in " |
| 2672 | "idetape_copy_stage_to_user\n"); | 1970 | "idetape_copy_stage_to_user\n"); |
| 2673 | return 1; | 1971 | return 1; |
| 2674 | } | 1972 | } |
| 2675 | #endif /* IDETAPE_DEBUG_BUGS */ | ||
| 2676 | count = min(tape->b_count, n); | 1973 | count = min(tape->b_count, n); |
| 2677 | if (copy_to_user(buf, tape->b_data, count)) | 1974 | if (copy_to_user(buf, tape->b_data, count)) |
| 2678 | ret = 1; | 1975 | ret = 1; |
| @@ -2752,12 +2049,10 @@ static void idetape_wait_for_request (ide_drive_t *drive, struct request *rq) | |||
| 2752 | DECLARE_COMPLETION_ONSTACK(wait); | 2049 | DECLARE_COMPLETION_ONSTACK(wait); |
| 2753 | idetape_tape_t *tape = drive->driver_data; | 2050 | idetape_tape_t *tape = drive->driver_data; |
| 2754 | 2051 | ||
| 2755 | #if IDETAPE_DEBUG_BUGS | ||
| 2756 | if (rq == NULL || !blk_special_request(rq)) { | 2052 | if (rq == NULL || !blk_special_request(rq)) { |
| 2757 | printk (KERN_ERR "ide-tape: bug: Trying to sleep on non-valid request\n"); | 2053 | printk (KERN_ERR "ide-tape: bug: Trying to sleep on non-valid request\n"); |
| 2758 | return; | 2054 | return; |
| 2759 | } | 2055 | } |
| 2760 | #endif /* IDETAPE_DEBUG_BUGS */ | ||
| 2761 | rq->end_io_data = &wait; | 2056 | rq->end_io_data = &wait; |
| 2762 | rq->end_io = blk_end_sync_rq; | 2057 | rq->end_io = blk_end_sync_rq; |
| 2763 | spin_unlock_irq(&tape->spinlock); | 2058 | spin_unlock_irq(&tape->spinlock); |
| @@ -2817,7 +2112,7 @@ static ide_startstop_t idetape_read_position_callback (ide_drive_t *drive) | |||
| 2817 | static void idetape_create_write_filemark_cmd (ide_drive_t *drive, idetape_pc_t *pc,int write_filemark) | 2112 | static void idetape_create_write_filemark_cmd (ide_drive_t *drive, idetape_pc_t *pc,int write_filemark) |
| 2818 | { | 2113 | { |
| 2819 | idetape_init_pc(pc); | 2114 | idetape_init_pc(pc); |
| 2820 | pc->c[0] = IDETAPE_WRITE_FILEMARK_CMD; | 2115 | pc->c[0] = WRITE_FILEMARKS; |
| 2821 | pc->c[4] = write_filemark; | 2116 | pc->c[4] = write_filemark; |
| 2822 | set_bit(PC_WAIT_FOR_DSC, &pc->flags); | 2117 | set_bit(PC_WAIT_FOR_DSC, &pc->flags); |
| 2823 | pc->callback = &idetape_pc_callback; | 2118 | pc->callback = &idetape_pc_callback; |
| @@ -2826,7 +2121,7 @@ static void idetape_create_write_filemark_cmd (ide_drive_t *drive, idetape_pc_t | |||
| 2826 | static void idetape_create_test_unit_ready_cmd(idetape_pc_t *pc) | 2121 | static void idetape_create_test_unit_ready_cmd(idetape_pc_t *pc) |
| 2827 | { | 2122 | { |
| 2828 | idetape_init_pc(pc); | 2123 | idetape_init_pc(pc); |
| 2829 | pc->c[0] = IDETAPE_TEST_UNIT_READY_CMD; | 2124 | pc->c[0] = TEST_UNIT_READY; |
| 2830 | pc->callback = &idetape_pc_callback; | 2125 | pc->callback = &idetape_pc_callback; |
| 2831 | } | 2126 | } |
| 2832 | 2127 | ||
| @@ -2864,7 +2159,7 @@ static int __idetape_queue_pc_tail (ide_drive_t *drive, idetape_pc_t *pc) | |||
| 2864 | static void idetape_create_load_unload_cmd (ide_drive_t *drive, idetape_pc_t *pc,int cmd) | 2159 | static void idetape_create_load_unload_cmd (ide_drive_t *drive, idetape_pc_t *pc,int cmd) |
| 2865 | { | 2160 | { |
| 2866 | idetape_init_pc(pc); | 2161 | idetape_init_pc(pc); |
| 2867 | pc->c[0] = IDETAPE_LOAD_UNLOAD_CMD; | 2162 | pc->c[0] = START_STOP; |
| 2868 | pc->c[4] = cmd; | 2163 | pc->c[4] = cmd; |
| 2869 | set_bit(PC_WAIT_FOR_DSC, &pc->flags); | 2164 | set_bit(PC_WAIT_FOR_DSC, &pc->flags); |
| 2870 | pc->callback = &idetape_pc_callback; | 2165 | pc->callback = &idetape_pc_callback; |
| @@ -2921,7 +2216,7 @@ static int idetape_flush_tape_buffers (ide_drive_t *drive) | |||
| 2921 | static void idetape_create_read_position_cmd (idetape_pc_t *pc) | 2216 | static void idetape_create_read_position_cmd (idetape_pc_t *pc) |
| 2922 | { | 2217 | { |
| 2923 | idetape_init_pc(pc); | 2218 | idetape_init_pc(pc); |
| 2924 | pc->c[0] = IDETAPE_READ_POSITION_CMD; | 2219 | pc->c[0] = READ_POSITION; |
| 2925 | pc->request_transfer = 20; | 2220 | pc->request_transfer = 20; |
| 2926 | pc->callback = &idetape_read_position_callback; | 2221 | pc->callback = &idetape_read_position_callback; |
| 2927 | } | 2222 | } |
| @@ -2947,9 +2242,9 @@ static int idetape_read_position (ide_drive_t *drive) | |||
| 2947 | static void idetape_create_locate_cmd (ide_drive_t *drive, idetape_pc_t *pc, unsigned int block, u8 partition, int skip) | 2242 | static void idetape_create_locate_cmd (ide_drive_t *drive, idetape_pc_t *pc, unsigned int block, u8 partition, int skip) |
| 2948 | { | 2243 | { |
| 2949 | idetape_init_pc(pc); | 2244 | idetape_init_pc(pc); |
| 2950 | pc->c[0] = IDETAPE_LOCATE_CMD; | 2245 | pc->c[0] = POSITION_TO_ELEMENT; |
| 2951 | pc->c[1] = 2; | 2246 | pc->c[1] = 2; |
| 2952 | put_unaligned(htonl(block), (unsigned int *) &pc->c[3]); | 2247 | put_unaligned(cpu_to_be32(block), (unsigned int *) &pc->c[3]); |
| 2953 | pc->c[8] = partition; | 2248 | pc->c[8] = partition; |
| 2954 | set_bit(PC_WAIT_FOR_DSC, &pc->flags); | 2249 | set_bit(PC_WAIT_FOR_DSC, &pc->flags); |
| 2955 | pc->callback = &idetape_pc_callback; | 2250 | pc->callback = &idetape_pc_callback; |
| @@ -2959,11 +2254,12 @@ static int idetape_create_prevent_cmd (ide_drive_t *drive, idetape_pc_t *pc, int | |||
| 2959 | { | 2254 | { |
| 2960 | idetape_tape_t *tape = drive->driver_data; | 2255 | idetape_tape_t *tape = drive->driver_data; |
| 2961 | 2256 | ||
| 2962 | if (!tape->capabilities.lock) | 2257 | /* device supports locking according to capabilities page */ |
| 2258 | if (!(tape->caps[6] & 0x01)) | ||
| 2963 | return 0; | 2259 | return 0; |
| 2964 | 2260 | ||
| 2965 | idetape_init_pc(pc); | 2261 | idetape_init_pc(pc); |
| 2966 | pc->c[0] = IDETAPE_PREVENT_CMD; | 2262 | pc->c[0] = ALLOW_MEDIUM_REMOVAL; |
| 2967 | pc->c[4] = prevent; | 2263 | pc->c[4] = prevent; |
| 2968 | pc->callback = &idetape_pc_callback; | 2264 | pc->callback = &idetape_pc_callback; |
| 2969 | return 1; | 2265 | return 1; |
| @@ -3072,12 +2368,10 @@ static int idetape_queue_rw_tail(ide_drive_t *drive, int cmd, int blocks, struct | |||
| 3072 | if (tape->debug_level >= 2) | 2368 | if (tape->debug_level >= 2) |
| 3073 | printk(KERN_INFO "ide-tape: idetape_queue_rw_tail: cmd=%d\n",cmd); | 2369 | printk(KERN_INFO "ide-tape: idetape_queue_rw_tail: cmd=%d\n",cmd); |
| 3074 | #endif /* IDETAPE_DEBUG_LOG */ | 2370 | #endif /* IDETAPE_DEBUG_LOG */ |
| 3075 | #if IDETAPE_DEBUG_BUGS | ||
| 3076 | if (idetape_pipeline_active(tape)) { | 2371 | if (idetape_pipeline_active(tape)) { |
| 3077 | printk(KERN_ERR "ide-tape: bug: the pipeline is active in idetape_queue_rw_tail\n"); | 2372 | printk(KERN_ERR "ide-tape: bug: the pipeline is active in idetape_queue_rw_tail\n"); |
| 3078 | return (0); | 2373 | return (0); |
| 3079 | } | 2374 | } |
| 3080 | #endif /* IDETAPE_DEBUG_BUGS */ | ||
| 3081 | 2375 | ||
| 3082 | idetape_init_rq(&rq, cmd); | 2376 | idetape_init_rq(&rq, cmd); |
| 3083 | rq.rq_disk = tape->disk; | 2377 | rq.rq_disk = tape->disk; |
| @@ -3108,7 +2402,7 @@ static void idetape_insert_pipeline_into_queue (ide_drive_t *drive) | |||
| 3108 | return; | 2402 | return; |
| 3109 | if (!idetape_pipeline_active(tape)) { | 2403 | if (!idetape_pipeline_active(tape)) { |
| 3110 | set_bit(IDETAPE_PIPELINE_ACTIVE, &tape->flags); | 2404 | set_bit(IDETAPE_PIPELINE_ACTIVE, &tape->flags); |
| 3111 | idetape_active_next_stage(drive); | 2405 | idetape_activate_next_stage(drive); |
| 3112 | (void) ide_do_drive_cmd(drive, tape->active_data_request, ide_end); | 2406 | (void) ide_do_drive_cmd(drive, tape->active_data_request, ide_end); |
| 3113 | } | 2407 | } |
| 3114 | } | 2408 | } |
| @@ -3116,7 +2410,7 @@ static void idetape_insert_pipeline_into_queue (ide_drive_t *drive) | |||
| 3116 | static void idetape_create_inquiry_cmd (idetape_pc_t *pc) | 2410 | static void idetape_create_inquiry_cmd (idetape_pc_t *pc) |
| 3117 | { | 2411 | { |
| 3118 | idetape_init_pc(pc); | 2412 | idetape_init_pc(pc); |
| 3119 | pc->c[0] = IDETAPE_INQUIRY_CMD; | 2413 | pc->c[0] = INQUIRY; |
| 3120 | pc->c[4] = pc->request_transfer = 254; | 2414 | pc->c[4] = pc->request_transfer = 254; |
| 3121 | pc->callback = &idetape_pc_callback; | 2415 | pc->callback = &idetape_pc_callback; |
| 3122 | } | 2416 | } |
| @@ -3124,28 +2418,15 @@ static void idetape_create_inquiry_cmd (idetape_pc_t *pc) | |||
| 3124 | static void idetape_create_rewind_cmd (ide_drive_t *drive, idetape_pc_t *pc) | 2418 | static void idetape_create_rewind_cmd (ide_drive_t *drive, idetape_pc_t *pc) |
| 3125 | { | 2419 | { |
| 3126 | idetape_init_pc(pc); | 2420 | idetape_init_pc(pc); |
| 3127 | pc->c[0] = IDETAPE_REWIND_CMD; | 2421 | pc->c[0] = REZERO_UNIT; |
| 3128 | set_bit(PC_WAIT_FOR_DSC, &pc->flags); | 2422 | set_bit(PC_WAIT_FOR_DSC, &pc->flags); |
| 3129 | pc->callback = &idetape_pc_callback; | 2423 | pc->callback = &idetape_pc_callback; |
| 3130 | } | 2424 | } |
| 3131 | 2425 | ||
| 3132 | #if 0 | ||
| 3133 | static void idetape_create_mode_select_cmd (idetape_pc_t *pc, int length) | ||
| 3134 | { | ||
| 3135 | idetape_init_pc(pc); | ||
| 3136 | set_bit(PC_WRITING, &pc->flags); | ||
| 3137 | pc->c[0] = IDETAPE_MODE_SELECT_CMD; | ||
| 3138 | pc->c[1] = 0x10; | ||
| 3139 | put_unaligned(htons(length), (unsigned short *) &pc->c[3]); | ||
| 3140 | pc->request_transfer = 255; | ||
| 3141 | pc->callback = &idetape_pc_callback; | ||
| 3142 | } | ||
| 3143 | #endif | ||
| 3144 | |||
| 3145 | static void idetape_create_erase_cmd (idetape_pc_t *pc) | 2426 | static void idetape_create_erase_cmd (idetape_pc_t *pc) |
| 3146 | { | 2427 | { |
| 3147 | idetape_init_pc(pc); | 2428 | idetape_init_pc(pc); |
| 3148 | pc->c[0] = IDETAPE_ERASE_CMD; | 2429 | pc->c[0] = ERASE; |
| 3149 | pc->c[1] = 1; | 2430 | pc->c[1] = 1; |
| 3150 | set_bit(PC_WAIT_FOR_DSC, &pc->flags); | 2431 | set_bit(PC_WAIT_FOR_DSC, &pc->flags); |
| 3151 | pc->callback = &idetape_pc_callback; | 2432 | pc->callback = &idetape_pc_callback; |
| @@ -3154,8 +2435,8 @@ static void idetape_create_erase_cmd (idetape_pc_t *pc) | |||
| 3154 | static void idetape_create_space_cmd (idetape_pc_t *pc,int count, u8 cmd) | 2435 | static void idetape_create_space_cmd (idetape_pc_t *pc,int count, u8 cmd) |
| 3155 | { | 2436 | { |
| 3156 | idetape_init_pc(pc); | 2437 | idetape_init_pc(pc); |
| 3157 | pc->c[0] = IDETAPE_SPACE_CMD; | 2438 | pc->c[0] = SPACE; |
| 3158 | put_unaligned(htonl(count), (unsigned int *) &pc->c[1]); | 2439 | put_unaligned(cpu_to_be32(count), (unsigned int *) &pc->c[1]); |
| 3159 | pc->c[1] = cmd; | 2440 | pc->c[1] = cmd; |
| 3160 | set_bit(PC_WAIT_FOR_DSC, &pc->flags); | 2441 | set_bit(PC_WAIT_FOR_DSC, &pc->flags); |
| 3161 | pc->callback = &idetape_pc_callback; | 2442 | pc->callback = &idetape_pc_callback; |
| @@ -3275,8 +2556,7 @@ static void idetape_empty_write_pipeline (ide_drive_t *drive) | |||
| 3275 | idetape_tape_t *tape = drive->driver_data; | 2556 | idetape_tape_t *tape = drive->driver_data; |
| 3276 | int blocks, min; | 2557 | int blocks, min; |
| 3277 | struct idetape_bh *bh; | 2558 | struct idetape_bh *bh; |
| 3278 | 2559 | ||
| 3279 | #if IDETAPE_DEBUG_BUGS | ||
| 3280 | if (tape->chrdev_direction != idetape_direction_write) { | 2560 | if (tape->chrdev_direction != idetape_direction_write) { |
| 3281 | printk(KERN_ERR "ide-tape: bug: Trying to empty write pipeline, but we are not writing.\n"); | 2561 | printk(KERN_ERR "ide-tape: bug: Trying to empty write pipeline, but we are not writing.\n"); |
| 3282 | return; | 2562 | return; |
| @@ -3285,7 +2565,6 @@ static void idetape_empty_write_pipeline (ide_drive_t *drive) | |||
| 3285 | printk(KERN_ERR "ide-tape: bug: merge_buffer too big\n"); | 2565 | printk(KERN_ERR "ide-tape: bug: merge_buffer too big\n"); |
| 3286 | tape->merge_stage_size = tape->stage_size; | 2566 | tape->merge_stage_size = tape->stage_size; |
| 3287 | } | 2567 | } |
| 3288 | #endif /* IDETAPE_DEBUG_BUGS */ | ||
| 3289 | if (tape->merge_stage_size) { | 2568 | if (tape->merge_stage_size) { |
| 3290 | blocks = tape->merge_stage_size / tape->tape_block_size; | 2569 | blocks = tape->merge_stage_size / tape->tape_block_size; |
| 3291 | if (tape->merge_stage_size % tape->tape_block_size) { | 2570 | if (tape->merge_stage_size % tape->tape_block_size) { |
| @@ -3330,7 +2609,6 @@ static void idetape_empty_write_pipeline (ide_drive_t *drive) | |||
| 3330 | * can be totally different on the next backup). | 2609 | * can be totally different on the next backup). |
| 3331 | */ | 2610 | */ |
| 3332 | tape->max_stages = tape->min_pipeline; | 2611 | tape->max_stages = tape->min_pipeline; |
| 3333 | #if IDETAPE_DEBUG_BUGS | ||
| 3334 | if (tape->first_stage != NULL || | 2612 | if (tape->first_stage != NULL || |
| 3335 | tape->next_stage != NULL || | 2613 | tape->next_stage != NULL || |
| 3336 | tape->last_stage != NULL || | 2614 | tape->last_stage != NULL || |
| @@ -3341,7 +2619,6 @@ static void idetape_empty_write_pipeline (ide_drive_t *drive) | |||
| 3341 | tape->first_stage, tape->next_stage, | 2619 | tape->first_stage, tape->next_stage, |
| 3342 | tape->last_stage, tape->nr_stages); | 2620 | tape->last_stage, tape->nr_stages); |
| 3343 | } | 2621 | } |
| 3344 | #endif /* IDETAPE_DEBUG_BUGS */ | ||
| 3345 | } | 2622 | } |
| 3346 | 2623 | ||
| 3347 | static void idetape_restart_speed_control (ide_drive_t *drive) | 2624 | static void idetape_restart_speed_control (ide_drive_t *drive) |
| @@ -3364,7 +2641,7 @@ static int idetape_initiate_read (ide_drive_t *drive, int max_stages) | |||
| 3364 | idetape_stage_t *new_stage; | 2641 | idetape_stage_t *new_stage; |
| 3365 | struct request rq; | 2642 | struct request rq; |
| 3366 | int bytes_read; | 2643 | int bytes_read; |
| 3367 | int blocks = tape->capabilities.ctl; | 2644 | u16 blocks = *(u16 *)&tape->caps[12]; |
| 3368 | 2645 | ||
| 3369 | /* Initialize read operation */ | 2646 | /* Initialize read operation */ |
| 3370 | if (tape->chrdev_direction != idetape_direction_read) { | 2647 | if (tape->chrdev_direction != idetape_direction_read) { |
| @@ -3372,12 +2649,10 @@ static int idetape_initiate_read (ide_drive_t *drive, int max_stages) | |||
| 3372 | idetape_empty_write_pipeline(drive); | 2649 | idetape_empty_write_pipeline(drive); |
| 3373 | idetape_flush_tape_buffers(drive); | 2650 | idetape_flush_tape_buffers(drive); |
| 3374 | } | 2651 | } |
| 3375 | #if IDETAPE_DEBUG_BUGS | ||
| 3376 | if (tape->merge_stage || tape->merge_stage_size) { | 2652 | if (tape->merge_stage || tape->merge_stage_size) { |
| 3377 | printk (KERN_ERR "ide-tape: merge_stage_size should be 0 now\n"); | 2653 | printk (KERN_ERR "ide-tape: merge_stage_size should be 0 now\n"); |
| 3378 | tape->merge_stage_size = 0; | 2654 | tape->merge_stage_size = 0; |
| 3379 | } | 2655 | } |
| 3380 | #endif /* IDETAPE_DEBUG_BUGS */ | ||
| 3381 | if ((tape->merge_stage = __idetape_kmalloc_stage(tape, 0, 0)) == NULL) | 2656 | if ((tape->merge_stage = __idetape_kmalloc_stage(tape, 0, 0)) == NULL) |
| 3382 | return -ENOMEM; | 2657 | return -ENOMEM; |
| 3383 | tape->chrdev_direction = idetape_direction_read; | 2658 | tape->chrdev_direction = idetape_direction_read; |
| @@ -3478,12 +2753,10 @@ static int idetape_add_chrdev_read_request (ide_drive_t *drive,int blocks) | |||
| 3478 | tape->pipeline_head++; | 2753 | tape->pipeline_head++; |
| 3479 | calculate_speeds(drive); | 2754 | calculate_speeds(drive); |
| 3480 | } | 2755 | } |
| 3481 | #if IDETAPE_DEBUG_BUGS | ||
| 3482 | if (bytes_read > blocks * tape->tape_block_size) { | 2756 | if (bytes_read > blocks * tape->tape_block_size) { |
| 3483 | printk(KERN_ERR "ide-tape: bug: trying to return more bytes than requested\n"); | 2757 | printk(KERN_ERR "ide-tape: bug: trying to return more bytes than requested\n"); |
| 3484 | bytes_read = blocks * tape->tape_block_size; | 2758 | bytes_read = blocks * tape->tape_block_size; |
| 3485 | } | 2759 | } |
| 3486 | #endif /* IDETAPE_DEBUG_BUGS */ | ||
| 3487 | return (bytes_read); | 2760 | return (bytes_read); |
| 3488 | } | 2761 | } |
| 3489 | 2762 | ||
| @@ -3567,16 +2840,21 @@ static int idetape_rewind_tape (ide_drive_t *drive) | |||
| 3567 | static int idetape_blkdev_ioctl(ide_drive_t *drive, unsigned int cmd, unsigned long arg) | 2840 | static int idetape_blkdev_ioctl(ide_drive_t *drive, unsigned int cmd, unsigned long arg) |
| 3568 | { | 2841 | { |
| 3569 | idetape_tape_t *tape = drive->driver_data; | 2842 | idetape_tape_t *tape = drive->driver_data; |
| 3570 | idetape_config_t config; | ||
| 3571 | void __user *argp = (void __user *)arg; | 2843 | void __user *argp = (void __user *)arg; |
| 3572 | 2844 | ||
| 2845 | struct idetape_config { | ||
| 2846 | int dsc_rw_frequency; | ||
| 2847 | int dsc_media_access_frequency; | ||
| 2848 | int nr_stages; | ||
| 2849 | } config; | ||
| 2850 | |||
| 3573 | #if IDETAPE_DEBUG_LOG | 2851 | #if IDETAPE_DEBUG_LOG |
| 3574 | if (tape->debug_level >= 4) | 2852 | if (tape->debug_level >= 4) |
| 3575 | printk(KERN_INFO "ide-tape: Reached idetape_blkdev_ioctl\n"); | 2853 | printk(KERN_INFO "ide-tape: Reached idetape_blkdev_ioctl\n"); |
| 3576 | #endif /* IDETAPE_DEBUG_LOG */ | 2854 | #endif /* IDETAPE_DEBUG_LOG */ |
| 3577 | switch (cmd) { | 2855 | switch (cmd) { |
| 3578 | case 0x0340: | 2856 | case 0x0340: |
| 3579 | if (copy_from_user(&config, argp, sizeof (idetape_config_t))) | 2857 | if (copy_from_user(&config, argp, sizeof(config))) |
| 3580 | return -EFAULT; | 2858 | return -EFAULT; |
| 3581 | tape->best_dsc_rw_frequency = config.dsc_rw_frequency; | 2859 | tape->best_dsc_rw_frequency = config.dsc_rw_frequency; |
| 3582 | tape->max_stages = config.nr_stages; | 2860 | tape->max_stages = config.nr_stages; |
| @@ -3584,7 +2862,7 @@ static int idetape_blkdev_ioctl(ide_drive_t *drive, unsigned int cmd, unsigned l | |||
| 3584 | case 0x0350: | 2862 | case 0x0350: |
| 3585 | config.dsc_rw_frequency = (int) tape->best_dsc_rw_frequency; | 2863 | config.dsc_rw_frequency = (int) tape->best_dsc_rw_frequency; |
| 3586 | config.nr_stages = tape->max_stages; | 2864 | config.nr_stages = tape->max_stages; |
| 3587 | if (copy_to_user(argp, &config, sizeof (idetape_config_t))) | 2865 | if (copy_to_user(argp, &config, sizeof(config))) |
| 3588 | return -EFAULT; | 2866 | return -EFAULT; |
| 3589 | break; | 2867 | break; |
| 3590 | default: | 2868 | default: |
| @@ -3608,11 +2886,12 @@ static int idetape_space_over_filemarks (ide_drive_t *drive,short mt_op,int mt_c | |||
| 3608 | idetape_pc_t pc; | 2886 | idetape_pc_t pc; |
| 3609 | unsigned long flags; | 2887 | unsigned long flags; |
| 3610 | int retval,count=0; | 2888 | int retval,count=0; |
| 2889 | int sprev = !!(tape->caps[4] & 0x20); | ||
| 3611 | 2890 | ||
| 3612 | if (mt_count == 0) | 2891 | if (mt_count == 0) |
| 3613 | return 0; | 2892 | return 0; |
| 3614 | if (MTBSF == mt_op || MTBSFM == mt_op) { | 2893 | if (MTBSF == mt_op || MTBSFM == mt_op) { |
| 3615 | if (!tape->capabilities.sprev) | 2894 | if (!sprev) |
| 3616 | return -EIO; | 2895 | return -EIO; |
| 3617 | mt_count = - mt_count; | 2896 | mt_count = - mt_count; |
| 3618 | } | 2897 | } |
| @@ -3666,7 +2945,7 @@ static int idetape_space_over_filemarks (ide_drive_t *drive,short mt_op,int mt_c | |||
| 3666 | return (idetape_queue_pc_tail(drive, &pc)); | 2945 | return (idetape_queue_pc_tail(drive, &pc)); |
| 3667 | case MTFSFM: | 2946 | case MTFSFM: |
| 3668 | case MTBSFM: | 2947 | case MTBSFM: |
| 3669 | if (!tape->capabilities.sprev) | 2948 | if (!sprev) |
| 3670 | return (-EIO); | 2949 | return (-EIO); |
| 3671 | retval = idetape_space_over_filemarks(drive, MTFSF, mt_count-count); | 2950 | retval = idetape_space_over_filemarks(drive, MTFSF, mt_count-count); |
| 3672 | if (retval) return (retval); | 2951 | if (retval) return (retval); |
| @@ -3703,6 +2982,7 @@ static ssize_t idetape_chrdev_read (struct file *file, char __user *buf, | |||
| 3703 | ide_drive_t *drive = tape->drive; | 2982 | ide_drive_t *drive = tape->drive; |
| 3704 | ssize_t bytes_read,temp, actually_read = 0, rc; | 2983 | ssize_t bytes_read,temp, actually_read = 0, rc; |
| 3705 | ssize_t ret = 0; | 2984 | ssize_t ret = 0; |
| 2985 | u16 ctl = *(u16 *)&tape->caps[12]; | ||
| 3706 | 2986 | ||
| 3707 | #if IDETAPE_DEBUG_LOG | 2987 | #if IDETAPE_DEBUG_LOG |
| 3708 | if (tape->debug_level >= 3) | 2988 | if (tape->debug_level >= 3) |
| @@ -3728,7 +3008,7 @@ static ssize_t idetape_chrdev_read (struct file *file, char __user *buf, | |||
| 3728 | count -= actually_read; | 3008 | count -= actually_read; |
| 3729 | } | 3009 | } |
| 3730 | while (count >= tape->stage_size) { | 3010 | while (count >= tape->stage_size) { |
| 3731 | bytes_read = idetape_add_chrdev_read_request(drive, tape->capabilities.ctl); | 3011 | bytes_read = idetape_add_chrdev_read_request(drive, ctl); |
| 3732 | if (bytes_read <= 0) | 3012 | if (bytes_read <= 0) |
| 3733 | goto finish; | 3013 | goto finish; |
| 3734 | if (idetape_copy_stage_to_user(tape, buf, tape->merge_stage, bytes_read)) | 3014 | if (idetape_copy_stage_to_user(tape, buf, tape->merge_stage, bytes_read)) |
| @@ -3738,7 +3018,7 @@ static ssize_t idetape_chrdev_read (struct file *file, char __user *buf, | |||
| 3738 | actually_read += bytes_read; | 3018 | actually_read += bytes_read; |
| 3739 | } | 3019 | } |
| 3740 | if (count) { | 3020 | if (count) { |
| 3741 | bytes_read = idetape_add_chrdev_read_request(drive, tape->capabilities.ctl); | 3021 | bytes_read = idetape_add_chrdev_read_request(drive, ctl); |
| 3742 | if (bytes_read <= 0) | 3022 | if (bytes_read <= 0) |
| 3743 | goto finish; | 3023 | goto finish; |
| 3744 | temp = min((unsigned long)count, (unsigned long)bytes_read); | 3024 | temp = min((unsigned long)count, (unsigned long)bytes_read); |
| @@ -3767,6 +3047,7 @@ static ssize_t idetape_chrdev_write (struct file *file, const char __user *buf, | |||
| 3767 | ide_drive_t *drive = tape->drive; | 3047 | ide_drive_t *drive = tape->drive; |
| 3768 | ssize_t actually_written = 0; | 3048 | ssize_t actually_written = 0; |
| 3769 | ssize_t ret = 0; | 3049 | ssize_t ret = 0; |
| 3050 | u16 ctl = *(u16 *)&tape->caps[12]; | ||
| 3770 | 3051 | ||
| 3771 | /* The drive is write protected. */ | 3052 | /* The drive is write protected. */ |
| 3772 | if (tape->write_prot) | 3053 | if (tape->write_prot) |
| @@ -3782,13 +3063,11 @@ static ssize_t idetape_chrdev_write (struct file *file, const char __user *buf, | |||
| 3782 | if (tape->chrdev_direction != idetape_direction_write) { | 3063 | if (tape->chrdev_direction != idetape_direction_write) { |
| 3783 | if (tape->chrdev_direction == idetape_direction_read) | 3064 | if (tape->chrdev_direction == idetape_direction_read) |
| 3784 | idetape_discard_read_pipeline(drive, 1); | 3065 | idetape_discard_read_pipeline(drive, 1); |
| 3785 | #if IDETAPE_DEBUG_BUGS | ||
| 3786 | if (tape->merge_stage || tape->merge_stage_size) { | 3066 | if (tape->merge_stage || tape->merge_stage_size) { |
| 3787 | printk(KERN_ERR "ide-tape: merge_stage_size " | 3067 | printk(KERN_ERR "ide-tape: merge_stage_size " |
| 3788 | "should be 0 now\n"); | 3068 | "should be 0 now\n"); |
| 3789 | tape->merge_stage_size = 0; | 3069 | tape->merge_stage_size = 0; |
| 3790 | } | 3070 | } |
| 3791 | #endif /* IDETAPE_DEBUG_BUGS */ | ||
| 3792 | if ((tape->merge_stage = __idetape_kmalloc_stage(tape, 0, 0)) == NULL) | 3071 | if ((tape->merge_stage = __idetape_kmalloc_stage(tape, 0, 0)) == NULL) |
| 3793 | return -ENOMEM; | 3072 | return -ENOMEM; |
| 3794 | tape->chrdev_direction = idetape_direction_write; | 3073 | tape->chrdev_direction = idetape_direction_write; |
| @@ -3816,12 +3095,10 @@ static ssize_t idetape_chrdev_write (struct file *file, const char __user *buf, | |||
| 3816 | if (tape->restart_speed_control_req) | 3095 | if (tape->restart_speed_control_req) |
| 3817 | idetape_restart_speed_control(drive); | 3096 | idetape_restart_speed_control(drive); |
| 3818 | if (tape->merge_stage_size) { | 3097 | if (tape->merge_stage_size) { |
| 3819 | #if IDETAPE_DEBUG_BUGS | ||
| 3820 | if (tape->merge_stage_size >= tape->stage_size) { | 3098 | if (tape->merge_stage_size >= tape->stage_size) { |
| 3821 | printk(KERN_ERR "ide-tape: bug: merge buffer too big\n"); | 3099 | printk(KERN_ERR "ide-tape: bug: merge buffer too big\n"); |
| 3822 | tape->merge_stage_size = 0; | 3100 | tape->merge_stage_size = 0; |
| 3823 | } | 3101 | } |
| 3824 | #endif /* IDETAPE_DEBUG_BUGS */ | ||
| 3825 | actually_written = min((unsigned int)(tape->stage_size - tape->merge_stage_size), (unsigned int)count); | 3102 | actually_written = min((unsigned int)(tape->stage_size - tape->merge_stage_size), (unsigned int)count); |
| 3826 | if (idetape_copy_stage_from_user(tape, tape->merge_stage, buf, actually_written)) | 3103 | if (idetape_copy_stage_from_user(tape, tape->merge_stage, buf, actually_written)) |
| 3827 | ret = -EFAULT; | 3104 | ret = -EFAULT; |
| @@ -3832,7 +3109,7 @@ static ssize_t idetape_chrdev_write (struct file *file, const char __user *buf, | |||
| 3832 | if (tape->merge_stage_size == tape->stage_size) { | 3109 | if (tape->merge_stage_size == tape->stage_size) { |
| 3833 | ssize_t retval; | 3110 | ssize_t retval; |
| 3834 | tape->merge_stage_size = 0; | 3111 | tape->merge_stage_size = 0; |
| 3835 | retval = idetape_add_chrdev_write_request(drive, tape->capabilities.ctl); | 3112 | retval = idetape_add_chrdev_write_request(drive, ctl); |
| 3836 | if (retval <= 0) | 3113 | if (retval <= 0) |
| 3837 | return (retval); | 3114 | return (retval); |
| 3838 | } | 3115 | } |
| @@ -3843,7 +3120,7 @@ static ssize_t idetape_chrdev_write (struct file *file, const char __user *buf, | |||
| 3843 | ret = -EFAULT; | 3120 | ret = -EFAULT; |
| 3844 | buf += tape->stage_size; | 3121 | buf += tape->stage_size; |
| 3845 | count -= tape->stage_size; | 3122 | count -= tape->stage_size; |
| 3846 | retval = idetape_add_chrdev_write_request(drive, tape->capabilities.ctl); | 3123 | retval = idetape_add_chrdev_write_request(drive, ctl); |
| 3847 | actually_written += tape->stage_size; | 3124 | actually_written += tape->stage_size; |
| 3848 | if (retval <= 0) | 3125 | if (retval <= 0) |
| 3849 | return (retval); | 3126 | return (retval); |
| @@ -3871,69 +3148,20 @@ static int idetape_write_filemark (ide_drive_t *drive) | |||
| 3871 | } | 3148 | } |
| 3872 | 3149 | ||
| 3873 | /* | 3150 | /* |
| 3874 | * idetape_mtioctop is called from idetape_chrdev_ioctl when | 3151 | * Called from idetape_chrdev_ioctl when the general mtio MTIOCTOP ioctl is |
| 3875 | * the general mtio MTIOCTOP ioctl is requested. | 3152 | * requested. |
| 3876 | * | ||
| 3877 | * We currently support the following mtio.h operations: | ||
| 3878 | * | 3153 | * |
| 3879 | * MTFSF - Space over mt_count filemarks in the positive direction. | 3154 | * Note: MTBSF and MTBSFM are not supported when the tape doesn't support |
| 3880 | * The tape is positioned after the last spaced filemark. | 3155 | * spacing over filemarks in the reverse direction. In this case, MTFSFM is also |
| 3156 | * usually not supported (it is supported in the rare case in which we crossed | ||
| 3157 | * the filemark during our read-ahead pipelined operation mode). | ||
| 3881 | * | 3158 | * |
| 3882 | * MTFSFM - Same as MTFSF, but the tape is positioned before the | 3159 | * The following commands are currently not supported: |
| 3883 | * last filemark. | ||
| 3884 | * | 3160 | * |
| 3885 | * MTBSF - Steps background over mt_count filemarks, tape is | 3161 | * MTFSS, MTBSS, MTWSM, MTSETDENSITY, MTSETDRVBUFFER, MT_ST_BOOLEANS, |
| 3886 | * positioned before the last filemark. | 3162 | * MT_ST_WRITE_THRESHOLD. |
| 3887 | * | ||
| 3888 | * MTBSFM - Like MTBSF, only tape is positioned after the last filemark. | ||
| 3889 | * | ||
| 3890 | * Note: | ||
| 3891 | * | ||
| 3892 | * MTBSF and MTBSFM are not supported when the tape doesn't | ||
| 3893 | * support spacing over filemarks in the reverse direction. | ||
| 3894 | * In this case, MTFSFM is also usually not supported (it is | ||
| 3895 | * supported in the rare case in which we crossed the filemark | ||
| 3896 | * during our read-ahead pipelined operation mode). | ||
| 3897 | * | ||
| 3898 | * MTWEOF - Writes mt_count filemarks. Tape is positioned after | ||
| 3899 | * the last written filemark. | ||
| 3900 | * | ||
| 3901 | * MTREW - Rewinds tape. | ||
| 3902 | * | ||
| 3903 | * MTLOAD - Loads the tape. | ||
| 3904 | * | ||
| 3905 | * MTOFFL - Puts the tape drive "Offline": Rewinds the tape and | ||
| 3906 | * MTUNLOAD prevents further access until the media is replaced. | ||
| 3907 | * | ||
| 3908 | * MTNOP - Flushes tape buffers. | ||
| 3909 | * | ||
| 3910 | * MTRETEN - Retension media. This typically consists of one end | ||
| 3911 | * to end pass on the media. | ||
| 3912 | * | ||
| 3913 | * MTEOM - Moves to the end of recorded data. | ||
| 3914 | * | ||
| 3915 | * MTERASE - Erases tape. | ||
| 3916 | * | ||
| 3917 | * MTSETBLK - Sets the user block size to mt_count bytes. If | ||
| 3918 | * mt_count is 0, we will attempt to autodetect | ||
| 3919 | * the block size. | ||
| 3920 | * | ||
| 3921 | * MTSEEK - Positions the tape in a specific block number, where | ||
| 3922 | * each block is assumed to contain which user_block_size | ||
| 3923 | * bytes. | ||
| 3924 | * | ||
| 3925 | * MTSETPART - Switches to another tape partition. | ||
| 3926 | * | ||
| 3927 | * MTLOCK - Locks the tape door. | ||
| 3928 | * | ||
| 3929 | * MTUNLOCK - Unlocks the tape door. | ||
| 3930 | * | ||
| 3931 | * The following commands are currently not supported: | ||
| 3932 | * | ||
| 3933 | * MTFSS, MTBSS, MTWSM, MTSETDENSITY, | ||
| 3934 | * MTSETDRVBUFFER, MT_ST_BOOLEANS, MT_ST_WRITE_THRESHOLD. | ||
| 3935 | */ | 3163 | */ |
| 3936 | static int idetape_mtioctop (ide_drive_t *drive,short mt_op,int mt_count) | 3164 | static int idetape_mtioctop(ide_drive_t *drive, short mt_op, int mt_count) |
| 3937 | { | 3165 | { |
| 3938 | idetape_tape_t *tape = drive->driver_data; | 3166 | idetape_tape_t *tape = drive->driver_data; |
| 3939 | idetape_pc_t pc; | 3167 | idetape_pc_t pc; |
| @@ -4048,29 +3276,12 @@ static int idetape_mtioctop (ide_drive_t *drive,short mt_op,int mt_count) | |||
| 4048 | } | 3276 | } |
| 4049 | 3277 | ||
| 4050 | /* | 3278 | /* |
| 4051 | * Our character device ioctls. | 3279 | * Our character device ioctls. General mtio.h magnetic io commands are |
| 4052 | * | 3280 | * supported here, and not in the corresponding block interface. Our own |
| 4053 | * General mtio.h magnetic io commands are supported here, and not in | 3281 | * ide-tape ioctls are supported on both interfaces. |
| 4054 | * the corresponding block interface. | ||
| 4055 | * | ||
| 4056 | * The following ioctls are supported: | ||
| 4057 | * | ||
| 4058 | * MTIOCTOP - Refer to idetape_mtioctop for detailed description. | ||
| 4059 | * | ||
| 4060 | * MTIOCGET - The mt_dsreg field in the returned mtget structure | ||
| 4061 | * will be set to (user block size in bytes << | ||
| 4062 | * MT_ST_BLKSIZE_SHIFT) & MT_ST_BLKSIZE_MASK. | ||
| 4063 | * | ||
| 4064 | * The mt_blkno is set to the current user block number. | ||
| 4065 | * The other mtget fields are not supported. | ||
| 4066 | * | ||
| 4067 | * MTIOCPOS - The current tape "block position" is returned. We | ||
| 4068 | * assume that each block contains user_block_size | ||
| 4069 | * bytes. | ||
| 4070 | * | ||
| 4071 | * Our own ide-tape ioctls are supported on both interfaces. | ||
| 4072 | */ | 3282 | */ |
| 4073 | static int idetape_chrdev_ioctl (struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg) | 3283 | static int idetape_chrdev_ioctl(struct inode *inode, struct file *file, |
| 3284 | unsigned int cmd, unsigned long arg) | ||
| 4074 | { | 3285 | { |
| 4075 | struct ide_tape_obj *tape = ide_tape_f(file); | 3286 | struct ide_tape_obj *tape = ide_tape_f(file); |
| 4076 | ide_drive_t *drive = tape->drive; | 3287 | ide_drive_t *drive = tape->drive; |
| @@ -4124,7 +3335,30 @@ static int idetape_chrdev_ioctl (struct inode *inode, struct file *file, unsigne | |||
| 4124 | } | 3335 | } |
| 4125 | } | 3336 | } |
| 4126 | 3337 | ||
| 4127 | static void idetape_get_blocksize_from_block_descriptor(ide_drive_t *drive); | 3338 | /* |
| 3339 | * Do a mode sense page 0 with block descriptor and if it succeeds set the tape | ||
| 3340 | * block size with the reported value. | ||
| 3341 | */ | ||
| 3342 | static void ide_tape_get_bsize_from_bdesc(ide_drive_t *drive) | ||
| 3343 | { | ||
| 3344 | idetape_tape_t *tape = drive->driver_data; | ||
| 3345 | idetape_pc_t pc; | ||
| 3346 | |||
| 3347 | idetape_create_mode_sense_cmd(&pc, IDETAPE_BLOCK_DESCRIPTOR); | ||
| 3348 | if (idetape_queue_pc_tail(drive, &pc)) { | ||
| 3349 | printk(KERN_ERR "ide-tape: Can't get block descriptor\n"); | ||
| 3350 | if (tape->tape_block_size == 0) { | ||
| 3351 | printk(KERN_WARNING "ide-tape: Cannot deal with zero " | ||
| 3352 | "block size, assuming 32k\n"); | ||
| 3353 | tape->tape_block_size = 32768; | ||
| 3354 | } | ||
| 3355 | return; | ||
| 3356 | } | ||
| 3357 | tape->tape_block_size = (pc.buffer[4 + 5] << 16) + | ||
| 3358 | (pc.buffer[4 + 6] << 8) + | ||
| 3359 | pc.buffer[4 + 7]; | ||
| 3360 | tape->drv_write_prot = (pc.buffer[2] & 0x80) >> 7; | ||
| 3361 | } | ||
| 4128 | 3362 | ||
| 4129 | /* | 3363 | /* |
| 4130 | * Our character device open function. | 3364 | * Our character device open function. |
| @@ -4178,7 +3412,7 @@ static int idetape_chrdev_open (struct inode *inode, struct file *filp) | |||
| 4178 | clear_bit(IDETAPE_PIPELINE_ERROR, &tape->flags); | 3412 | clear_bit(IDETAPE_PIPELINE_ERROR, &tape->flags); |
| 4179 | 3413 | ||
| 4180 | /* Read block size and write protect status from drive. */ | 3414 | /* Read block size and write protect status from drive. */ |
| 4181 | idetape_get_blocksize_from_block_descriptor(drive); | 3415 | ide_tape_get_bsize_from_bdesc(drive); |
| 4182 | 3416 | ||
| 4183 | /* Set write protect flag if device is opened as read-only. */ | 3417 | /* Set write protect flag if device is opened as read-only. */ |
| 4184 | if ((filp->f_flags & O_ACCMODE) == O_RDONLY) | 3418 | if ((filp->f_flags & O_ACCMODE) == O_RDONLY) |
| @@ -4296,190 +3530,100 @@ static int idetape_identify_device (ide_drive_t *drive) | |||
| 4296 | 3530 | ||
| 4297 | *((unsigned short *) &gcw) = id->config; | 3531 | *((unsigned short *) &gcw) = id->config; |
| 4298 | 3532 | ||
| 4299 | #if IDETAPE_DEBUG_INFO | ||
| 4300 | printk(KERN_INFO "ide-tape: Dumping ATAPI Identify Device tape parameters\n"); | ||
| 4301 | printk(KERN_INFO "ide-tape: Protocol Type: "); | ||
| 4302 | switch (gcw.protocol) { | ||
| 4303 | case 0: case 1: printk("ATA\n");break; | ||
| 4304 | case 2: printk("ATAPI\n");break; | ||
| 4305 | case 3: printk("Reserved (Unknown to ide-tape)\n");break; | ||
| 4306 | } | ||
| 4307 | printk(KERN_INFO "ide-tape: Device Type: %x - ",gcw.device_type); | ||
| 4308 | switch (gcw.device_type) { | ||
| 4309 | case 0: printk("Direct-access Device\n");break; | ||
| 4310 | case 1: printk("Streaming Tape Device\n");break; | ||
| 4311 | case 2: case 3: case 4: printk("Reserved\n");break; | ||
| 4312 | case 5: printk("CD-ROM Device\n");break; | ||
| 4313 | case 6: printk("Reserved\n"); | ||
| 4314 | case 7: printk("Optical memory Device\n");break; | ||
| 4315 | case 0x1f: printk("Unknown or no Device type\n");break; | ||
| 4316 | default: printk("Reserved\n"); | ||
| 4317 | } | ||
| 4318 | printk(KERN_INFO "ide-tape: Removable: %s",gcw.removable ? "Yes\n":"No\n"); | ||
| 4319 | printk(KERN_INFO "ide-tape: Command Packet DRQ Type: "); | ||
| 4320 | switch (gcw.drq_type) { | ||
| 4321 | case 0: printk("Microprocessor DRQ\n");break; | ||
| 4322 | case 1: printk("Interrupt DRQ\n");break; | ||
| 4323 | case 2: printk("Accelerated DRQ\n");break; | ||
| 4324 | case 3: printk("Reserved\n");break; | ||
| 4325 | } | ||
| 4326 | printk(KERN_INFO "ide-tape: Command Packet Size: "); | ||
| 4327 | switch (gcw.packet_size) { | ||
| 4328 | case 0: printk("12 bytes\n");break; | ||
| 4329 | case 1: printk("16 bytes\n");break; | ||
| 4330 | default: printk("Reserved\n");break; | ||
| 4331 | } | ||
| 4332 | #endif /* IDETAPE_DEBUG_INFO */ | ||
| 4333 | |||
| 4334 | /* Check that we can support this device */ | 3533 | /* Check that we can support this device */ |
| 4335 | 3534 | ||
| 4336 | if (gcw.protocol !=2 ) | 3535 | if (gcw.protocol != 2) |
| 4337 | printk(KERN_ERR "ide-tape: Protocol is not ATAPI\n"); | 3536 | printk(KERN_ERR "ide-tape: Protocol (0x%02x) is not ATAPI\n", |
| 3537 | gcw.protocol); | ||
| 4338 | else if (gcw.device_type != 1) | 3538 | else if (gcw.device_type != 1) |
| 4339 | printk(KERN_ERR "ide-tape: Device type is not set to tape\n"); | 3539 | printk(KERN_ERR "ide-tape: Device type (0x%02x) is not set " |
| 3540 | "to tape\n", gcw.device_type); | ||
| 4340 | else if (!gcw.removable) | 3541 | else if (!gcw.removable) |
| 4341 | printk(KERN_ERR "ide-tape: The removable flag is not set\n"); | 3542 | printk(KERN_ERR "ide-tape: The removable flag is not set\n"); |
| 4342 | else if (gcw.packet_size != 0) { | 3543 | else if (gcw.packet_size != 0) { |
| 4343 | printk(KERN_ERR "ide-tape: Packet size is not 12 bytes long\n"); | 3544 | printk(KERN_ERR "ide-tape: Packet size (0x%02x) is not 12 " |
| 4344 | if (gcw.packet_size == 1) | 3545 | "bytes long\n", gcw.packet_size); |
| 4345 | printk(KERN_ERR "ide-tape: Sorry, padding to 16 bytes is still not supported\n"); | ||
| 4346 | } else | 3546 | } else |
| 4347 | return 1; | 3547 | return 1; |
| 4348 | return 0; | 3548 | return 0; |
| 4349 | } | 3549 | } |
| 4350 | 3550 | ||
| 4351 | /* | 3551 | static void idetape_get_inquiry_results(ide_drive_t *drive) |
| 4352 | * Use INQUIRY to get the firmware revision | ||
| 4353 | */ | ||
| 4354 | static void idetape_get_inquiry_results (ide_drive_t *drive) | ||
| 4355 | { | 3552 | { |
| 4356 | char *r; | 3553 | char *r; |
| 4357 | idetape_tape_t *tape = drive->driver_data; | 3554 | idetape_tape_t *tape = drive->driver_data; |
| 4358 | idetape_pc_t pc; | 3555 | idetape_pc_t pc; |
| 4359 | idetape_inquiry_result_t *inquiry; | 3556 | |
| 4360 | |||
| 4361 | idetape_create_inquiry_cmd(&pc); | 3557 | idetape_create_inquiry_cmd(&pc); |
| 4362 | if (idetape_queue_pc_tail(drive, &pc)) { | 3558 | if (idetape_queue_pc_tail(drive, &pc)) { |
| 4363 | printk(KERN_ERR "ide-tape: %s: can't get INQUIRY results\n", tape->name); | 3559 | printk(KERN_ERR "ide-tape: %s: can't get INQUIRY results\n", |
| 3560 | tape->name); | ||
| 4364 | return; | 3561 | return; |
| 4365 | } | 3562 | } |
| 4366 | inquiry = (idetape_inquiry_result_t *) pc.buffer; | 3563 | memcpy(tape->vendor_id, &pc.buffer[8], 8); |
| 4367 | memcpy(tape->vendor_id, inquiry->vendor_id, 8); | 3564 | memcpy(tape->product_id, &pc.buffer[16], 16); |
| 4368 | memcpy(tape->product_id, inquiry->product_id, 16); | 3565 | memcpy(tape->firmware_revision, &pc.buffer[32], 4); |
| 4369 | memcpy(tape->firmware_revision, inquiry->revision_level, 4); | 3566 | |
| 4370 | ide_fixstring(tape->vendor_id, 10, 0); | 3567 | ide_fixstring(tape->vendor_id, 10, 0); |
| 4371 | ide_fixstring(tape->product_id, 18, 0); | 3568 | ide_fixstring(tape->product_id, 18, 0); |
| 4372 | ide_fixstring(tape->firmware_revision, 6, 0); | 3569 | ide_fixstring(tape->firmware_revision, 6, 0); |
| 4373 | r = tape->firmware_revision; | 3570 | r = tape->firmware_revision; |
| 4374 | if (*(r + 1) == '.') | 3571 | if (*(r + 1) == '.') |
| 4375 | tape->firmware_revision_num = (*r - '0') * 100 + (*(r + 2) - '0') * 10 + *(r + 3) - '0'; | 3572 | tape->firmware_revision_num = (*r - '0') * 100 + |
| 4376 | printk(KERN_INFO "ide-tape: %s <-> %s: %s %s rev %s\n", drive->name, tape->name, tape->vendor_id, tape->product_id, tape->firmware_revision); | 3573 | (*(r + 2) - '0') * 10 + *(r + 3) - '0'; |
| 3574 | printk(KERN_INFO "ide-tape: %s <-> %s: %s %s rev %s\n", | ||
| 3575 | drive->name, tape->name, tape->vendor_id, | ||
| 3576 | tape->product_id, tape->firmware_revision); | ||
| 4377 | } | 3577 | } |
| 4378 | 3578 | ||
| 4379 | /* | 3579 | /* |
| 4380 | * idetape_get_mode_sense_results asks the tape about its various | 3580 | * Ask the tape about its various parameters. In particular, we will adjust our |
| 4381 | * parameters. In particular, we will adjust our data transfer buffer | 3581 | * data transfer buffer size to the recommended value as returned by the tape. |
| 4382 | * size to the recommended value as returned by the tape. | ||
| 4383 | */ | 3582 | */ |
| 4384 | static void idetape_get_mode_sense_results (ide_drive_t *drive) | 3583 | static void idetape_get_mode_sense_results (ide_drive_t *drive) |
| 4385 | { | 3584 | { |
| 4386 | idetape_tape_t *tape = drive->driver_data; | 3585 | idetape_tape_t *tape = drive->driver_data; |
| 4387 | idetape_pc_t pc; | 3586 | idetape_pc_t pc; |
| 4388 | idetape_mode_parameter_header_t *header; | 3587 | u8 *caps; |
| 4389 | idetape_capabilities_page_t *capabilities; | 3588 | u8 speed, max_speed; |
| 4390 | 3589 | ||
| 4391 | idetape_create_mode_sense_cmd(&pc, IDETAPE_CAPABILITIES_PAGE); | 3590 | idetape_create_mode_sense_cmd(&pc, IDETAPE_CAPABILITIES_PAGE); |
| 4392 | if (idetape_queue_pc_tail(drive, &pc)) { | 3591 | if (idetape_queue_pc_tail(drive, &pc)) { |
| 4393 | printk(KERN_ERR "ide-tape: Can't get tape parameters - assuming some default values\n"); | 3592 | printk(KERN_ERR "ide-tape: Can't get tape parameters - assuming" |
| 3593 | " some default values\n"); | ||
| 4394 | tape->tape_block_size = 512; | 3594 | tape->tape_block_size = 512; |
| 4395 | tape->capabilities.ctl = 52; | 3595 | put_unaligned(52, (u16 *)&tape->caps[12]); |
| 4396 | tape->capabilities.speed = 450; | 3596 | put_unaligned(540, (u16 *)&tape->caps[14]); |
| 4397 | tape->capabilities.buffer_size = 6 * 52; | 3597 | put_unaligned(6*52, (u16 *)&tape->caps[16]); |
| 4398 | return; | 3598 | return; |
| 4399 | } | 3599 | } |
| 4400 | header = (idetape_mode_parameter_header_t *) pc.buffer; | 3600 | caps = pc.buffer + 4 + pc.buffer[3]; |
| 4401 | capabilities = (idetape_capabilities_page_t *) (pc.buffer + sizeof(idetape_mode_parameter_header_t) + header->bdl); | ||
| 4402 | 3601 | ||
| 4403 | capabilities->max_speed = ntohs(capabilities->max_speed); | 3602 | /* convert to host order and save for later use */ |
| 4404 | capabilities->ctl = ntohs(capabilities->ctl); | 3603 | speed = be16_to_cpu(*(u16 *)&caps[14]); |
| 4405 | capabilities->speed = ntohs(capabilities->speed); | 3604 | max_speed = be16_to_cpu(*(u16 *)&caps[8]); |
| 4406 | capabilities->buffer_size = ntohs(capabilities->buffer_size); | ||
| 4407 | 3605 | ||
| 4408 | if (!capabilities->speed) { | 3606 | put_unaligned(max_speed, (u16 *)&caps[8]); |
| 4409 | printk(KERN_INFO "ide-tape: %s: overriding capabilities->speed (assuming 650KB/sec)\n", drive->name); | 3607 | put_unaligned(be16_to_cpu(*(u16 *)&caps[12]), (u16 *)&caps[12]); |
| 4410 | capabilities->speed = 650; | 3608 | put_unaligned(speed, (u16 *)&caps[14]); |
| 3609 | put_unaligned(be16_to_cpu(*(u16 *)&caps[16]), (u16 *)&caps[16]); | ||
| 3610 | |||
| 3611 | if (!speed) { | ||
| 3612 | printk(KERN_INFO "ide-tape: %s: invalid tape speed " | ||
| 3613 | "(assuming 650KB/sec)\n", drive->name); | ||
| 3614 | put_unaligned(650, (u16 *)&caps[14]); | ||
| 4411 | } | 3615 | } |
| 4412 | if (!capabilities->max_speed) { | 3616 | if (!max_speed) { |
| 4413 | printk(KERN_INFO "ide-tape: %s: overriding capabilities->max_speed (assuming 650KB/sec)\n", drive->name); | 3617 | printk(KERN_INFO "ide-tape: %s: invalid max_speed " |
| 4414 | capabilities->max_speed = 650; | 3618 | "(assuming 650KB/sec)\n", drive->name); |
| 3619 | put_unaligned(650, (u16 *)&caps[8]); | ||
| 4415 | } | 3620 | } |
| 4416 | 3621 | ||
| 4417 | tape->capabilities = *capabilities; /* Save us a copy */ | 3622 | memcpy(&tape->caps, caps, 20); |
| 4418 | if (capabilities->blk512) | 3623 | if (caps[7] & 0x02) |
| 4419 | tape->tape_block_size = 512; | 3624 | tape->tape_block_size = 512; |
| 4420 | else if (capabilities->blk1024) | 3625 | else if (caps[7] & 0x04) |
| 4421 | tape->tape_block_size = 1024; | 3626 | tape->tape_block_size = 1024; |
| 4422 | |||
| 4423 | #if IDETAPE_DEBUG_INFO | ||
| 4424 | printk(KERN_INFO "ide-tape: Dumping the results of the MODE SENSE packet command\n"); | ||
| 4425 | printk(KERN_INFO "ide-tape: Mode Parameter Header:\n"); | ||
| 4426 | printk(KERN_INFO "ide-tape: Mode Data Length - %d\n",header->mode_data_length); | ||
| 4427 | printk(KERN_INFO "ide-tape: Medium Type - %d\n",header->medium_type); | ||
| 4428 | printk(KERN_INFO "ide-tape: Device Specific Parameter - %d\n",header->dsp); | ||
| 4429 | printk(KERN_INFO "ide-tape: Block Descriptor Length - %d\n",header->bdl); | ||
| 4430 | |||
| 4431 | printk(KERN_INFO "ide-tape: Capabilities and Mechanical Status Page:\n"); | ||
| 4432 | printk(KERN_INFO "ide-tape: Page code - %d\n",capabilities->page_code); | ||
| 4433 | printk(KERN_INFO "ide-tape: Page length - %d\n",capabilities->page_length); | ||
| 4434 | printk(KERN_INFO "ide-tape: Read only - %s\n",capabilities->ro ? "Yes":"No"); | ||
| 4435 | printk(KERN_INFO "ide-tape: Supports reverse space - %s\n",capabilities->sprev ? "Yes":"No"); | ||
| 4436 | printk(KERN_INFO "ide-tape: Supports erase initiated formatting - %s\n",capabilities->efmt ? "Yes":"No"); | ||
| 4437 | printk(KERN_INFO "ide-tape: Supports QFA two Partition format - %s\n",capabilities->qfa ? "Yes":"No"); | ||
| 4438 | printk(KERN_INFO "ide-tape: Supports locking the medium - %s\n",capabilities->lock ? "Yes":"No"); | ||
| 4439 | printk(KERN_INFO "ide-tape: The volume is currently locked - %s\n",capabilities->locked ? "Yes":"No"); | ||
| 4440 | printk(KERN_INFO "ide-tape: The device defaults in the prevent state - %s\n",capabilities->prevent ? "Yes":"No"); | ||
| 4441 | printk(KERN_INFO "ide-tape: Supports ejecting the medium - %s\n",capabilities->eject ? "Yes":"No"); | ||
| 4442 | printk(KERN_INFO "ide-tape: Supports error correction - %s\n",capabilities->ecc ? "Yes":"No"); | ||
| 4443 | printk(KERN_INFO "ide-tape: Supports data compression - %s\n",capabilities->cmprs ? "Yes":"No"); | ||
| 4444 | printk(KERN_INFO "ide-tape: Supports 512 bytes block size - %s\n",capabilities->blk512 ? "Yes":"No"); | ||
| 4445 | printk(KERN_INFO "ide-tape: Supports 1024 bytes block size - %s\n",capabilities->blk1024 ? "Yes":"No"); | ||
| 4446 | printk(KERN_INFO "ide-tape: Supports 32768 bytes block size / Restricted byte count for PIO transfers - %s\n",capabilities->blk32768 ? "Yes":"No"); | ||
| 4447 | printk(KERN_INFO "ide-tape: Maximum supported speed in KBps - %d\n",capabilities->max_speed); | ||
| 4448 | printk(KERN_INFO "ide-tape: Continuous transfer limits in blocks - %d\n",capabilities->ctl); | ||
| 4449 | printk(KERN_INFO "ide-tape: Current speed in KBps - %d\n",capabilities->speed); | ||
| 4450 | printk(KERN_INFO "ide-tape: Buffer size - %d\n",capabilities->buffer_size*512); | ||
| 4451 | #endif /* IDETAPE_DEBUG_INFO */ | ||
| 4452 | } | ||
| 4453 | |||
| 4454 | /* | ||
| 4455 | * ide_get_blocksize_from_block_descriptor does a mode sense page 0 with block descriptor | ||
| 4456 | * and if it succeeds sets the tape block size with the reported value | ||
| 4457 | */ | ||
| 4458 | static void idetape_get_blocksize_from_block_descriptor(ide_drive_t *drive) | ||
| 4459 | { | ||
| 4460 | |||
| 4461 | idetape_tape_t *tape = drive->driver_data; | ||
| 4462 | idetape_pc_t pc; | ||
| 4463 | idetape_mode_parameter_header_t *header; | ||
| 4464 | idetape_parameter_block_descriptor_t *block_descrp; | ||
| 4465 | |||
| 4466 | idetape_create_mode_sense_cmd(&pc, IDETAPE_BLOCK_DESCRIPTOR); | ||
| 4467 | if (idetape_queue_pc_tail(drive, &pc)) { | ||
| 4468 | printk(KERN_ERR "ide-tape: Can't get block descriptor\n"); | ||
| 4469 | if (tape->tape_block_size == 0) { | ||
| 4470 | printk(KERN_WARNING "ide-tape: Cannot deal with zero block size, assume 32k\n"); | ||
| 4471 | tape->tape_block_size = 32768; | ||
| 4472 | } | ||
| 4473 | return; | ||
| 4474 | } | ||
| 4475 | header = (idetape_mode_parameter_header_t *) pc.buffer; | ||
| 4476 | block_descrp = (idetape_parameter_block_descriptor_t *) (pc.buffer + sizeof(idetape_mode_parameter_header_t)); | ||
| 4477 | tape->tape_block_size =( block_descrp->length[0]<<16) + (block_descrp->length[1]<<8) + block_descrp->length[2]; | ||
| 4478 | tape->drv_write_prot = (header->dsp & 0x80) >> 7; | ||
| 4479 | |||
| 4480 | #if IDETAPE_DEBUG_INFO | ||
| 4481 | printk(KERN_INFO "ide-tape: Adjusted block size - %d\n", tape->tape_block_size); | ||
| 4482 | #endif /* IDETAPE_DEBUG_INFO */ | ||
| 4483 | } | 3627 | } |
| 4484 | 3628 | ||
| 4485 | #ifdef CONFIG_IDE_PROC_FS | 3629 | #ifdef CONFIG_IDE_PROC_FS |
| @@ -4490,13 +3634,15 @@ static void idetape_add_settings (ide_drive_t *drive) | |||
| 4490 | /* | 3634 | /* |
| 4491 | * drive setting name read/write data type min max mul_factor div_factor data pointer set function | 3635 | * drive setting name read/write data type min max mul_factor div_factor data pointer set function |
| 4492 | */ | 3636 | */ |
| 4493 | ide_add_setting(drive, "buffer", SETTING_READ, TYPE_SHORT, 0, 0xffff, 1, 2, &tape->capabilities.buffer_size, NULL); | 3637 | ide_add_setting(drive, "buffer", SETTING_READ, TYPE_SHORT, 0, 0xffff, |
| 3638 | 1, 2, (u16 *)&tape->caps[16], NULL); | ||
| 4494 | ide_add_setting(drive, "pipeline_min", SETTING_RW, TYPE_INT, 1, 0xffff, tape->stage_size / 1024, 1, &tape->min_pipeline, NULL); | 3639 | ide_add_setting(drive, "pipeline_min", SETTING_RW, TYPE_INT, 1, 0xffff, tape->stage_size / 1024, 1, &tape->min_pipeline, NULL); |
| 4495 | ide_add_setting(drive, "pipeline", SETTING_RW, TYPE_INT, 1, 0xffff, tape->stage_size / 1024, 1, &tape->max_stages, NULL); | 3640 | ide_add_setting(drive, "pipeline", SETTING_RW, TYPE_INT, 1, 0xffff, tape->stage_size / 1024, 1, &tape->max_stages, NULL); |
| 4496 | ide_add_setting(drive, "pipeline_max", SETTING_RW, TYPE_INT, 1, 0xffff, tape->stage_size / 1024, 1, &tape->max_pipeline, NULL); | 3641 | ide_add_setting(drive, "pipeline_max", SETTING_RW, TYPE_INT, 1, 0xffff, tape->stage_size / 1024, 1, &tape->max_pipeline, NULL); |
| 4497 | ide_add_setting(drive, "pipeline_used", SETTING_READ, TYPE_INT, 0, 0xffff, tape->stage_size / 1024, 1, &tape->nr_stages, NULL); | 3642 | ide_add_setting(drive, "pipeline_used", SETTING_READ, TYPE_INT, 0, 0xffff, tape->stage_size / 1024, 1, &tape->nr_stages, NULL); |
| 4498 | ide_add_setting(drive, "pipeline_pending", SETTING_READ, TYPE_INT, 0, 0xffff, tape->stage_size / 1024, 1, &tape->nr_pending_stages, NULL); | 3643 | ide_add_setting(drive, "pipeline_pending", SETTING_READ, TYPE_INT, 0, 0xffff, tape->stage_size / 1024, 1, &tape->nr_pending_stages, NULL); |
| 4499 | ide_add_setting(drive, "speed", SETTING_READ, TYPE_SHORT, 0, 0xffff, 1, 1, &tape->capabilities.speed, NULL); | 3644 | ide_add_setting(drive, "speed", SETTING_READ, TYPE_SHORT, 0, 0xffff, |
| 3645 | 1, 1, (u16 *)&tape->caps[14], NULL); | ||
| 4500 | ide_add_setting(drive, "stage", SETTING_READ, TYPE_INT, 0, 0xffff, 1, 1024, &tape->stage_size, NULL); | 3646 | ide_add_setting(drive, "stage", SETTING_READ, TYPE_INT, 0, 0xffff, 1, 1024, &tape->stage_size, NULL); |
| 4501 | ide_add_setting(drive, "tdsc", SETTING_RW, TYPE_INT, IDETAPE_DSC_RW_MIN, IDETAPE_DSC_RW_MAX, 1000, HZ, &tape->best_dsc_rw_frequency, NULL); | 3647 | ide_add_setting(drive, "tdsc", SETTING_RW, TYPE_INT, IDETAPE_DSC_RW_MIN, IDETAPE_DSC_RW_MAX, 1000, HZ, &tape->best_dsc_rw_frequency, NULL); |
| 4502 | ide_add_setting(drive, "dsc_overlap", SETTING_RW, TYPE_BYTE, 0, 1, 1, 1, &drive->dsc_overlap, NULL); | 3648 | ide_add_setting(drive, "dsc_overlap", SETTING_RW, TYPE_BYTE, 0, 1, 1, 1, &drive->dsc_overlap, NULL); |
| @@ -4528,6 +3674,7 @@ static void idetape_setup (ide_drive_t *drive, idetape_tape_t *tape, int minor) | |||
| 4528 | struct idetape_id_gcw gcw; | 3674 | struct idetape_id_gcw gcw; |
| 4529 | int stage_size; | 3675 | int stage_size; |
| 4530 | struct sysinfo si; | 3676 | struct sysinfo si; |
| 3677 | u16 *ctl = (u16 *)&tape->caps[12]; | ||
| 4531 | 3678 | ||
| 4532 | spin_lock_init(&tape->spinlock); | 3679 | spin_lock_init(&tape->spinlock); |
| 4533 | drive->dsc_overlap = 1; | 3680 | drive->dsc_overlap = 1; |
| @@ -4555,13 +3702,13 @@ static void idetape_setup (ide_drive_t *drive, idetape_tape_t *tape, int minor) | |||
| 4555 | 3702 | ||
| 4556 | idetape_get_inquiry_results(drive); | 3703 | idetape_get_inquiry_results(drive); |
| 4557 | idetape_get_mode_sense_results(drive); | 3704 | idetape_get_mode_sense_results(drive); |
| 4558 | idetape_get_blocksize_from_block_descriptor(drive); | 3705 | ide_tape_get_bsize_from_bdesc(drive); |
| 4559 | tape->user_bs_factor = 1; | 3706 | tape->user_bs_factor = 1; |
| 4560 | tape->stage_size = tape->capabilities.ctl * tape->tape_block_size; | 3707 | tape->stage_size = *ctl * tape->tape_block_size; |
| 4561 | while (tape->stage_size > 0xffff) { | 3708 | while (tape->stage_size > 0xffff) { |
| 4562 | printk(KERN_NOTICE "ide-tape: decreasing stage size\n"); | 3709 | printk(KERN_NOTICE "ide-tape: decreasing stage size\n"); |
| 4563 | tape->capabilities.ctl /= 2; | 3710 | *ctl /= 2; |
| 4564 | tape->stage_size = tape->capabilities.ctl * tape->tape_block_size; | 3711 | tape->stage_size = *ctl * tape->tape_block_size; |
| 4565 | } | 3712 | } |
| 4566 | stage_size = tape->stage_size; | 3713 | stage_size = tape->stage_size; |
| 4567 | tape->pages_per_stage = stage_size / PAGE_SIZE; | 3714 | tape->pages_per_stage = stage_size / PAGE_SIZE; |
| @@ -4570,11 +3717,8 @@ static void idetape_setup (ide_drive_t *drive, idetape_tape_t *tape, int minor) | |||
| 4570 | tape->excess_bh_size = PAGE_SIZE - stage_size % PAGE_SIZE; | 3717 | tape->excess_bh_size = PAGE_SIZE - stage_size % PAGE_SIZE; |
| 4571 | } | 3718 | } |
| 4572 | 3719 | ||
| 4573 | /* | 3720 | /* Select the "best" DSC read/write polling freq and pipeline size. */ |
| 4574 | * Select the "best" DSC read/write polling frequency | 3721 | speed = max(*(u16 *)&tape->caps[14], *(u16 *)&tape->caps[8]); |
| 4575 | * and pipeline size. | ||
| 4576 | */ | ||
| 4577 | speed = max(tape->capabilities.speed, tape->capabilities.max_speed); | ||
| 4578 | 3722 | ||
| 4579 | tape->max_stages = speed * 1000 * 10 / tape->stage_size; | 3723 | tape->max_stages = speed * 1000 * 10 / tape->stage_size; |
| 4580 | 3724 | ||
| @@ -4591,7 +3735,7 @@ static void idetape_setup (ide_drive_t *drive, idetape_tape_t *tape, int minor) | |||
| 4591 | tape->max_stages = tape->min_pipeline = tape->max_pipeline = 1; | 3735 | tape->max_stages = tape->min_pipeline = tape->max_pipeline = 1; |
| 4592 | 3736 | ||
| 4593 | t1 = (tape->stage_size * HZ) / (speed * 1000); | 3737 | t1 = (tape->stage_size * HZ) / (speed * 1000); |
| 4594 | tmid = (tape->capabilities.buffer_size * 32 * HZ) / (speed * 125); | 3738 | tmid = (*(u16 *)&tape->caps[16] * 32 * HZ) / (speed * 125); |
| 4595 | tn = (IDETAPE_FIFO_THRESHOLD * tape->stage_size * HZ) / (speed * 1000); | 3739 | tn = (IDETAPE_FIFO_THRESHOLD * tape->stage_size * HZ) / (speed * 1000); |
| 4596 | 3740 | ||
| 4597 | if (tape->max_stages) | 3741 | if (tape->max_stages) |
| @@ -4606,8 +3750,8 @@ static void idetape_setup (ide_drive_t *drive, idetape_tape_t *tape, int minor) | |||
| 4606 | tape->best_dsc_rw_frequency = max_t(unsigned long, min_t(unsigned long, t, IDETAPE_DSC_RW_MAX), IDETAPE_DSC_RW_MIN); | 3750 | tape->best_dsc_rw_frequency = max_t(unsigned long, min_t(unsigned long, t, IDETAPE_DSC_RW_MAX), IDETAPE_DSC_RW_MIN); |
| 4607 | printk(KERN_INFO "ide-tape: %s <-> %s: %dKBps, %d*%dkB buffer, " | 3751 | printk(KERN_INFO "ide-tape: %s <-> %s: %dKBps, %d*%dkB buffer, " |
| 4608 | "%dkB pipeline, %lums tDSC%s\n", | 3752 | "%dkB pipeline, %lums tDSC%s\n", |
| 4609 | drive->name, tape->name, tape->capabilities.speed, | 3753 | drive->name, tape->name, *(u16 *)&tape->caps[14], |
| 4610 | (tape->capabilities.buffer_size * 512) / tape->stage_size, | 3754 | (*(u16 *)&tape->caps[16] * 512) / tape->stage_size, |
| 4611 | tape->stage_size / 1024, | 3755 | tape->stage_size / 1024, |
| 4612 | tape->max_stages * tape->stage_size / 1024, | 3756 | tape->max_stages * tape->stage_size / 1024, |
| 4613 | tape->best_dsc_rw_frequency * 1000 / HZ, | 3757 | tape->best_dsc_rw_frequency * 1000 / HZ, |
diff --git a/drivers/ide/ide-taskfile.c b/drivers/ide/ide-taskfile.c index 16a9a581d089..4e1da1c78cb5 100644 --- a/drivers/ide/ide-taskfile.c +++ b/drivers/ide/ide-taskfile.c | |||
| @@ -755,6 +755,7 @@ int ide_cmd_ioctl (ide_drive_t *drive, unsigned int cmd, unsigned long arg) | |||
| 755 | u8 args[4], xfer_rate = 0; | 755 | u8 args[4], xfer_rate = 0; |
| 756 | ide_task_t tfargs; | 756 | ide_task_t tfargs; |
| 757 | struct ide_taskfile *tf = &tfargs.tf; | 757 | struct ide_taskfile *tf = &tfargs.tf; |
| 758 | struct hd_driveid *id = drive->id; | ||
| 758 | 759 | ||
| 759 | if (NULL == (void *) arg) { | 760 | if (NULL == (void *) arg) { |
| 760 | struct request rq; | 761 | struct request rq; |
| @@ -792,10 +793,16 @@ int ide_cmd_ioctl (ide_drive_t *drive, unsigned int cmd, unsigned long arg) | |||
| 792 | return -ENOMEM; | 793 | return -ENOMEM; |
| 793 | } | 794 | } |
| 794 | 795 | ||
| 795 | if (set_transfer(drive, &tfargs)) { | 796 | if (tf->command == WIN_SETFEATURES && |
| 797 | tf->feature == SETFEATURES_XFER && | ||
| 798 | tf->nsect >= XFER_SW_DMA_0 && | ||
| 799 | (id->dma_ultra || id->dma_mword || id->dma_1word)) { | ||
| 796 | xfer_rate = args[1]; | 800 | xfer_rate = args[1]; |
| 797 | if (ide_ata66_check(drive, &tfargs)) | 801 | if (tf->nsect > XFER_UDMA_2 && !eighty_ninty_three(drive)) { |
| 802 | printk(KERN_WARNING "%s: UDMA speeds >UDMA33 cannot " | ||
| 803 | "be set\n", drive->name); | ||
| 798 | goto abort; | 804 | goto abort; |
| 805 | } | ||
| 799 | } | 806 | } |
| 800 | 807 | ||
| 801 | err = ide_raw_taskfile(drive, &tfargs, buf, args[3]); | 808 | err = ide_raw_taskfile(drive, &tfargs, buf, args[3]); |
diff --git a/drivers/ide/ide.c b/drivers/ide/ide.c index ab9ca2b5b66c..ac6136001615 100644 --- a/drivers/ide/ide.c +++ b/drivers/ide/ide.c | |||
| @@ -499,6 +499,8 @@ void ide_remove_port_from_hwgroup(ide_hwif_t *hwif) | |||
| 499 | /** | 499 | /** |
| 500 | * ide_unregister - free an IDE interface | 500 | * ide_unregister - free an IDE interface |
| 501 | * @index: index of interface (will change soon to a pointer) | 501 | * @index: index of interface (will change soon to a pointer) |
| 502 | * @init_default: init default hwif flag | ||
| 503 | * @restore: restore hwif flag | ||
| 502 | * | 504 | * |
| 503 | * Perform the final unregister of an IDE interface. At the moment | 505 | * Perform the final unregister of an IDE interface. At the moment |
| 504 | * we don't refcount interfaces so this will also get split up. | 506 | * we don't refcount interfaces so this will also get split up. |
| @@ -518,7 +520,7 @@ void ide_remove_port_from_hwgroup(ide_hwif_t *hwif) | |||
| 518 | * This is raving bonkers. | 520 | * This is raving bonkers. |
| 519 | */ | 521 | */ |
| 520 | 522 | ||
| 521 | void ide_unregister(unsigned int index) | 523 | void ide_unregister(unsigned int index, int init_default, int restore) |
| 522 | { | 524 | { |
| 523 | ide_drive_t *drive; | 525 | ide_drive_t *drive; |
| 524 | ide_hwif_t *hwif, *g; | 526 | ide_hwif_t *hwif, *g; |
| @@ -602,9 +604,12 @@ void ide_unregister(unsigned int index) | |||
| 602 | 604 | ||
| 603 | /* restore hwif data to pristine status */ | 605 | /* restore hwif data to pristine status */ |
| 604 | ide_init_port_data(hwif, index); | 606 | ide_init_port_data(hwif, index); |
| 605 | init_hwif_default(hwif, index); | ||
| 606 | 607 | ||
| 607 | ide_hwif_restore(hwif, &tmp_hwif); | 608 | if (init_default) |
| 609 | init_hwif_default(hwif, index); | ||
| 610 | |||
| 611 | if (restore) | ||
| 612 | ide_hwif_restore(hwif, &tmp_hwif); | ||
| 608 | 613 | ||
| 609 | abort: | 614 | abort: |
| 610 | spin_unlock_irq(&ide_lock); | 615 | spin_unlock_irq(&ide_lock); |
| @@ -678,6 +683,31 @@ void ide_init_port_hw(ide_hwif_t *hwif, hw_regs_t *hw) | |||
| 678 | } | 683 | } |
| 679 | EXPORT_SYMBOL_GPL(ide_init_port_hw); | 684 | EXPORT_SYMBOL_GPL(ide_init_port_hw); |
| 680 | 685 | ||
| 686 | ide_hwif_t *ide_deprecated_find_port(unsigned long base) | ||
| 687 | { | ||
| 688 | ide_hwif_t *hwif; | ||
| 689 | int i; | ||
| 690 | |||
| 691 | for (i = 0; i < MAX_HWIFS; i++) { | ||
| 692 | hwif = &ide_hwifs[i]; | ||
| 693 | if (hwif->io_ports[IDE_DATA_OFFSET] == base) | ||
| 694 | goto found; | ||
| 695 | } | ||
| 696 | |||
| 697 | for (i = 0; i < MAX_HWIFS; i++) { | ||
| 698 | hwif = &ide_hwifs[i]; | ||
| 699 | if (hwif->hold) | ||
| 700 | continue; | ||
| 701 | if (!hwif->present && hwif->mate == NULL) | ||
| 702 | goto found; | ||
| 703 | } | ||
| 704 | |||
| 705 | hwif = NULL; | ||
| 706 | found: | ||
| 707 | return hwif; | ||
| 708 | } | ||
| 709 | EXPORT_SYMBOL_GPL(ide_deprecated_find_port); | ||
| 710 | |||
| 681 | /** | 711 | /** |
| 682 | * ide_register_hw - register IDE interface | 712 | * ide_register_hw - register IDE interface |
| 683 | * @hw: hardware registers | 713 | * @hw: hardware registers |
| @@ -697,38 +727,26 @@ int ide_register_hw(hw_regs_t *hw, void (*quirkproc)(ide_drive_t *), | |||
| 697 | u8 idx[4] = { 0xff, 0xff, 0xff, 0xff }; | 727 | u8 idx[4] = { 0xff, 0xff, 0xff, 0xff }; |
| 698 | 728 | ||
| 699 | do { | 729 | do { |
| 700 | for (index = 0; index < MAX_HWIFS; ++index) { | 730 | hwif = ide_deprecated_find_port(hw->io_ports[IDE_DATA_OFFSET]); |
| 701 | hwif = &ide_hwifs[index]; | 731 | index = hwif->index; |
| 702 | if (hwif->io_ports[IDE_DATA_OFFSET] == hw->io_ports[IDE_DATA_OFFSET]) | 732 | if (hwif) |
| 703 | goto found; | 733 | goto found; |
| 704 | } | ||
| 705 | for (index = 0; index < MAX_HWIFS; ++index) { | ||
| 706 | hwif = &ide_hwifs[index]; | ||
| 707 | if (hwif->hold) | ||
| 708 | continue; | ||
| 709 | if (!hwif->present && hwif->mate == NULL) | ||
| 710 | goto found; | ||
| 711 | } | ||
| 712 | for (index = 0; index < MAX_HWIFS; index++) | 734 | for (index = 0; index < MAX_HWIFS; index++) |
| 713 | ide_unregister(index); | 735 | ide_unregister(index, 1, 1); |
| 714 | } while (retry--); | 736 | } while (retry--); |
| 715 | return -1; | 737 | return -1; |
| 716 | found: | 738 | found: |
| 717 | if (hwif->present) | 739 | if (hwif->present) |
| 718 | ide_unregister(index); | 740 | ide_unregister(index, 0, 1); |
| 719 | else if (!hwif->hold) { | 741 | else if (!hwif->hold) |
| 720 | ide_init_port_data(hwif, index); | 742 | ide_init_port_data(hwif, index); |
| 721 | init_hwif_default(hwif, index); | ||
| 722 | } | ||
| 723 | if (hwif->present) | ||
| 724 | return -1; | ||
| 725 | 743 | ||
| 726 | ide_init_port_hw(hwif, hw); | 744 | ide_init_port_hw(hwif, hw); |
| 727 | hwif->quirkproc = quirkproc; | 745 | hwif->quirkproc = quirkproc; |
| 728 | 746 | ||
| 729 | idx[0] = index; | 747 | idx[0] = index; |
| 730 | 748 | ||
| 731 | ide_device_add(idx); | 749 | ide_device_add(idx, NULL); |
| 732 | 750 | ||
| 733 | if (hwifp) | 751 | if (hwifp) |
| 734 | *hwifp = hwif; | 752 | *hwifp = hwif; |
| @@ -791,10 +809,6 @@ int set_io_32bit(ide_drive_t *drive, int arg) | |||
| 791 | return -EBUSY; | 809 | return -EBUSY; |
| 792 | 810 | ||
| 793 | drive->io_32bit = arg; | 811 | drive->io_32bit = arg; |
| 794 | #ifdef CONFIG_BLK_DEV_DTC2278 | ||
| 795 | if (HWIF(drive)->chipset == ide_dtc2278) | ||
| 796 | HWIF(drive)->drives[!drive->select.b.unit].io_32bit = arg; | ||
| 797 | #endif /* CONFIG_BLK_DEV_DTC2278 */ | ||
| 798 | 812 | ||
| 799 | spin_unlock_irq(&ide_lock); | 813 | spin_unlock_irq(&ide_lock); |
| 800 | 814 | ||
| @@ -1021,11 +1035,8 @@ int generic_ide_ioctl(ide_drive_t *drive, struct file *file, struct block_device | |||
| 1021 | case HDIO_GET_NICE: | 1035 | case HDIO_GET_NICE: |
| 1022 | return put_user(drive->dsc_overlap << IDE_NICE_DSC_OVERLAP | | 1036 | return put_user(drive->dsc_overlap << IDE_NICE_DSC_OVERLAP | |
| 1023 | drive->atapi_overlap << IDE_NICE_ATAPI_OVERLAP | | 1037 | drive->atapi_overlap << IDE_NICE_ATAPI_OVERLAP | |
| 1024 | drive->nice0 << IDE_NICE_0 | | 1038 | drive->nice1 << IDE_NICE_1, |
| 1025 | drive->nice1 << IDE_NICE_1 | | ||
| 1026 | drive->nice2 << IDE_NICE_2, | ||
| 1027 | (long __user *) arg); | 1039 | (long __user *) arg); |
| 1028 | |||
| 1029 | #ifdef CONFIG_IDE_TASK_IOCTL | 1040 | #ifdef CONFIG_IDE_TASK_IOCTL |
| 1030 | case HDIO_DRIVE_TASKFILE: | 1041 | case HDIO_DRIVE_TASKFILE: |
| 1031 | if (!capable(CAP_SYS_ADMIN) || !capable(CAP_SYS_RAWIO)) | 1042 | if (!capable(CAP_SYS_ADMIN) || !capable(CAP_SYS_RAWIO)) |
| @@ -1066,7 +1077,7 @@ int generic_ide_ioctl(ide_drive_t *drive, struct file *file, struct block_device | |||
| 1066 | case HDIO_UNREGISTER_HWIF: | 1077 | case HDIO_UNREGISTER_HWIF: |
| 1067 | if (!capable(CAP_SYS_RAWIO)) return -EACCES; | 1078 | if (!capable(CAP_SYS_RAWIO)) return -EACCES; |
| 1068 | /* (arg > MAX_HWIFS) checked in function */ | 1079 | /* (arg > MAX_HWIFS) checked in function */ |
| 1069 | ide_unregister(arg); | 1080 | ide_unregister(arg, 1, 1); |
| 1070 | return 0; | 1081 | return 0; |
| 1071 | case HDIO_SET_NICE: | 1082 | case HDIO_SET_NICE: |
| 1072 | if (!capable(CAP_SYS_ADMIN)) return -EACCES; | 1083 | if (!capable(CAP_SYS_ADMIN)) return -EACCES; |
| @@ -1711,7 +1722,7 @@ void __exit cleanup_module (void) | |||
| 1711 | int index; | 1722 | int index; |
| 1712 | 1723 | ||
| 1713 | for (index = 0; index < MAX_HWIFS; ++index) | 1724 | for (index = 0; index < MAX_HWIFS; ++index) |
| 1714 | ide_unregister(index); | 1725 | ide_unregister(index, 0, 0); |
| 1715 | 1726 | ||
| 1716 | proc_ide_destroy(); | 1727 | proc_ide_destroy(); |
| 1717 | 1728 | ||
diff --git a/drivers/ide/legacy/ali14xx.c b/drivers/ide/legacy/ali14xx.c index e3ea2096804a..d4d1a6bea599 100644 --- a/drivers/ide/legacy/ali14xx.c +++ b/drivers/ide/legacy/ali14xx.c | |||
| @@ -191,9 +191,14 @@ static int __init initRegisters (void) { | |||
| 191 | return t; | 191 | return t; |
| 192 | } | 192 | } |
| 193 | 193 | ||
| 194 | static const struct ide_port_info ali14xx_port_info = { | ||
| 195 | .chipset = ide_ali14xx, | ||
| 196 | .host_flags = IDE_HFLAG_NO_DMA | IDE_HFLAG_NO_AUTOTUNE, | ||
| 197 | .pio_mask = ATA_PIO4, | ||
| 198 | }; | ||
| 199 | |||
| 194 | static int __init ali14xx_probe(void) | 200 | static int __init ali14xx_probe(void) |
| 195 | { | 201 | { |
| 196 | ide_hwif_t *hwif, *mate; | ||
| 197 | static u8 idx[4] = { 0, 1, 0xff, 0xff }; | 202 | static u8 idx[4] = { 0, 1, 0xff, 0xff }; |
| 198 | 203 | ||
| 199 | printk(KERN_DEBUG "ali14xx: base=0x%03x, regOn=0x%02x.\n", | 204 | printk(KERN_DEBUG "ali14xx: base=0x%03x, regOn=0x%02x.\n", |
| @@ -205,21 +210,10 @@ static int __init ali14xx_probe(void) | |||
| 205 | return 1; | 210 | return 1; |
| 206 | } | 211 | } |
| 207 | 212 | ||
| 208 | hwif = &ide_hwifs[0]; | 213 | ide_hwifs[0].set_pio_mode = &ali14xx_set_pio_mode; |
| 209 | mate = &ide_hwifs[1]; | 214 | ide_hwifs[1].set_pio_mode = &ali14xx_set_pio_mode; |
| 210 | |||
| 211 | hwif->chipset = ide_ali14xx; | ||
| 212 | hwif->pio_mask = ATA_PIO4; | ||
| 213 | hwif->set_pio_mode = &ali14xx_set_pio_mode; | ||
| 214 | hwif->mate = mate; | ||
| 215 | |||
| 216 | mate->chipset = ide_ali14xx; | ||
| 217 | mate->pio_mask = ATA_PIO4; | ||
| 218 | mate->set_pio_mode = &ali14xx_set_pio_mode; | ||
| 219 | mate->mate = hwif; | ||
| 220 | mate->channel = 1; | ||
| 221 | 215 | ||
| 222 | ide_device_add(idx); | 216 | ide_device_add(idx, &ali14xx_port_info); |
| 223 | 217 | ||
| 224 | return 0; | 218 | return 0; |
| 225 | } | 219 | } |
diff --git a/drivers/ide/legacy/buddha.c b/drivers/ide/legacy/buddha.c index dd3d198ade47..8bdb79da17e8 100644 --- a/drivers/ide/legacy/buddha.c +++ b/drivers/ide/legacy/buddha.c | |||
| @@ -232,7 +232,7 @@ fail_base2: | |||
| 232 | } | 232 | } |
| 233 | } | 233 | } |
| 234 | 234 | ||
| 235 | ide_device_add(idx); | 235 | ide_device_add(idx, NULL); |
| 236 | } | 236 | } |
| 237 | 237 | ||
| 238 | return 0; | 238 | return 0; |
diff --git a/drivers/ide/legacy/dtc2278.c b/drivers/ide/legacy/dtc2278.c index 611c9705a3ae..73396f70f2b7 100644 --- a/drivers/ide/legacy/dtc2278.c +++ b/drivers/ide/legacy/dtc2278.c | |||
| @@ -84,14 +84,20 @@ static void dtc2278_set_pio_mode(ide_drive_t *drive, const u8 pio) | |||
| 84 | /* Actually we do - there is a data sheet available for the | 84 | /* Actually we do - there is a data sheet available for the |
| 85 | Winbond but does anyone actually care */ | 85 | Winbond but does anyone actually care */ |
| 86 | } | 86 | } |
| 87 | |||
| 88 | /* | ||
| 89 | * 32bit I/O has to be enabled for *both* drives at the same time. | ||
| 90 | */ | ||
| 91 | drive->io_32bit = 1; | ||
| 92 | HWIF(drive)->drives[!drive->select.b.unit].io_32bit = 1; | ||
| 93 | } | 87 | } |
| 94 | 88 | ||
| 89 | static const struct ide_port_info dtc2278_port_info __initdata = { | ||
| 90 | .chipset = ide_dtc2278, | ||
| 91 | .host_flags = IDE_HFLAG_SERIALIZE | | ||
| 92 | IDE_HFLAG_NO_UNMASK_IRQS | | ||
| 93 | IDE_HFLAG_IO_32BIT | | ||
| 94 | /* disallow ->io_32bit changes */ | ||
| 95 | IDE_HFLAG_NO_IO_32BIT | | ||
| 96 | IDE_HFLAG_NO_DMA | | ||
| 97 | IDE_HFLAG_NO_AUTOTUNE, | ||
| 98 | .pio_mask = ATA_PIO4, | ||
| 99 | }; | ||
| 100 | |||
| 95 | static int __init dtc2278_probe(void) | 101 | static int __init dtc2278_probe(void) |
| 96 | { | 102 | { |
| 97 | unsigned long flags; | 103 | unsigned long flags; |
| @@ -122,23 +128,9 @@ static int __init dtc2278_probe(void) | |||
| 122 | #endif | 128 | #endif |
| 123 | local_irq_restore(flags); | 129 | local_irq_restore(flags); |
| 124 | 130 | ||
| 125 | hwif->serialized = 1; | ||
| 126 | hwif->chipset = ide_dtc2278; | ||
| 127 | hwif->pio_mask = ATA_PIO4; | ||
| 128 | hwif->set_pio_mode = &dtc2278_set_pio_mode; | 131 | hwif->set_pio_mode = &dtc2278_set_pio_mode; |
| 129 | hwif->drives[0].no_unmask = 1; | 132 | |
| 130 | hwif->drives[1].no_unmask = 1; | 133 | ide_device_add(idx, &dtc2278_port_info); |
| 131 | hwif->mate = mate; | ||
| 132 | |||
| 133 | mate->serialized = 1; | ||
| 134 | mate->chipset = ide_dtc2278; | ||
| 135 | mate->pio_mask = ATA_PIO4; | ||
| 136 | mate->drives[0].no_unmask = 1; | ||
| 137 | mate->drives[1].no_unmask = 1; | ||
| 138 | mate->mate = hwif; | ||
| 139 | mate->channel = 1; | ||
| 140 | |||
| 141 | ide_device_add(idx); | ||
| 142 | 134 | ||
| 143 | return 0; | 135 | return 0; |
| 144 | } | 136 | } |
diff --git a/drivers/ide/legacy/falconide.c b/drivers/ide/legacy/falconide.c index c9bd6bfb1f3b..85b69a82825f 100644 --- a/drivers/ide/legacy/falconide.c +++ b/drivers/ide/legacy/falconide.c | |||
| @@ -83,7 +83,7 @@ static int __init falconide_init(void) | |||
| 83 | ide_init_port_data(hwif, index); | 83 | ide_init_port_data(hwif, index); |
| 84 | ide_init_port_hw(hwif, &hw); | 84 | ide_init_port_hw(hwif, &hw); |
| 85 | 85 | ||
| 86 | ide_device_add(idx); | 86 | ide_device_add(idx, NULL); |
| 87 | } | 87 | } |
| 88 | } | 88 | } |
| 89 | 89 | ||
diff --git a/drivers/ide/legacy/gayle.c b/drivers/ide/legacy/gayle.c index f67c51a2c84a..fc29ce75aff1 100644 --- a/drivers/ide/legacy/gayle.c +++ b/drivers/ide/legacy/gayle.c | |||
| @@ -186,7 +186,7 @@ found: | |||
| 186 | release_mem_region(res_start, res_n); | 186 | release_mem_region(res_start, res_n); |
| 187 | } | 187 | } |
| 188 | 188 | ||
| 189 | ide_device_add(idx); | 189 | ide_device_add(idx, NULL); |
| 190 | 190 | ||
| 191 | return 0; | 191 | return 0; |
| 192 | } | 192 | } |
diff --git a/drivers/ide/legacy/ht6560b.c b/drivers/ide/legacy/ht6560b.c index 57bc15cddca0..02d12c74764a 100644 --- a/drivers/ide/legacy/ht6560b.c +++ b/drivers/ide/legacy/ht6560b.c | |||
| @@ -300,16 +300,36 @@ static void ht6560b_set_pio_mode(ide_drive_t *drive, const u8 pio) | |||
| 300 | #endif | 300 | #endif |
| 301 | } | 301 | } |
| 302 | 302 | ||
| 303 | static void __init ht6560b_port_init_devs(ide_hwif_t *hwif) | ||
| 304 | { | ||
| 305 | /* Setting default configurations for drives. */ | ||
| 306 | int t = (HT_CONFIG_DEFAULT << 8) | HT_TIMING_DEFAULT; | ||
| 307 | |||
| 308 | if (hwif->channel) | ||
| 309 | t |= (HT_SECONDARY_IF << 8); | ||
| 310 | |||
| 311 | hwif->drives[0].drive_data = t; | ||
| 312 | hwif->drives[1].drive_data = t; | ||
| 313 | } | ||
| 314 | |||
| 303 | int probe_ht6560b = 0; | 315 | int probe_ht6560b = 0; |
| 304 | 316 | ||
| 305 | module_param_named(probe, probe_ht6560b, bool, 0); | 317 | module_param_named(probe, probe_ht6560b, bool, 0); |
| 306 | MODULE_PARM_DESC(probe, "probe for HT6560B chipset"); | 318 | MODULE_PARM_DESC(probe, "probe for HT6560B chipset"); |
| 307 | 319 | ||
| 320 | static const struct ide_port_info ht6560b_port_info __initdata = { | ||
| 321 | .chipset = ide_ht6560b, | ||
| 322 | .host_flags = IDE_HFLAG_SERIALIZE | /* is this needed? */ | ||
| 323 | IDE_HFLAG_NO_DMA | | ||
| 324 | IDE_HFLAG_NO_AUTOTUNE | | ||
| 325 | IDE_HFLAG_ABUSE_PREFETCH, | ||
| 326 | .pio_mask = ATA_PIO5, | ||
| 327 | }; | ||
| 328 | |||
| 308 | static int __init ht6560b_init(void) | 329 | static int __init ht6560b_init(void) |
| 309 | { | 330 | { |
| 310 | ide_hwif_t *hwif, *mate; | 331 | ide_hwif_t *hwif, *mate; |
| 311 | static u8 idx[4] = { 0, 1, 0xff, 0xff }; | 332 | static u8 idx[4] = { 0, 1, 0xff, 0xff }; |
| 312 | int t; | ||
| 313 | 333 | ||
| 314 | if (probe_ht6560b == 0) | 334 | if (probe_ht6560b == 0) |
| 315 | return -ENODEV; | 335 | return -ENODEV; |
| @@ -328,36 +348,16 @@ static int __init ht6560b_init(void) | |||
| 328 | goto release_region; | 348 | goto release_region; |
| 329 | } | 349 | } |
| 330 | 350 | ||
| 331 | hwif->chipset = ide_ht6560b; | ||
| 332 | hwif->selectproc = &ht6560b_selectproc; | 351 | hwif->selectproc = &ht6560b_selectproc; |
| 333 | hwif->host_flags = IDE_HFLAG_ABUSE_PREFETCH; | ||
| 334 | hwif->pio_mask = ATA_PIO5; | ||
| 335 | hwif->set_pio_mode = &ht6560b_set_pio_mode; | 352 | hwif->set_pio_mode = &ht6560b_set_pio_mode; |
| 336 | hwif->serialized = 1; /* is this needed? */ | ||
| 337 | hwif->mate = mate; | ||
| 338 | 353 | ||
| 339 | mate->chipset = ide_ht6560b; | ||
| 340 | mate->selectproc = &ht6560b_selectproc; | 354 | mate->selectproc = &ht6560b_selectproc; |
| 341 | mate->host_flags = IDE_HFLAG_ABUSE_PREFETCH; | ||
| 342 | mate->pio_mask = ATA_PIO5; | ||
| 343 | mate->set_pio_mode = &ht6560b_set_pio_mode; | 355 | mate->set_pio_mode = &ht6560b_set_pio_mode; |
| 344 | mate->serialized = 1; /* is this needed? */ | ||
| 345 | mate->mate = hwif; | ||
| 346 | mate->channel = 1; | ||
| 347 | |||
| 348 | /* | ||
| 349 | * Setting default configurations for drives | ||
| 350 | */ | ||
| 351 | t = (HT_CONFIG_DEFAULT << 8); | ||
| 352 | t |= HT_TIMING_DEFAULT; | ||
| 353 | hwif->drives[0].drive_data = t; | ||
| 354 | hwif->drives[1].drive_data = t; | ||
| 355 | 356 | ||
| 356 | t |= (HT_SECONDARY_IF << 8); | 357 | hwif->port_init_devs = ht6560b_port_init_devs; |
| 357 | mate->drives[0].drive_data = t; | 358 | mate->port_init_devs = ht6560b_port_init_devs; |
| 358 | mate->drives[1].drive_data = t; | ||
| 359 | 359 | ||
| 360 | ide_device_add(idx); | 360 | ide_device_add(idx, &ht6560b_port_info); |
| 361 | 361 | ||
| 362 | return 0; | 362 | return 0; |
| 363 | 363 | ||
diff --git a/drivers/ide/legacy/ide-cs.c b/drivers/ide/legacy/ide-cs.c index 3bd29676ef6a..15ccf6944ae2 100644 --- a/drivers/ide/legacy/ide-cs.c +++ b/drivers/ide/legacy/ide-cs.c | |||
| @@ -145,13 +145,36 @@ static void ide_detach(struct pcmcia_device *link) | |||
| 145 | 145 | ||
| 146 | static int idecs_register(unsigned long io, unsigned long ctl, unsigned long irq, struct pcmcia_device *handle) | 146 | static int idecs_register(unsigned long io, unsigned long ctl, unsigned long irq, struct pcmcia_device *handle) |
| 147 | { | 147 | { |
| 148 | ide_hwif_t *hwif; | ||
| 148 | hw_regs_t hw; | 149 | hw_regs_t hw; |
| 150 | int i; | ||
| 151 | u8 idx[4] = { 0xff, 0xff, 0xff, 0xff }; | ||
| 152 | |||
| 149 | memset(&hw, 0, sizeof(hw)); | 153 | memset(&hw, 0, sizeof(hw)); |
| 150 | ide_init_hwif_ports(&hw, io, ctl, NULL); | 154 | ide_std_init_ports(&hw, io, ctl); |
| 151 | hw.irq = irq; | 155 | hw.irq = irq; |
| 152 | hw.chipset = ide_pci; | 156 | hw.chipset = ide_pci; |
| 153 | hw.dev = &handle->dev; | 157 | hw.dev = &handle->dev; |
| 154 | return ide_register_hw(&hw, &ide_undecoded_slave, NULL); | 158 | |
| 159 | hwif = ide_deprecated_find_port(hw.io_ports[IDE_DATA_OFFSET]); | ||
| 160 | if (hwif == NULL) | ||
| 161 | return -1; | ||
| 162 | |||
| 163 | i = hwif->index; | ||
| 164 | |||
| 165 | if (hwif->present) | ||
| 166 | ide_unregister(i, 0, 0); | ||
| 167 | else if (!hwif->hold) | ||
| 168 | ide_init_port_data(hwif, i); | ||
| 169 | |||
| 170 | ide_init_port_hw(hwif, &hw); | ||
| 171 | hwif->quirkproc = &ide_undecoded_slave; | ||
| 172 | |||
| 173 | idx[0] = i; | ||
| 174 | |||
| 175 | ide_device_add(idx, NULL); | ||
| 176 | |||
| 177 | return hwif->present ? i : -1; | ||
| 155 | } | 178 | } |
| 156 | 179 | ||
| 157 | /*====================================================================== | 180 | /*====================================================================== |
| @@ -337,7 +360,7 @@ void ide_release(struct pcmcia_device *link) | |||
| 337 | if (info->ndev) { | 360 | if (info->ndev) { |
| 338 | /* FIXME: if this fails we need to queue the cleanup somehow | 361 | /* FIXME: if this fails we need to queue the cleanup somehow |
| 339 | -- need to investigate the required PCMCIA magic */ | 362 | -- need to investigate the required PCMCIA magic */ |
| 340 | ide_unregister(info->hd); | 363 | ide_unregister(info->hd, 0, 0); |
| 341 | } | 364 | } |
| 342 | info->ndev = 0; | 365 | info->ndev = 0; |
| 343 | 366 | ||
diff --git a/drivers/ide/legacy/ide_platform.c b/drivers/ide/legacy/ide_platform.c index 7c3231a21d17..26c82ce602de 100644 --- a/drivers/ide/legacy/ide_platform.c +++ b/drivers/ide/legacy/ide_platform.c | |||
| @@ -108,7 +108,7 @@ static int __devinit plat_ide_probe(struct platform_device *pdev) | |||
| 108 | 108 | ||
| 109 | idx[0] = hwif->index; | 109 | idx[0] = hwif->index; |
| 110 | 110 | ||
| 111 | ide_device_add(idx); | 111 | ide_device_add(idx, NULL); |
| 112 | 112 | ||
| 113 | platform_set_drvdata(pdev, hwif); | 113 | platform_set_drvdata(pdev, hwif); |
| 114 | 114 | ||
| @@ -122,7 +122,7 @@ static int __devexit plat_ide_remove(struct platform_device *pdev) | |||
| 122 | { | 122 | { |
| 123 | ide_hwif_t *hwif = pdev->dev.driver_data; | 123 | ide_hwif_t *hwif = pdev->dev.driver_data; |
| 124 | 124 | ||
| 125 | ide_unregister(hwif->index); | 125 | ide_unregister(hwif->index, 0, 0); |
| 126 | 126 | ||
| 127 | return 0; | 127 | return 0; |
| 128 | } | 128 | } |
diff --git a/drivers/ide/legacy/macide.c b/drivers/ide/legacy/macide.c index c54d07ff64fe..06df8df857a3 100644 --- a/drivers/ide/legacy/macide.c +++ b/drivers/ide/legacy/macide.c | |||
| @@ -123,19 +123,9 @@ static int __init macide_init(void) | |||
| 123 | ide_init_port_data(hwif, index); | 123 | ide_init_port_data(hwif, index); |
| 124 | ide_init_port_hw(hwif, &hw); | 124 | ide_init_port_hw(hwif, &hw); |
| 125 | 125 | ||
| 126 | if (macintosh_config->ide_type == MAC_IDE_BABOON && | ||
| 127 | macintosh_config->ident == MAC_MODEL_PB190) { | ||
| 128 | /* Fix breakage in ide-disk.c: drive capacity */ | ||
| 129 | /* is not initialized for drives without a */ | ||
| 130 | /* hardware ID, and we can't get that without */ | ||
| 131 | /* probing the drive which freezes a 190. */ | ||
| 132 | ide_drive_t *drive = &hwif->drives[0]; | ||
| 133 | drive->capacity64 = drive->cyl*drive->head*drive->sect; | ||
| 134 | } | ||
| 135 | |||
| 136 | hwif->mmio = 1; | 126 | hwif->mmio = 1; |
| 137 | 127 | ||
| 138 | ide_device_add(idx); | 128 | ide_device_add(idx, NULL); |
| 139 | } | 129 | } |
| 140 | 130 | ||
| 141 | return 0; | 131 | return 0; |
diff --git a/drivers/ide/legacy/q40ide.c b/drivers/ide/legacy/q40ide.c index a9c6b0609c54..2f0b34d892a1 100644 --- a/drivers/ide/legacy/q40ide.c +++ b/drivers/ide/legacy/q40ide.c | |||
| @@ -154,7 +154,7 @@ static int __init q40ide_init(void) | |||
| 154 | } | 154 | } |
| 155 | } | 155 | } |
| 156 | 156 | ||
| 157 | ide_device_add(idx); | 157 | ide_device_add(idx, NULL); |
| 158 | 158 | ||
| 159 | return 0; | 159 | return 0; |
| 160 | } | 160 | } |
diff --git a/drivers/ide/legacy/qd65xx.c b/drivers/ide/legacy/qd65xx.c index 37534bb483a7..bba29df5f21d 100644 --- a/drivers/ide/legacy/qd65xx.c +++ b/drivers/ide/legacy/qd65xx.c | |||
| @@ -305,18 +305,33 @@ static int __init qd_testreg(int port) | |||
| 305 | * called to setup an ata channel : adjusts attributes & links for tuning | 305 | * called to setup an ata channel : adjusts attributes & links for tuning |
| 306 | */ | 306 | */ |
| 307 | 307 | ||
| 308 | static void __init qd_setup(ide_hwif_t *hwif, int base, int config, | 308 | static void __init qd_setup(ide_hwif_t *hwif, int base, int config) |
| 309 | unsigned int data0, unsigned int data1) | ||
| 310 | { | 309 | { |
| 311 | hwif->chipset = ide_qd65xx; | ||
| 312 | hwif->channel = hwif->index; | ||
| 313 | hwif->select_data = base; | 310 | hwif->select_data = base; |
| 314 | hwif->config_data = config; | 311 | hwif->config_data = config; |
| 315 | hwif->drives[0].drive_data = data0; | 312 | } |
| 316 | hwif->drives[1].drive_data = data1; | 313 | |
| 317 | hwif->drives[0].io_32bit = | 314 | static void __init qd6500_port_init_devs(ide_hwif_t *hwif) |
| 318 | hwif->drives[1].io_32bit = 1; | 315 | { |
| 319 | hwif->pio_mask = ATA_PIO4; | 316 | u8 base = hwif->select_data, config = QD_CONFIG(hwif); |
| 317 | |||
| 318 | hwif->drives[0].drive_data = QD6500_DEF_DATA; | ||
| 319 | hwif->drives[1].drive_data = QD6500_DEF_DATA; | ||
| 320 | } | ||
| 321 | |||
| 322 | static void __init qd6580_port_init_devs(ide_hwif_t *hwif) | ||
| 323 | { | ||
| 324 | u16 t1, t2; | ||
| 325 | u8 base = hwif->select_data, config = QD_CONFIG(hwif); | ||
| 326 | |||
| 327 | if (QD_CONTROL(hwif) & QD_CONTR_SEC_DISABLED) { | ||
| 328 | t1 = QD6580_DEF_DATA; | ||
| 329 | t2 = QD6580_DEF_DATA2; | ||
| 330 | } else | ||
| 331 | t2 = t1 = hwif->channel ? QD6580_DEF_DATA2 : QD6580_DEF_DATA; | ||
| 332 | |||
| 333 | hwif->drives[0].drive_data = t1; | ||
| 334 | hwif->drives[1].drive_data = t2; | ||
| 320 | } | 335 | } |
| 321 | 336 | ||
| 322 | /* | 337 | /* |
| @@ -356,6 +371,14 @@ static void __exit qd_unsetup(ide_hwif_t *hwif) | |||
| 356 | } | 371 | } |
| 357 | */ | 372 | */ |
| 358 | 373 | ||
| 374 | static const struct ide_port_info qd65xx_port_info __initdata = { | ||
| 375 | .chipset = ide_qd65xx, | ||
| 376 | .host_flags = IDE_HFLAG_IO_32BIT | | ||
| 377 | IDE_HFLAG_NO_DMA | | ||
| 378 | IDE_HFLAG_NO_AUTOTUNE, | ||
| 379 | .pio_mask = ATA_PIO4, | ||
| 380 | }; | ||
| 381 | |||
| 359 | /* | 382 | /* |
| 360 | * qd_probe: | 383 | * qd_probe: |
| 361 | * | 384 | * |
| @@ -393,13 +416,14 @@ static int __init qd_probe(int base) | |||
| 393 | return 1; | 416 | return 1; |
| 394 | } | 417 | } |
| 395 | 418 | ||
| 396 | qd_setup(hwif, base, config, QD6500_DEF_DATA, QD6500_DEF_DATA); | 419 | qd_setup(hwif, base, config); |
| 397 | 420 | ||
| 421 | hwif->port_init_devs = qd6500_port_init_devs; | ||
| 398 | hwif->set_pio_mode = &qd6500_set_pio_mode; | 422 | hwif->set_pio_mode = &qd6500_set_pio_mode; |
| 399 | 423 | ||
| 400 | idx[0] = unit; | 424 | idx[unit] = unit; |
| 401 | 425 | ||
| 402 | ide_device_add(idx); | 426 | ide_device_add(idx, &qd65xx_port_info); |
| 403 | 427 | ||
| 404 | return 1; | 428 | return 1; |
| 405 | } | 429 | } |
| @@ -426,14 +450,15 @@ static int __init qd_probe(int base) | |||
| 426 | hwif = &ide_hwifs[unit]; | 450 | hwif = &ide_hwifs[unit]; |
| 427 | printk(KERN_INFO "%s: qd6580: single IDE board\n", | 451 | printk(KERN_INFO "%s: qd6580: single IDE board\n", |
| 428 | hwif->name); | 452 | hwif->name); |
| 429 | qd_setup(hwif, base, config | (control << 8), | ||
| 430 | QD6580_DEF_DATA, QD6580_DEF_DATA2); | ||
| 431 | 453 | ||
| 454 | qd_setup(hwif, base, config | (control << 8)); | ||
| 455 | |||
| 456 | hwif->port_init_devs = qd6580_port_init_devs; | ||
| 432 | hwif->set_pio_mode = &qd6580_set_pio_mode; | 457 | hwif->set_pio_mode = &qd6580_set_pio_mode; |
| 433 | 458 | ||
| 434 | idx[0] = unit; | 459 | idx[unit] = unit; |
| 435 | 460 | ||
| 436 | ide_device_add(idx); | 461 | ide_device_add(idx, &qd65xx_port_info); |
| 437 | 462 | ||
| 438 | outb(QD_DEF_CONTR, QD_CONTROL_PORT); | 463 | outb(QD_DEF_CONTR, QD_CONTROL_PORT); |
| 439 | 464 | ||
| @@ -447,20 +472,20 @@ static int __init qd_probe(int base) | |||
| 447 | printk(KERN_INFO "%s&%s: qd6580: dual IDE board\n", | 472 | printk(KERN_INFO "%s&%s: qd6580: dual IDE board\n", |
| 448 | hwif->name, mate->name); | 473 | hwif->name, mate->name); |
| 449 | 474 | ||
| 450 | qd_setup(hwif, base, config | (control << 8), | 475 | qd_setup(hwif, base, config | (control << 8)); |
| 451 | QD6580_DEF_DATA, QD6580_DEF_DATA); | ||
| 452 | 476 | ||
| 477 | hwif->port_init_devs = qd6580_port_init_devs; | ||
| 453 | hwif->set_pio_mode = &qd6580_set_pio_mode; | 478 | hwif->set_pio_mode = &qd6580_set_pio_mode; |
| 454 | 479 | ||
| 455 | qd_setup(mate, base, config | (control << 8), | 480 | qd_setup(mate, base, config | (control << 8)); |
| 456 | QD6580_DEF_DATA2, QD6580_DEF_DATA2); | ||
| 457 | 481 | ||
| 482 | mate->port_init_devs = qd6580_port_init_devs; | ||
| 458 | mate->set_pio_mode = &qd6580_set_pio_mode; | 483 | mate->set_pio_mode = &qd6580_set_pio_mode; |
| 459 | 484 | ||
| 460 | idx[0] = 0; | 485 | idx[0] = 0; |
| 461 | idx[1] = 1; | 486 | idx[1] = 1; |
| 462 | 487 | ||
| 463 | ide_device_add(idx); | 488 | ide_device_add(idx, &qd65xx_port_info); |
| 464 | 489 | ||
| 465 | outb(QD_DEF_CONTR, QD_CONTROL_PORT); | 490 | outb(QD_DEF_CONTR, QD_CONTROL_PORT); |
| 466 | 491 | ||
diff --git a/drivers/ide/legacy/umc8672.c b/drivers/ide/legacy/umc8672.c index 26f38ce58776..5696ba026005 100644 --- a/drivers/ide/legacy/umc8672.c +++ b/drivers/ide/legacy/umc8672.c | |||
| @@ -120,9 +120,14 @@ static void umc_set_pio_mode(ide_drive_t *drive, const u8 pio) | |||
| 120 | spin_unlock_irqrestore(&ide_lock, flags); | 120 | spin_unlock_irqrestore(&ide_lock, flags); |
| 121 | } | 121 | } |
| 122 | 122 | ||
| 123 | static const struct ide_port_info umc8672_port_info __initdata = { | ||
| 124 | .chipset = ide_umc8672, | ||
| 125 | .host_flags = IDE_HFLAG_NO_DMA | IDE_HFLAG_NO_AUTOTUNE, | ||
| 126 | .pio_mask = ATA_PIO4, | ||
| 127 | }; | ||
| 128 | |||
| 123 | static int __init umc8672_probe(void) | 129 | static int __init umc8672_probe(void) |
| 124 | { | 130 | { |
| 125 | ide_hwif_t *hwif, *mate; | ||
| 126 | unsigned long flags; | 131 | unsigned long flags; |
| 127 | static u8 idx[4] = { 0, 1, 0xff, 0xff }; | 132 | static u8 idx[4] = { 0, 1, 0xff, 0xff }; |
| 128 | 133 | ||
| @@ -143,21 +148,10 @@ static int __init umc8672_probe(void) | |||
| 143 | umc_set_speeds (current_speeds); | 148 | umc_set_speeds (current_speeds); |
| 144 | local_irq_restore(flags); | 149 | local_irq_restore(flags); |
| 145 | 150 | ||
| 146 | hwif = &ide_hwifs[0]; | 151 | ide_hwifs[0].set_pio_mode = &umc_set_pio_mode; |
| 147 | mate = &ide_hwifs[1]; | 152 | ide_hwifs[1].set_pio_mode = &umc_set_pio_mode; |
| 148 | |||
| 149 | hwif->chipset = ide_umc8672; | ||
| 150 | hwif->pio_mask = ATA_PIO4; | ||
| 151 | hwif->set_pio_mode = &umc_set_pio_mode; | ||
| 152 | hwif->mate = mate; | ||
| 153 | |||
| 154 | mate->chipset = ide_umc8672; | ||
| 155 | mate->pio_mask = ATA_PIO4; | ||
| 156 | mate->set_pio_mode = &umc_set_pio_mode; | ||
| 157 | mate->mate = hwif; | ||
| 158 | mate->channel = 1; | ||
| 159 | 153 | ||
| 160 | ide_device_add(idx); | 154 | ide_device_add(idx, &umc8672_port_info); |
| 161 | 155 | ||
| 162 | return 0; | 156 | return 0; |
| 163 | } | 157 | } |
diff --git a/drivers/ide/mips/au1xxx-ide.c b/drivers/ide/mips/au1xxx-ide.c index cd42b30a7a3b..0f4bf5d72835 100644 --- a/drivers/ide/mips/au1xxx-ide.c +++ b/drivers/ide/mips/au1xxx-ide.c | |||
| @@ -548,6 +548,17 @@ static void auide_setup_ports(hw_regs_t *hw, _auide_hwif *ahwif) | |||
| 548 | *ata_regs = ahwif->regbase + (14 << AU1XXX_ATA_REG_OFFSET); | 548 | *ata_regs = ahwif->regbase + (14 << AU1XXX_ATA_REG_OFFSET); |
| 549 | } | 549 | } |
| 550 | 550 | ||
| 551 | static const struct ide_port_info au1xxx_port_info = { | ||
| 552 | .host_flags = IDE_HFLAG_POST_SET_MODE | | ||
| 553 | IDE_HFLAG_NO_DMA | /* no SFF-style DMA */ | ||
| 554 | IDE_HFLAG_NO_IO_32BIT | | ||
| 555 | IDE_HFLAG_UNMASK_IRQS, | ||
| 556 | .pio_mask = ATA_PIO4, | ||
| 557 | #ifdef CONFIG_BLK_DEV_IDE_AU1XXX_MDMA2_DBDMA | ||
| 558 | .mwdma_mask = ATA_MWDMA2, | ||
| 559 | #endif | ||
| 560 | }; | ||
| 561 | |||
| 551 | static int au_ide_probe(struct device *dev) | 562 | static int au_ide_probe(struct device *dev) |
| 552 | { | 563 | { |
| 553 | struct platform_device *pdev = to_platform_device(dev); | 564 | struct platform_device *pdev = to_platform_device(dev); |
| @@ -606,21 +617,6 @@ static int au_ide_probe(struct device *dev) | |||
| 606 | 617 | ||
| 607 | hwif->dev = dev; | 618 | hwif->dev = dev; |
| 608 | 619 | ||
| 609 | hwif->ultra_mask = 0x0; /* Disable Ultra DMA */ | ||
| 610 | #ifdef CONFIG_BLK_DEV_IDE_AU1XXX_MDMA2_DBDMA | ||
| 611 | hwif->mwdma_mask = 0x07; /* Multimode-2 DMA */ | ||
| 612 | hwif->swdma_mask = 0x00; | ||
| 613 | #else | ||
| 614 | hwif->mwdma_mask = 0x0; | ||
| 615 | hwif->swdma_mask = 0x0; | ||
| 616 | #endif | ||
| 617 | |||
| 618 | hwif->pio_mask = ATA_PIO4; | ||
| 619 | hwif->host_flags = IDE_HFLAG_POST_SET_MODE; | ||
| 620 | |||
| 621 | hwif->drives[0].unmask = 1; | ||
| 622 | hwif->drives[1].unmask = 1; | ||
| 623 | |||
| 624 | /* hold should be on in all cases */ | 620 | /* hold should be on in all cases */ |
| 625 | hwif->hold = 1; | 621 | hwif->hold = 1; |
| 626 | 622 | ||
| @@ -651,16 +647,9 @@ static int au_ide_probe(struct device *dev) | |||
| 651 | hwif->ide_dma_test_irq = &auide_dma_test_irq; | 647 | hwif->ide_dma_test_irq = &auide_dma_test_irq; |
| 652 | hwif->dma_lost_irq = &auide_dma_lost_irq; | 648 | hwif->dma_lost_irq = &auide_dma_lost_irq; |
| 653 | #endif | 649 | #endif |
| 654 | hwif->channel = 0; | ||
| 655 | hwif->select_data = 0; /* no chipset-specific code */ | 650 | hwif->select_data = 0; /* no chipset-specific code */ |
| 656 | hwif->config_data = 0; /* no chipset-specific code */ | 651 | hwif->config_data = 0; /* no chipset-specific code */ |
| 657 | 652 | ||
| 658 | hwif->drives[0].autotune = 1; /* 1=autotune, 2=noautotune, 0=default */ | ||
| 659 | hwif->drives[1].autotune = 1; | ||
| 660 | |||
| 661 | hwif->drives[0].no_io_32bit = 1; | ||
| 662 | hwif->drives[1].no_io_32bit = 1; | ||
| 663 | |||
| 664 | auide_hwif.hwif = hwif; | 653 | auide_hwif.hwif = hwif; |
| 665 | hwif->hwif_data = &auide_hwif; | 654 | hwif->hwif_data = &auide_hwif; |
| 666 | 655 | ||
| @@ -671,7 +660,7 @@ static int au_ide_probe(struct device *dev) | |||
| 671 | 660 | ||
| 672 | idx[0] = hwif->index; | 661 | idx[0] = hwif->index; |
| 673 | 662 | ||
| 674 | ide_device_add(idx); | 663 | ide_device_add(idx, &au1xxx_port_info); |
| 675 | 664 | ||
| 676 | dev_set_drvdata(dev, hwif); | 665 | dev_set_drvdata(dev, hwif); |
| 677 | 666 | ||
| @@ -688,7 +677,7 @@ static int au_ide_remove(struct device *dev) | |||
| 688 | ide_hwif_t *hwif = dev_get_drvdata(dev); | 677 | ide_hwif_t *hwif = dev_get_drvdata(dev); |
| 689 | _auide_hwif *ahwif = &auide_hwif; | 678 | _auide_hwif *ahwif = &auide_hwif; |
| 690 | 679 | ||
| 691 | ide_unregister(hwif->index); | 680 | ide_unregister(hwif->index, 0, 0); |
| 692 | 681 | ||
| 693 | iounmap((void *)ahwif->regbase); | 682 | iounmap((void *)ahwif->regbase); |
| 694 | 683 | ||
diff --git a/drivers/ide/mips/swarm.c b/drivers/ide/mips/swarm.c index 8b3959dfa2b7..956259fc09ba 100644 --- a/drivers/ide/mips/swarm.c +++ b/drivers/ide/mips/swarm.c | |||
| @@ -129,7 +129,7 @@ static int __devinit swarm_ide_probe(struct device *dev) | |||
| 129 | 129 | ||
| 130 | idx[0] = hwif->index; | 130 | idx[0] = hwif->index; |
| 131 | 131 | ||
| 132 | ide_device_add(idx); | 132 | ide_device_add(idx, NULL); |
| 133 | 133 | ||
| 134 | dev_set_drvdata(dev, hwif); | 134 | dev_set_drvdata(dev, hwif); |
| 135 | 135 | ||
diff --git a/drivers/ide/pci/aec62xx.c b/drivers/ide/pci/aec62xx.c index 824df78c7012..cfb3265bc1a8 100644 --- a/drivers/ide/pci/aec62xx.c +++ b/drivers/ide/pci/aec62xx.c | |||
| @@ -7,7 +7,6 @@ | |||
| 7 | #include <linux/module.h> | 7 | #include <linux/module.h> |
| 8 | #include <linux/types.h> | 8 | #include <linux/types.h> |
| 9 | #include <linux/pci.h> | 9 | #include <linux/pci.h> |
| 10 | #include <linux/delay.h> | ||
| 11 | #include <linux/hdreg.h> | 10 | #include <linux/hdreg.h> |
| 12 | #include <linux/ide.h> | 11 | #include <linux/ide.h> |
| 13 | #include <linux/init.h> | 12 | #include <linux/init.h> |
| @@ -166,6 +165,16 @@ static unsigned int __devinit init_chipset_aec62xx(struct pci_dev *dev, const ch | |||
| 166 | return dev->irq; | 165 | return dev->irq; |
| 167 | } | 166 | } |
| 168 | 167 | ||
| 168 | static u8 __devinit atp86x_cable_detect(ide_hwif_t *hwif) | ||
| 169 | { | ||
| 170 | struct pci_dev *dev = to_pci_dev(hwif->dev); | ||
| 171 | u8 ata66 = 0, mask = hwif->channel ? 0x02 : 0x01; | ||
| 172 | |||
| 173 | pci_read_config_byte(dev, 0x49, &ata66); | ||
| 174 | |||
| 175 | return (ata66 & mask) ? ATA_CBL_PATA40 : ATA_CBL_PATA80; | ||
| 176 | } | ||
| 177 | |||
| 169 | static void __devinit init_hwif_aec62xx(ide_hwif_t *hwif) | 178 | static void __devinit init_hwif_aec62xx(ide_hwif_t *hwif) |
| 170 | { | 179 | { |
| 171 | struct pci_dev *dev = to_pci_dev(hwif->dev); | 180 | struct pci_dev *dev = to_pci_dev(hwif->dev); |
| @@ -174,21 +183,10 @@ static void __devinit init_hwif_aec62xx(ide_hwif_t *hwif) | |||
| 174 | 183 | ||
| 175 | if (dev->device == PCI_DEVICE_ID_ARTOP_ATP850UF) | 184 | if (dev->device == PCI_DEVICE_ID_ARTOP_ATP850UF) |
| 176 | hwif->set_dma_mode = &aec6210_set_mode; | 185 | hwif->set_dma_mode = &aec6210_set_mode; |
| 177 | else | 186 | else { |
| 178 | hwif->set_dma_mode = &aec6260_set_mode; | 187 | hwif->set_dma_mode = &aec6260_set_mode; |
| 179 | 188 | ||
| 180 | if (hwif->dma_base == 0) | 189 | hwif->cable_detect = atp86x_cable_detect; |
| 181 | return; | ||
| 182 | |||
| 183 | if (dev->device == PCI_DEVICE_ID_ARTOP_ATP850UF) | ||
| 184 | return; | ||
| 185 | |||
| 186 | if (hwif->cbl != ATA_CBL_PATA40_SHORT) { | ||
| 187 | u8 ata66 = 0, mask = hwif->channel ? 0x02 : 0x01; | ||
| 188 | |||
| 189 | pci_read_config_byte(dev, 0x49, &ata66); | ||
| 190 | |||
| 191 | hwif->cbl = (ata66 & mask) ? ATA_CBL_PATA40 : ATA_CBL_PATA80; | ||
| 192 | } | 190 | } |
| 193 | } | 191 | } |
| 194 | 192 | ||
diff --git a/drivers/ide/pci/alim15x3.c b/drivers/ide/pci/alim15x3.c index 130cc6e784e5..b3b6f514ce2d 100644 --- a/drivers/ide/pci/alim15x3.c +++ b/drivers/ide/pci/alim15x3.c | |||
| @@ -31,7 +31,6 @@ | |||
| 31 | #include <linux/types.h> | 31 | #include <linux/types.h> |
| 32 | #include <linux/kernel.h> | 32 | #include <linux/kernel.h> |
| 33 | #include <linux/pci.h> | 33 | #include <linux/pci.h> |
| 34 | #include <linux/delay.h> | ||
| 35 | #include <linux/hdreg.h> | 34 | #include <linux/hdreg.h> |
| 36 | #include <linux/ide.h> | 35 | #include <linux/ide.h> |
| 37 | #include <linux/init.h> | 36 | #include <linux/init.h> |
| @@ -666,13 +665,12 @@ static void __devinit init_hwif_common_ali15x3 (ide_hwif_t *hwif) | |||
| 666 | hwif->set_dma_mode = &ali_set_dma_mode; | 665 | hwif->set_dma_mode = &ali_set_dma_mode; |
| 667 | hwif->udma_filter = &ali_udma_filter; | 666 | hwif->udma_filter = &ali_udma_filter; |
| 668 | 667 | ||
| 668 | hwif->cable_detect = ata66_ali15x3; | ||
| 669 | |||
| 669 | if (hwif->dma_base == 0) | 670 | if (hwif->dma_base == 0) |
| 670 | return; | 671 | return; |
| 671 | 672 | ||
| 672 | hwif->dma_setup = &ali15x3_dma_setup; | 673 | hwif->dma_setup = &ali15x3_dma_setup; |
| 673 | |||
| 674 | if (hwif->cbl != ATA_CBL_PATA40_SHORT) | ||
| 675 | hwif->cbl = ata66_ali15x3(hwif); | ||
| 676 | } | 674 | } |
| 677 | 675 | ||
| 678 | /** | 676 | /** |
diff --git a/drivers/ide/pci/amd74xx.c b/drivers/ide/pci/amd74xx.c index 8c52bc9eaa59..2ef890ce8097 100644 --- a/drivers/ide/pci/amd74xx.c +++ b/drivers/ide/pci/amd74xx.c | |||
| @@ -17,12 +17,9 @@ | |||
| 17 | 17 | ||
| 18 | #include <linux/module.h> | 18 | #include <linux/module.h> |
| 19 | #include <linux/kernel.h> | 19 | #include <linux/kernel.h> |
| 20 | #include <linux/ioport.h> | ||
| 21 | #include <linux/blkdev.h> | ||
| 22 | #include <linux/pci.h> | 20 | #include <linux/pci.h> |
| 23 | #include <linux/init.h> | 21 | #include <linux/init.h> |
| 24 | #include <linux/ide.h> | 22 | #include <linux/ide.h> |
| 25 | #include <asm/io.h> | ||
| 26 | 23 | ||
| 27 | #include "ide-timing.h" | 24 | #include "ide-timing.h" |
| 28 | 25 | ||
| @@ -199,6 +196,14 @@ static unsigned int __devinit init_chipset_amd74xx(struct pci_dev *dev, | |||
| 199 | return dev->irq; | 196 | return dev->irq; |
| 200 | } | 197 | } |
| 201 | 198 | ||
| 199 | static u8 __devinit amd_cable_detect(ide_hwif_t *hwif) | ||
| 200 | { | ||
| 201 | if ((amd_80w >> hwif->channel) & 1) | ||
| 202 | return ATA_CBL_PATA80; | ||
| 203 | else | ||
| 204 | return ATA_CBL_PATA40; | ||
| 205 | } | ||
| 206 | |||
| 202 | static void __devinit init_hwif_amd74xx(ide_hwif_t *hwif) | 207 | static void __devinit init_hwif_amd74xx(ide_hwif_t *hwif) |
| 203 | { | 208 | { |
| 204 | struct pci_dev *dev = to_pci_dev(hwif->dev); | 209 | struct pci_dev *dev = to_pci_dev(hwif->dev); |
| @@ -209,15 +214,7 @@ static void __devinit init_hwif_amd74xx(ide_hwif_t *hwif) | |||
| 209 | hwif->set_pio_mode = &amd_set_pio_mode; | 214 | hwif->set_pio_mode = &amd_set_pio_mode; |
| 210 | hwif->set_dma_mode = &amd_set_drive; | 215 | hwif->set_dma_mode = &amd_set_drive; |
| 211 | 216 | ||
| 212 | if (!hwif->dma_base) | 217 | hwif->cable_detect = amd_cable_detect; |
| 213 | return; | ||
| 214 | |||
| 215 | if (hwif->cbl != ATA_CBL_PATA40_SHORT) { | ||
| 216 | if ((amd_80w >> hwif->channel) & 1) | ||
| 217 | hwif->cbl = ATA_CBL_PATA80; | ||
| 218 | else | ||
| 219 | hwif->cbl = ATA_CBL_PATA40; | ||
| 220 | } | ||
| 221 | } | 218 | } |
| 222 | 219 | ||
| 223 | #define IDE_HFLAGS_AMD \ | 220 | #define IDE_HFLAGS_AMD \ |
diff --git a/drivers/ide/pci/atiixp.c b/drivers/ide/pci/atiixp.c index b56274af1782..7e037c880cb0 100644 --- a/drivers/ide/pci/atiixp.c +++ b/drivers/ide/pci/atiixp.c | |||
| @@ -6,15 +6,11 @@ | |||
| 6 | #include <linux/types.h> | 6 | #include <linux/types.h> |
| 7 | #include <linux/module.h> | 7 | #include <linux/module.h> |
| 8 | #include <linux/kernel.h> | 8 | #include <linux/kernel.h> |
| 9 | #include <linux/ioport.h> | ||
| 10 | #include <linux/pci.h> | 9 | #include <linux/pci.h> |
| 11 | #include <linux/hdreg.h> | 10 | #include <linux/hdreg.h> |
| 12 | #include <linux/ide.h> | 11 | #include <linux/ide.h> |
| 13 | #include <linux/delay.h> | ||
| 14 | #include <linux/init.h> | 12 | #include <linux/init.h> |
| 15 | 13 | ||
| 16 | #include <asm/io.h> | ||
| 17 | |||
| 18 | #define ATIIXP_IDE_PIO_TIMING 0x40 | 14 | #define ATIIXP_IDE_PIO_TIMING 0x40 |
| 19 | #define ATIIXP_IDE_MDMA_TIMING 0x44 | 15 | #define ATIIXP_IDE_MDMA_TIMING 0x44 |
| 20 | #define ATIIXP_IDE_PIO_CONTROL 0x48 | 16 | #define ATIIXP_IDE_PIO_CONTROL 0x48 |
| @@ -121,6 +117,19 @@ static void atiixp_set_dma_mode(ide_drive_t *drive, const u8 speed) | |||
| 121 | spin_unlock_irqrestore(&atiixp_lock, flags); | 117 | spin_unlock_irqrestore(&atiixp_lock, flags); |
| 122 | } | 118 | } |
| 123 | 119 | ||
| 120 | static u8 __devinit atiixp_cable_detect(ide_hwif_t *hwif) | ||
| 121 | { | ||
| 122 | struct pci_dev *pdev = to_pci_dev(hwif->dev); | ||
| 123 | u8 udma_mode = 0, ch = hwif->channel; | ||
| 124 | |||
| 125 | pci_read_config_byte(pdev, ATIIXP_IDE_UDMA_MODE + ch, &udma_mode); | ||
| 126 | |||
| 127 | if ((udma_mode & 0x07) >= 0x04 || (udma_mode & 0x70) >= 0x40) | ||
| 128 | return ATA_CBL_PATA80; | ||
| 129 | else | ||
| 130 | return ATA_CBL_PATA40; | ||
| 131 | } | ||
| 132 | |||
| 124 | /** | 133 | /** |
| 125 | * init_hwif_atiixp - fill in the hwif for the ATIIXP | 134 | * init_hwif_atiixp - fill in the hwif for the ATIIXP |
| 126 | * @hwif: IDE interface | 135 | * @hwif: IDE interface |
| @@ -131,21 +140,10 @@ static void atiixp_set_dma_mode(ide_drive_t *drive, const u8 speed) | |||
| 131 | 140 | ||
| 132 | static void __devinit init_hwif_atiixp(ide_hwif_t *hwif) | 141 | static void __devinit init_hwif_atiixp(ide_hwif_t *hwif) |
| 133 | { | 142 | { |
| 134 | struct pci_dev *pdev = to_pci_dev(hwif->dev); | ||
| 135 | u8 udma_mode = 0, ch = hwif->channel; | ||
| 136 | |||
| 137 | hwif->set_pio_mode = &atiixp_set_pio_mode; | 143 | hwif->set_pio_mode = &atiixp_set_pio_mode; |
| 138 | hwif->set_dma_mode = &atiixp_set_dma_mode; | 144 | hwif->set_dma_mode = &atiixp_set_dma_mode; |
| 139 | 145 | ||
| 140 | if (!hwif->dma_base) | 146 | hwif->cable_detect = atiixp_cable_detect; |
| 141 | return; | ||
| 142 | |||
| 143 | pci_read_config_byte(pdev, ATIIXP_IDE_UDMA_MODE + ch, &udma_mode); | ||
| 144 | |||
| 145 | if ((udma_mode & 0x07) >= 0x04 || (udma_mode & 0x70) >= 0x40) | ||
| 146 | hwif->cbl = ATA_CBL_PATA80; | ||
| 147 | else | ||
| 148 | hwif->cbl = ATA_CBL_PATA40; | ||
| 149 | } | 147 | } |
| 150 | 148 | ||
| 151 | static const struct ide_port_info atiixp_pci_info[] __devinitdata = { | 149 | static const struct ide_port_info atiixp_pci_info[] __devinitdata = { |
diff --git a/drivers/ide/pci/cmd640.c b/drivers/ide/pci/cmd640.c index 7240c20b9593..bd24dad3cfc6 100644 --- a/drivers/ide/pci/cmd640.c +++ b/drivers/ide/pci/cmd640.c | |||
| @@ -103,10 +103,6 @@ | |||
| 103 | #include <linux/types.h> | 103 | #include <linux/types.h> |
| 104 | #include <linux/kernel.h> | 104 | #include <linux/kernel.h> |
| 105 | #include <linux/delay.h> | 105 | #include <linux/delay.h> |
| 106 | #include <linux/timer.h> | ||
| 107 | #include <linux/mm.h> | ||
| 108 | #include <linux/ioport.h> | ||
| 109 | #include <linux/blkdev.h> | ||
| 110 | #include <linux/hdreg.h> | 106 | #include <linux/hdreg.h> |
| 111 | #include <linux/ide.h> | 107 | #include <linux/ide.h> |
| 112 | #include <linux/init.h> | 108 | #include <linux/init.h> |
| @@ -703,6 +699,18 @@ static int pci_conf2(void) | |||
| 703 | return 0; | 699 | return 0; |
| 704 | } | 700 | } |
| 705 | 701 | ||
| 702 | static const struct ide_port_info cmd640_port_info __initdata = { | ||
| 703 | .chipset = ide_cmd640, | ||
| 704 | .host_flags = IDE_HFLAG_SERIALIZE | | ||
| 705 | IDE_HFLAG_NO_DMA | | ||
| 706 | IDE_HFLAG_NO_AUTOTUNE | | ||
| 707 | IDE_HFLAG_ABUSE_PREFETCH | | ||
| 708 | IDE_HFLAG_ABUSE_FAST_DEVSEL, | ||
| 709 | #ifdef CONFIG_BLK_DEV_CMD640_ENHANCED | ||
| 710 | .pio_mask = ATA_PIO5, | ||
| 711 | #endif | ||
| 712 | }; | ||
| 713 | |||
| 706 | /* | 714 | /* |
| 707 | * Probe for a cmd640 chipset, and initialize it if found. | 715 | * Probe for a cmd640 chipset, and initialize it if found. |
| 708 | */ | 716 | */ |
| @@ -760,11 +768,7 @@ static int __init cmd640x_init(void) | |||
| 760 | setup_device_ptrs (); | 768 | setup_device_ptrs (); |
| 761 | printk("%s: buggy cmd640%c interface on %s, config=0x%02x\n", | 769 | printk("%s: buggy cmd640%c interface on %s, config=0x%02x\n", |
| 762 | cmd_hwif0->name, 'a' + cmd640_chip_version - 1, bus_type, cfr); | 770 | cmd_hwif0->name, 'a' + cmd640_chip_version - 1, bus_type, cfr); |
| 763 | cmd_hwif0->chipset = ide_cmd640; | ||
| 764 | #ifdef CONFIG_BLK_DEV_CMD640_ENHANCED | 771 | #ifdef CONFIG_BLK_DEV_CMD640_ENHANCED |
| 765 | cmd_hwif0->host_flags = IDE_HFLAG_ABUSE_PREFETCH | | ||
| 766 | IDE_HFLAG_ABUSE_FAST_DEVSEL; | ||
| 767 | cmd_hwif0->pio_mask = ATA_PIO5; | ||
| 768 | cmd_hwif0->set_pio_mode = &cmd640_set_pio_mode; | 772 | cmd_hwif0->set_pio_mode = &cmd640_set_pio_mode; |
| 769 | #endif /* CONFIG_BLK_DEV_CMD640_ENHANCED */ | 773 | #endif /* CONFIG_BLK_DEV_CMD640_ENHANCED */ |
| 770 | 774 | ||
| @@ -815,23 +819,14 @@ static int __init cmd640x_init(void) | |||
| 815 | * Initialize data for secondary cmd640 port, if enabled | 819 | * Initialize data for secondary cmd640 port, if enabled |
| 816 | */ | 820 | */ |
| 817 | if (second_port_cmd640) { | 821 | if (second_port_cmd640) { |
| 818 | cmd_hwif0->serialized = 1; | ||
| 819 | cmd_hwif1->serialized = 1; | ||
| 820 | cmd_hwif1->chipset = ide_cmd640; | ||
| 821 | cmd_hwif0->mate = cmd_hwif1; | ||
| 822 | cmd_hwif1->mate = cmd_hwif0; | ||
| 823 | cmd_hwif1->channel = 1; | ||
| 824 | #ifdef CONFIG_BLK_DEV_CMD640_ENHANCED | 822 | #ifdef CONFIG_BLK_DEV_CMD640_ENHANCED |
| 825 | cmd_hwif1->host_flags = IDE_HFLAG_ABUSE_PREFETCH | | ||
| 826 | IDE_HFLAG_ABUSE_FAST_DEVSEL; | ||
| 827 | cmd_hwif1->pio_mask = ATA_PIO5; | ||
| 828 | cmd_hwif1->set_pio_mode = &cmd640_set_pio_mode; | 823 | cmd_hwif1->set_pio_mode = &cmd640_set_pio_mode; |
| 829 | #endif /* CONFIG_BLK_DEV_CMD640_ENHANCED */ | 824 | #endif /* CONFIG_BLK_DEV_CMD640_ENHANCED */ |
| 830 | 825 | ||
| 831 | idx[1] = cmd_hwif1->index; | 826 | idx[1] = cmd_hwif1->index; |
| 832 | } | 827 | } |
| 833 | printk(KERN_INFO "%s: %sserialized, secondary interface %s\n", cmd_hwif1->name, | 828 | printk(KERN_INFO "%s: %sserialized, secondary interface %s\n", cmd_hwif1->name, |
| 834 | cmd_hwif0->serialized ? "" : "not ", port2); | 829 | second_port_cmd640 ? "" : "not ", port2); |
| 835 | 830 | ||
| 836 | /* | 831 | /* |
| 837 | * Establish initial timings/prefetch for all drives. | 832 | * Establish initial timings/prefetch for all drives. |
| @@ -876,7 +871,7 @@ static int __init cmd640x_init(void) | |||
| 876 | cmd640_dump_regs(); | 871 | cmd640_dump_regs(); |
| 877 | #endif | 872 | #endif |
| 878 | 873 | ||
| 879 | ide_device_add(idx); | 874 | ide_device_add(idx, &cmd640_port_info); |
| 880 | 875 | ||
| 881 | return 1; | 876 | return 1; |
| 882 | } | 877 | } |
diff --git a/drivers/ide/pci/cmd64x.c b/drivers/ide/pci/cmd64x.c index 04aa9e59670e..edabe6299efd 100644 --- a/drivers/ide/pci/cmd64x.c +++ b/drivers/ide/pci/cmd64x.c | |||
| @@ -13,7 +13,6 @@ | |||
| 13 | #include <linux/module.h> | 13 | #include <linux/module.h> |
| 14 | #include <linux/types.h> | 14 | #include <linux/types.h> |
| 15 | #include <linux/pci.h> | 15 | #include <linux/pci.h> |
| 16 | #include <linux/delay.h> | ||
| 17 | #include <linux/hdreg.h> | 16 | #include <linux/hdreg.h> |
| 18 | #include <linux/ide.h> | 17 | #include <linux/ide.h> |
| 19 | #include <linux/init.h> | 18 | #include <linux/init.h> |
| @@ -393,6 +392,8 @@ static void __devinit init_hwif_cmd64x(ide_hwif_t *hwif) | |||
| 393 | hwif->set_pio_mode = &cmd64x_set_pio_mode; | 392 | hwif->set_pio_mode = &cmd64x_set_pio_mode; |
| 394 | hwif->set_dma_mode = &cmd64x_set_dma_mode; | 393 | hwif->set_dma_mode = &cmd64x_set_dma_mode; |
| 395 | 394 | ||
| 395 | hwif->cable_detect = ata66_cmd64x; | ||
| 396 | |||
| 396 | if (!hwif->dma_base) | 397 | if (!hwif->dma_base) |
| 397 | return; | 398 | return; |
| 398 | 399 | ||
| @@ -411,9 +412,6 @@ static void __devinit init_hwif_cmd64x(ide_hwif_t *hwif) | |||
| 411 | if (dev->device == PCI_DEVICE_ID_CMD_646 && dev->revision < 5) | 412 | if (dev->device == PCI_DEVICE_ID_CMD_646 && dev->revision < 5) |
| 412 | hwif->ultra_mask = 0x00; | 413 | hwif->ultra_mask = 0x00; |
| 413 | 414 | ||
| 414 | if (hwif->cbl != ATA_CBL_PATA40_SHORT) | ||
| 415 | hwif->cbl = ata66_cmd64x(hwif); | ||
| 416 | |||
| 417 | switch (dev->device) { | 415 | switch (dev->device) { |
| 418 | case PCI_DEVICE_ID_CMD_648: | 416 | case PCI_DEVICE_ID_CMD_648: |
| 419 | case PCI_DEVICE_ID_CMD_649: | 417 | case PCI_DEVICE_ID_CMD_649: |
diff --git a/drivers/ide/pci/cs5520.c b/drivers/ide/pci/cs5520.c index eb68a9ad0c98..0be1a824102b 100644 --- a/drivers/ide/pci/cs5520.c +++ b/drivers/ide/pci/cs5520.c | |||
| @@ -35,22 +35,12 @@ | |||
| 35 | #include <linux/module.h> | 35 | #include <linux/module.h> |
| 36 | #include <linux/types.h> | 36 | #include <linux/types.h> |
| 37 | #include <linux/kernel.h> | 37 | #include <linux/kernel.h> |
| 38 | #include <linux/delay.h> | ||
| 39 | #include <linux/timer.h> | ||
| 40 | #include <linux/mm.h> | ||
| 41 | #include <linux/ioport.h> | ||
| 42 | #include <linux/blkdev.h> | ||
| 43 | #include <linux/hdreg.h> | 38 | #include <linux/hdreg.h> |
| 44 | |||
| 45 | #include <linux/interrupt.h> | ||
| 46 | #include <linux/init.h> | 39 | #include <linux/init.h> |
| 47 | #include <linux/pci.h> | 40 | #include <linux/pci.h> |
| 48 | #include <linux/ide.h> | 41 | #include <linux/ide.h> |
| 49 | #include <linux/dma-mapping.h> | 42 | #include <linux/dma-mapping.h> |
| 50 | 43 | ||
| 51 | #include <asm/io.h> | ||
| 52 | #include <asm/irq.h> | ||
| 53 | |||
| 54 | struct pio_clocks | 44 | struct pio_clocks |
| 55 | { | 45 | { |
| 56 | int address; | 46 | int address; |
| @@ -180,7 +170,7 @@ static int __devinit cs5520_init_one(struct pci_dev *dev, const struct pci_devic | |||
| 180 | 170 | ||
| 181 | ide_pci_setup_ports(dev, d, 14, &idx[0]); | 171 | ide_pci_setup_ports(dev, d, 14, &idx[0]); |
| 182 | 172 | ||
| 183 | ide_device_add(idx); | 173 | ide_device_add(idx, d); |
| 184 | 174 | ||
| 185 | return 0; | 175 | return 0; |
| 186 | } | 176 | } |
diff --git a/drivers/ide/pci/cs5530.c b/drivers/ide/pci/cs5530.c index 765aac397ced..941a1344820b 100644 --- a/drivers/ide/pci/cs5530.c +++ b/drivers/ide/pci/cs5530.c | |||
| @@ -15,18 +15,12 @@ | |||
| 15 | #include <linux/module.h> | 15 | #include <linux/module.h> |
| 16 | #include <linux/types.h> | 16 | #include <linux/types.h> |
| 17 | #include <linux/kernel.h> | 17 | #include <linux/kernel.h> |
| 18 | #include <linux/delay.h> | ||
| 19 | #include <linux/timer.h> | ||
| 20 | #include <linux/mm.h> | ||
| 21 | #include <linux/ioport.h> | ||
| 22 | #include <linux/blkdev.h> | ||
| 23 | #include <linux/hdreg.h> | 18 | #include <linux/hdreg.h> |
| 24 | #include <linux/interrupt.h> | ||
| 25 | #include <linux/pci.h> | 19 | #include <linux/pci.h> |
| 26 | #include <linux/init.h> | 20 | #include <linux/init.h> |
| 27 | #include <linux/ide.h> | 21 | #include <linux/ide.h> |
| 22 | |||
| 28 | #include <asm/io.h> | 23 | #include <asm/io.h> |
| 29 | #include <asm/irq.h> | ||
| 30 | 24 | ||
| 31 | /* | 25 | /* |
| 32 | * Here are the standard PIO mode 0-4 timings for each "format". | 26 | * Here are the standard PIO mode 0-4 timings for each "format". |
diff --git a/drivers/ide/pci/cs5535.c b/drivers/ide/pci/cs5535.c index 66433aa53f59..d7b5ea992e94 100644 --- a/drivers/ide/pci/cs5535.c +++ b/drivers/ide/pci/cs5535.c | |||
| @@ -155,8 +155,9 @@ static void cs5535_set_pio_mode(ide_drive_t *drive, const u8 pio) | |||
| 155 | cs5535_set_speed(drive, XFER_PIO_0 + pio); | 155 | cs5535_set_speed(drive, XFER_PIO_0 + pio); |
| 156 | } | 156 | } |
| 157 | 157 | ||
| 158 | static u8 __devinit cs5535_cable_detect(struct pci_dev *dev) | 158 | static u8 __devinit cs5535_cable_detect(ide_hwif_t *hwif) |
| 159 | { | 159 | { |
| 160 | struct pci_dev *dev = to_pci_dev(hwif->dev); | ||
| 160 | u8 bit; | 161 | u8 bit; |
| 161 | 162 | ||
| 162 | /* if a 80 wire cable was detected */ | 163 | /* if a 80 wire cable was detected */ |
| @@ -175,15 +176,10 @@ static u8 __devinit cs5535_cable_detect(struct pci_dev *dev) | |||
| 175 | */ | 176 | */ |
| 176 | static void __devinit init_hwif_cs5535(ide_hwif_t *hwif) | 177 | static void __devinit init_hwif_cs5535(ide_hwif_t *hwif) |
| 177 | { | 178 | { |
| 178 | struct pci_dev *dev = to_pci_dev(hwif->dev); | ||
| 179 | |||
| 180 | hwif->set_pio_mode = &cs5535_set_pio_mode; | 179 | hwif->set_pio_mode = &cs5535_set_pio_mode; |
| 181 | hwif->set_dma_mode = &cs5535_set_dma_mode; | 180 | hwif->set_dma_mode = &cs5535_set_dma_mode; |
| 182 | 181 | ||
| 183 | if (hwif->dma_base == 0) | 182 | hwif->cable_detect = cs5535_cable_detect; |
| 184 | return; | ||
| 185 | |||
| 186 | hwif->cbl = cs5535_cable_detect(dev); | ||
| 187 | } | 183 | } |
| 188 | 184 | ||
| 189 | static const struct ide_port_info cs5535_chipset __devinitdata = { | 185 | static const struct ide_port_info cs5535_chipset __devinitdata = { |
diff --git a/drivers/ide/pci/cy82c693.c b/drivers/ide/pci/cy82c693.c index 50100ac8770f..724cbacf4e5b 100644 --- a/drivers/ide/pci/cy82c693.c +++ b/drivers/ide/pci/cy82c693.c | |||
| @@ -45,7 +45,6 @@ | |||
| 45 | #include <linux/module.h> | 45 | #include <linux/module.h> |
| 46 | #include <linux/types.h> | 46 | #include <linux/types.h> |
| 47 | #include <linux/pci.h> | 47 | #include <linux/pci.h> |
| 48 | #include <linux/delay.h> | ||
| 49 | #include <linux/ide.h> | 48 | #include <linux/ide.h> |
| 50 | #include <linux/init.h> | 49 | #include <linux/init.h> |
| 51 | 50 | ||
diff --git a/drivers/ide/pci/delkin_cb.c b/drivers/ide/pci/delkin_cb.c index 27e47fc97100..3f9cd64c26a6 100644 --- a/drivers/ide/pci/delkin_cb.c +++ b/drivers/ide/pci/delkin_cb.c | |||
| @@ -16,15 +16,14 @@ | |||
| 16 | * License. See the file COPYING in the main directory of this archive for | 16 | * License. See the file COPYING in the main directory of this archive for |
| 17 | * more details. | 17 | * more details. |
| 18 | */ | 18 | */ |
| 19 | #include <linux/autoconf.h> | 19 | |
| 20 | #include <linux/types.h> | 20 | #include <linux/types.h> |
| 21 | #include <linux/module.h> | 21 | #include <linux/module.h> |
| 22 | #include <linux/mm.h> | ||
| 23 | #include <linux/blkdev.h> | ||
| 24 | #include <linux/hdreg.h> | 22 | #include <linux/hdreg.h> |
| 25 | #include <linux/ide.h> | 23 | #include <linux/ide.h> |
| 26 | #include <linux/init.h> | 24 | #include <linux/init.h> |
| 27 | #include <linux/pci.h> | 25 | #include <linux/pci.h> |
| 26 | |||
| 28 | #include <asm/io.h> | 27 | #include <asm/io.h> |
| 29 | 28 | ||
| 30 | /* | 29 | /* |
| @@ -52,6 +51,7 @@ delkin_cb_probe (struct pci_dev *dev, const struct pci_device_id *id) | |||
| 52 | ide_hwif_t *hwif = NULL; | 51 | ide_hwif_t *hwif = NULL; |
| 53 | ide_drive_t *drive; | 52 | ide_drive_t *drive; |
| 54 | int i, rc; | 53 | int i, rc; |
| 54 | u8 idx[4] = { 0xff, 0xff, 0xff, 0xff }; | ||
| 55 | 55 | ||
| 56 | rc = pci_enable_device(dev); | 56 | rc = pci_enable_device(dev); |
| 57 | if (rc) { | 57 | if (rc) { |
| @@ -78,12 +78,27 @@ delkin_cb_probe (struct pci_dev *dev, const struct pci_device_id *id) | |||
| 78 | hw.irq = dev->irq; | 78 | hw.irq = dev->irq; |
| 79 | hw.chipset = ide_pci; /* this enables IRQ sharing */ | 79 | hw.chipset = ide_pci; /* this enables IRQ sharing */ |
| 80 | 80 | ||
| 81 | rc = ide_register_hw(&hw, &ide_undecoded_slave, &hwif); | 81 | hwif = ide_deprecated_find_port(hw.io_ports[IDE_DATA_OFFSET]); |
| 82 | if (rc < 0) { | 82 | if (hwif == NULL) |
| 83 | printk(KERN_ERR "delkin_cb: ide_register_hw failed (%d)\n", rc); | 83 | goto out_disable; |
| 84 | pci_disable_device(dev); | 84 | |
| 85 | return -ENODEV; | 85 | i = hwif->index; |
| 86 | } | 86 | |
| 87 | if (hwif->present) | ||
| 88 | ide_unregister(i, 0, 0); | ||
| 89 | else if (!hwif->hold) | ||
| 90 | ide_init_port_data(hwif, i); | ||
| 91 | |||
| 92 | ide_init_port_hw(hwif, &hw); | ||
| 93 | hwif->quirkproc = &ide_undecoded_slave; | ||
| 94 | |||
| 95 | idx[0] = i; | ||
| 96 | |||
| 97 | ide_device_add(idx, NULL); | ||
| 98 | |||
| 99 | if (!hwif->present) | ||
| 100 | goto out_disable; | ||
| 101 | |||
| 87 | pci_set_drvdata(dev, hwif); | 102 | pci_set_drvdata(dev, hwif); |
| 88 | hwif->dev = &dev->dev; | 103 | hwif->dev = &dev->dev; |
| 89 | drive = &hwif->drives[0]; | 104 | drive = &hwif->drives[0]; |
| @@ -92,6 +107,11 @@ delkin_cb_probe (struct pci_dev *dev, const struct pci_device_id *id) | |||
| 92 | drive->unmask = 1; | 107 | drive->unmask = 1; |
| 93 | } | 108 | } |
| 94 | return 0; | 109 | return 0; |
| 110 | |||
| 111 | out_disable: | ||
| 112 | printk(KERN_ERR "delkin_cb: no IDE devices found\n"); | ||
| 113 | pci_disable_device(dev); | ||
| 114 | return -ENODEV; | ||
| 95 | } | 115 | } |
| 96 | 116 | ||
| 97 | static void | 117 | static void |
| @@ -100,7 +120,8 @@ delkin_cb_remove (struct pci_dev *dev) | |||
| 100 | ide_hwif_t *hwif = pci_get_drvdata(dev); | 120 | ide_hwif_t *hwif = pci_get_drvdata(dev); |
| 101 | 121 | ||
| 102 | if (hwif) | 122 | if (hwif) |
| 103 | ide_unregister(hwif->index); | 123 | ide_unregister(hwif->index, 0, 0); |
| 124 | |||
| 104 | pci_disable_device(dev); | 125 | pci_disable_device(dev); |
| 105 | } | 126 | } |
| 106 | 127 | ||
diff --git a/drivers/ide/pci/generic.c b/drivers/ide/pci/generic.c index 59ebe84f1053..9262a9174b4e 100644 --- a/drivers/ide/pci/generic.c +++ b/drivers/ide/pci/generic.c | |||
| @@ -22,18 +22,11 @@ | |||
| 22 | #include <linux/types.h> | 22 | #include <linux/types.h> |
| 23 | #include <linux/module.h> | 23 | #include <linux/module.h> |
| 24 | #include <linux/kernel.h> | 24 | #include <linux/kernel.h> |
| 25 | #include <linux/delay.h> | ||
| 26 | #include <linux/timer.h> | ||
| 27 | #include <linux/mm.h> | ||
| 28 | #include <linux/ioport.h> | ||
| 29 | #include <linux/blkdev.h> | ||
| 30 | #include <linux/hdreg.h> | 25 | #include <linux/hdreg.h> |
| 31 | #include <linux/pci.h> | 26 | #include <linux/pci.h> |
| 32 | #include <linux/ide.h> | 27 | #include <linux/ide.h> |
| 33 | #include <linux/init.h> | 28 | #include <linux/init.h> |
| 34 | 29 | ||
| 35 | #include <asm/io.h> | ||
| 36 | |||
| 37 | static int ide_generic_all; /* Set to claim all devices */ | 30 | static int ide_generic_all; /* Set to claim all devices */ |
| 38 | 31 | ||
| 39 | /* | 32 | /* |
diff --git a/drivers/ide/pci/hpt34x.c b/drivers/ide/pci/hpt34x.c index 25dbb814822d..9f01da46b016 100644 --- a/drivers/ide/pci/hpt34x.c +++ b/drivers/ide/pci/hpt34x.c | |||
| @@ -26,20 +26,13 @@ | |||
| 26 | #include <linux/module.h> | 26 | #include <linux/module.h> |
| 27 | #include <linux/types.h> | 27 | #include <linux/types.h> |
| 28 | #include <linux/kernel.h> | 28 | #include <linux/kernel.h> |
| 29 | #include <linux/delay.h> | ||
| 30 | #include <linux/timer.h> | ||
| 31 | #include <linux/mm.h> | ||
| 32 | #include <linux/ioport.h> | 29 | #include <linux/ioport.h> |
| 33 | #include <linux/blkdev.h> | ||
| 34 | #include <linux/hdreg.h> | 30 | #include <linux/hdreg.h> |
| 35 | #include <linux/interrupt.h> | 31 | #include <linux/interrupt.h> |
| 36 | #include <linux/pci.h> | 32 | #include <linux/pci.h> |
| 37 | #include <linux/init.h> | 33 | #include <linux/init.h> |
| 38 | #include <linux/ide.h> | 34 | #include <linux/ide.h> |
| 39 | 35 | ||
| 40 | #include <asm/io.h> | ||
| 41 | #include <asm/irq.h> | ||
| 42 | |||
| 43 | #define HPT343_DEBUG_DRIVE_INFO 0 | 36 | #define HPT343_DEBUG_DRIVE_INFO 0 |
| 44 | 37 | ||
| 45 | static void hpt34x_set_mode(ide_drive_t *drive, const u8 speed) | 38 | static void hpt34x_set_mode(ide_drive_t *drive, const u8 speed) |
diff --git a/drivers/ide/pci/hpt366.c b/drivers/ide/pci/hpt366.c index 5623cad569da..d0f7bb8b8adf 100644 --- a/drivers/ide/pci/hpt366.c +++ b/drivers/ide/pci/hpt366.c | |||
| @@ -121,12 +121,8 @@ | |||
| 121 | #include <linux/module.h> | 121 | #include <linux/module.h> |
| 122 | #include <linux/kernel.h> | 122 | #include <linux/kernel.h> |
| 123 | #include <linux/delay.h> | 123 | #include <linux/delay.h> |
| 124 | #include <linux/timer.h> | ||
| 125 | #include <linux/mm.h> | ||
| 126 | #include <linux/ioport.h> | ||
| 127 | #include <linux/blkdev.h> | 124 | #include <linux/blkdev.h> |
| 128 | #include <linux/hdreg.h> | 125 | #include <linux/hdreg.h> |
| 129 | |||
| 130 | #include <linux/interrupt.h> | 126 | #include <linux/interrupt.h> |
| 131 | #include <linux/pci.h> | 127 | #include <linux/pci.h> |
| 132 | #include <linux/init.h> | 128 | #include <linux/init.h> |
| @@ -134,7 +130,6 @@ | |||
| 134 | 130 | ||
| 135 | #include <asm/uaccess.h> | 131 | #include <asm/uaccess.h> |
| 136 | #include <asm/io.h> | 132 | #include <asm/io.h> |
| 137 | #include <asm/irq.h> | ||
| 138 | 133 | ||
| 139 | /* various tuning parameters */ | 134 | /* various tuning parameters */ |
| 140 | #define HPT_RESET_STATE_ENGINE | 135 | #define HPT_RESET_STATE_ENGINE |
| @@ -1279,12 +1274,55 @@ static unsigned int __devinit init_chipset_hpt366(struct pci_dev *dev, const cha | |||
| 1279 | return dev->irq; | 1274 | return dev->irq; |
| 1280 | } | 1275 | } |
| 1281 | 1276 | ||
| 1277 | static u8 __devinit hpt3xx_cable_detect(ide_hwif_t *hwif) | ||
| 1278 | { | ||
| 1279 | struct pci_dev *dev = to_pci_dev(hwif->dev); | ||
| 1280 | struct hpt_info *info = pci_get_drvdata(dev); | ||
| 1281 | u8 chip_type = info->chip_type; | ||
| 1282 | u8 scr1 = 0, ata66 = hwif->channel ? 0x01 : 0x02; | ||
| 1283 | |||
| 1284 | /* | ||
| 1285 | * The HPT37x uses the CBLID pins as outputs for MA15/MA16 | ||
| 1286 | * address lines to access an external EEPROM. To read valid | ||
| 1287 | * cable detect state the pins must be enabled as inputs. | ||
| 1288 | */ | ||
| 1289 | if (chip_type == HPT374 && (PCI_FUNC(dev->devfn) & 1)) { | ||
| 1290 | /* | ||
| 1291 | * HPT374 PCI function 1 | ||
| 1292 | * - set bit 15 of reg 0x52 to enable TCBLID as input | ||
| 1293 | * - set bit 15 of reg 0x56 to enable FCBLID as input | ||
| 1294 | */ | ||
| 1295 | u8 mcr_addr = hwif->select_data + 2; | ||
| 1296 | u16 mcr; | ||
| 1297 | |||
| 1298 | pci_read_config_word(dev, mcr_addr, &mcr); | ||
| 1299 | pci_write_config_word(dev, mcr_addr, (mcr | 0x8000)); | ||
| 1300 | /* now read cable id register */ | ||
| 1301 | pci_read_config_byte(dev, 0x5a, &scr1); | ||
| 1302 | pci_write_config_word(dev, mcr_addr, mcr); | ||
| 1303 | } else if (chip_type >= HPT370) { | ||
| 1304 | /* | ||
| 1305 | * HPT370/372 and 374 pcifn 0 | ||
| 1306 | * - clear bit 0 of reg 0x5b to enable P/SCBLID as inputs | ||
| 1307 | */ | ||
| 1308 | u8 scr2 = 0; | ||
| 1309 | |||
| 1310 | pci_read_config_byte(dev, 0x5b, &scr2); | ||
| 1311 | pci_write_config_byte(dev, 0x5b, (scr2 & ~1)); | ||
| 1312 | /* now read cable id register */ | ||
| 1313 | pci_read_config_byte(dev, 0x5a, &scr1); | ||
| 1314 | pci_write_config_byte(dev, 0x5b, scr2); | ||
| 1315 | } else | ||
| 1316 | pci_read_config_byte(dev, 0x5a, &scr1); | ||
| 1317 | |||
| 1318 | return (scr1 & ata66) ? ATA_CBL_PATA40 : ATA_CBL_PATA80; | ||
| 1319 | } | ||
| 1320 | |||
| 1282 | static void __devinit init_hwif_hpt366(ide_hwif_t *hwif) | 1321 | static void __devinit init_hwif_hpt366(ide_hwif_t *hwif) |
| 1283 | { | 1322 | { |
| 1284 | struct pci_dev *dev = to_pci_dev(hwif->dev); | 1323 | struct pci_dev *dev = to_pci_dev(hwif->dev); |
| 1285 | struct hpt_info *info = pci_get_drvdata(dev); | 1324 | struct hpt_info *info = pci_get_drvdata(dev); |
| 1286 | int serialize = HPT_SERIALIZE_IO; | 1325 | int serialize = HPT_SERIALIZE_IO; |
| 1287 | u8 scr1 = 0, ata66 = hwif->channel ? 0x01 : 0x02; | ||
| 1288 | u8 chip_type = info->chip_type; | 1326 | u8 chip_type = info->chip_type; |
| 1289 | u8 new_mcr, old_mcr = 0; | 1327 | u8 new_mcr, old_mcr = 0; |
| 1290 | 1328 | ||
| @@ -1301,6 +1339,8 @@ static void __devinit init_hwif_hpt366(ide_hwif_t *hwif) | |||
| 1301 | hwif->udma_filter = &hpt3xx_udma_filter; | 1339 | hwif->udma_filter = &hpt3xx_udma_filter; |
| 1302 | hwif->mdma_filter = &hpt3xx_mdma_filter; | 1340 | hwif->mdma_filter = &hpt3xx_mdma_filter; |
| 1303 | 1341 | ||
| 1342 | hwif->cable_detect = hpt3xx_cable_detect; | ||
| 1343 | |||
| 1304 | /* | 1344 | /* |
| 1305 | * HPT3xxN chips have some complications: | 1345 | * HPT3xxN chips have some complications: |
| 1306 | * | 1346 | * |
| @@ -1346,43 +1386,6 @@ static void __devinit init_hwif_hpt366(ide_hwif_t *hwif) | |||
| 1346 | if (hwif->dma_base == 0) | 1386 | if (hwif->dma_base == 0) |
| 1347 | return; | 1387 | return; |
| 1348 | 1388 | ||
| 1349 | /* | ||
| 1350 | * The HPT37x uses the CBLID pins as outputs for MA15/MA16 | ||
| 1351 | * address lines to access an external EEPROM. To read valid | ||
| 1352 | * cable detect state the pins must be enabled as inputs. | ||
| 1353 | */ | ||
| 1354 | if (chip_type == HPT374 && (PCI_FUNC(dev->devfn) & 1)) { | ||
| 1355 | /* | ||
| 1356 | * HPT374 PCI function 1 | ||
| 1357 | * - set bit 15 of reg 0x52 to enable TCBLID as input | ||
| 1358 | * - set bit 15 of reg 0x56 to enable FCBLID as input | ||
| 1359 | */ | ||
| 1360 | u8 mcr_addr = hwif->select_data + 2; | ||
| 1361 | u16 mcr; | ||
| 1362 | |||
| 1363 | pci_read_config_word (dev, mcr_addr, &mcr); | ||
| 1364 | pci_write_config_word(dev, mcr_addr, (mcr | 0x8000)); | ||
| 1365 | /* now read cable id register */ | ||
| 1366 | pci_read_config_byte (dev, 0x5a, &scr1); | ||
| 1367 | pci_write_config_word(dev, mcr_addr, mcr); | ||
| 1368 | } else if (chip_type >= HPT370) { | ||
| 1369 | /* | ||
| 1370 | * HPT370/372 and 374 pcifn 0 | ||
| 1371 | * - clear bit 0 of reg 0x5b to enable P/SCBLID as inputs | ||
| 1372 | */ | ||
| 1373 | u8 scr2 = 0; | ||
| 1374 | |||
| 1375 | pci_read_config_byte (dev, 0x5b, &scr2); | ||
| 1376 | pci_write_config_byte(dev, 0x5b, (scr2 & ~1)); | ||
| 1377 | /* now read cable id register */ | ||
| 1378 | pci_read_config_byte (dev, 0x5a, &scr1); | ||
| 1379 | pci_write_config_byte(dev, 0x5b, scr2); | ||
| 1380 | } else | ||
| 1381 | pci_read_config_byte (dev, 0x5a, &scr1); | ||
| 1382 | |||
| 1383 | if (hwif->cbl != ATA_CBL_PATA40_SHORT) | ||
| 1384 | hwif->cbl = (scr1 & ata66) ? ATA_CBL_PATA40 : ATA_CBL_PATA80; | ||
| 1385 | |||
| 1386 | if (chip_type >= HPT374) { | 1389 | if (chip_type >= HPT374) { |
| 1387 | hwif->ide_dma_test_irq = &hpt374_ide_dma_test_irq; | 1390 | hwif->ide_dma_test_irq = &hpt374_ide_dma_test_irq; |
| 1388 | hwif->ide_dma_end = &hpt374_ide_dma_end; | 1391 | hwif->ide_dma_end = &hpt374_ide_dma_end; |
diff --git a/drivers/ide/pci/it8213.c b/drivers/ide/pci/it8213.c index df74e588a530..e3427eaab430 100644 --- a/drivers/ide/pci/it8213.c +++ b/drivers/ide/pci/it8213.c | |||
| @@ -10,13 +10,10 @@ | |||
| 10 | #include <linux/types.h> | 10 | #include <linux/types.h> |
| 11 | #include <linux/module.h> | 11 | #include <linux/module.h> |
| 12 | #include <linux/pci.h> | 12 | #include <linux/pci.h> |
| 13 | #include <linux/delay.h> | ||
| 14 | #include <linux/hdreg.h> | 13 | #include <linux/hdreg.h> |
| 15 | #include <linux/ide.h> | 14 | #include <linux/ide.h> |
| 16 | #include <linux/init.h> | 15 | #include <linux/init.h> |
| 17 | 16 | ||
| 18 | #include <asm/io.h> | ||
| 19 | |||
| 20 | /** | 17 | /** |
| 21 | * it8213_set_pio_mode - set host controller for PIO mode | 18 | * it8213_set_pio_mode - set host controller for PIO mode |
| 22 | * @drive: drive | 19 | * @drive: drive |
| @@ -143,6 +140,16 @@ static void it8213_set_dma_mode(ide_drive_t *drive, const u8 speed) | |||
| 143 | } | 140 | } |
| 144 | } | 141 | } |
| 145 | 142 | ||
| 143 | static u8 __devinit it8213_cable_detect(ide_hwif_t *hwif) | ||
| 144 | { | ||
| 145 | struct pci_dev *dev = to_pci_dev(hwif->dev); | ||
| 146 | u8 reg42h = 0; | ||
| 147 | |||
| 148 | pci_read_config_byte(dev, 0x42, ®42h); | ||
| 149 | |||
| 150 | return (reg42h & 0x02) ? ATA_CBL_PATA40 : ATA_CBL_PATA80; | ||
| 151 | } | ||
| 152 | |||
| 146 | /** | 153 | /** |
| 147 | * init_hwif_it8213 - set up hwif structs | 154 | * init_hwif_it8213 - set up hwif structs |
| 148 | * @hwif: interface to set up | 155 | * @hwif: interface to set up |
| @@ -152,19 +159,10 @@ static void it8213_set_dma_mode(ide_drive_t *drive, const u8 speed) | |||
| 152 | 159 | ||
| 153 | static void __devinit init_hwif_it8213(ide_hwif_t *hwif) | 160 | static void __devinit init_hwif_it8213(ide_hwif_t *hwif) |
| 154 | { | 161 | { |
| 155 | struct pci_dev *dev = to_pci_dev(hwif->dev); | ||
| 156 | u8 reg42h = 0; | ||
| 157 | |||
| 158 | hwif->set_dma_mode = &it8213_set_dma_mode; | 162 | hwif->set_dma_mode = &it8213_set_dma_mode; |
| 159 | hwif->set_pio_mode = &it8213_set_pio_mode; | 163 | hwif->set_pio_mode = &it8213_set_pio_mode; |
| 160 | 164 | ||
| 161 | if (!hwif->dma_base) | 165 | hwif->cable_detect = it8213_cable_detect; |
| 162 | return; | ||
| 163 | |||
| 164 | pci_read_config_byte(dev, 0x42, ®42h); | ||
| 165 | |||
| 166 | if (hwif->cbl != ATA_CBL_PATA40_SHORT) | ||
| 167 | hwif->cbl = (reg42h & 0x02) ? ATA_CBL_PATA40 : ATA_CBL_PATA80; | ||
| 168 | } | 166 | } |
| 169 | 167 | ||
| 170 | 168 | ||
diff --git a/drivers/ide/pci/it821x.c b/drivers/ide/pci/it821x.c index 938d35f35c81..1597f0cc1bf1 100644 --- a/drivers/ide/pci/it821x.c +++ b/drivers/ide/pci/it821x.c | |||
| @@ -63,13 +63,10 @@ | |||
| 63 | #include <linux/types.h> | 63 | #include <linux/types.h> |
| 64 | #include <linux/module.h> | 64 | #include <linux/module.h> |
| 65 | #include <linux/pci.h> | 65 | #include <linux/pci.h> |
| 66 | #include <linux/delay.h> | ||
| 67 | #include <linux/hdreg.h> | 66 | #include <linux/hdreg.h> |
| 68 | #include <linux/ide.h> | 67 | #include <linux/ide.h> |
| 69 | #include <linux/init.h> | 68 | #include <linux/init.h> |
| 70 | 69 | ||
| 71 | #include <asm/io.h> | ||
| 72 | |||
| 73 | struct it821x_dev | 70 | struct it821x_dev |
| 74 | { | 71 | { |
| 75 | unsigned int smart:1, /* Are we in smart raid mode */ | 72 | unsigned int smart:1, /* Are we in smart raid mode */ |
| @@ -579,14 +576,13 @@ static void __devinit init_hwif_it821x(ide_hwif_t *hwif) | |||
| 579 | } else | 576 | } else |
| 580 | hwif->host_flags |= IDE_HFLAG_NO_SET_MODE; | 577 | hwif->host_flags |= IDE_HFLAG_NO_SET_MODE; |
| 581 | 578 | ||
| 579 | hwif->cable_detect = ata66_it821x; | ||
| 580 | |||
| 582 | if (hwif->dma_base == 0) | 581 | if (hwif->dma_base == 0) |
| 583 | return; | 582 | return; |
| 584 | 583 | ||
| 585 | hwif->ultra_mask = ATA_UDMA6; | 584 | hwif->ultra_mask = ATA_UDMA6; |
| 586 | hwif->mwdma_mask = ATA_MWDMA2; | 585 | hwif->mwdma_mask = ATA_MWDMA2; |
| 587 | |||
| 588 | if (hwif->cbl != ATA_CBL_PATA40_SHORT) | ||
| 589 | hwif->cbl = ata66_it821x(hwif); | ||
| 590 | } | 586 | } |
| 591 | 587 | ||
| 592 | static void __devinit it8212_disable_raid(struct pci_dev *dev) | 588 | static void __devinit it8212_disable_raid(struct pci_dev *dev) |
diff --git a/drivers/ide/pci/jmicron.c b/drivers/ide/pci/jmicron.c index 8b40f6479c55..a56bcb4f22f4 100644 --- a/drivers/ide/pci/jmicron.c +++ b/drivers/ide/pci/jmicron.c | |||
| @@ -8,13 +8,10 @@ | |||
| 8 | #include <linux/types.h> | 8 | #include <linux/types.h> |
| 9 | #include <linux/module.h> | 9 | #include <linux/module.h> |
| 10 | #include <linux/pci.h> | 10 | #include <linux/pci.h> |
| 11 | #include <linux/delay.h> | ||
| 12 | #include <linux/hdreg.h> | 11 | #include <linux/hdreg.h> |
| 13 | #include <linux/ide.h> | 12 | #include <linux/ide.h> |
| 14 | #include <linux/init.h> | 13 | #include <linux/init.h> |
| 15 | 14 | ||
| 16 | #include <asm/io.h> | ||
| 17 | |||
| 18 | typedef enum { | 15 | typedef enum { |
| 19 | PORT_PATA0 = 0, | 16 | PORT_PATA0 = 0, |
| 20 | PORT_PATA1 = 1, | 17 | PORT_PATA1 = 1, |
| @@ -111,11 +108,7 @@ static void __devinit init_hwif_jmicron(ide_hwif_t *hwif) | |||
| 111 | hwif->set_pio_mode = &jmicron_set_pio_mode; | 108 | hwif->set_pio_mode = &jmicron_set_pio_mode; |
| 112 | hwif->set_dma_mode = &jmicron_set_dma_mode; | 109 | hwif->set_dma_mode = &jmicron_set_dma_mode; |
| 113 | 110 | ||
| 114 | if (hwif->dma_base == 0) | 111 | hwif->cable_detect = ata66_jmicron; |
| 115 | return; | ||
| 116 | |||
| 117 | if (hwif->cbl != ATA_CBL_PATA40_SHORT) | ||
| 118 | hwif->cbl = ata66_jmicron(hwif); | ||
| 119 | } | 112 | } |
| 120 | 113 | ||
| 121 | static const struct ide_port_info jmicron_chipset __devinitdata = { | 114 | static const struct ide_port_info jmicron_chipset __devinitdata = { |
diff --git a/drivers/ide/pci/ns87415.c b/drivers/ide/pci/ns87415.c index fc9eee9ccac3..bf0d3b2931f1 100644 --- a/drivers/ide/pci/ns87415.c +++ b/drivers/ide/pci/ns87415.c | |||
| @@ -10,11 +10,7 @@ | |||
| 10 | #include <linux/module.h> | 10 | #include <linux/module.h> |
| 11 | #include <linux/types.h> | 11 | #include <linux/types.h> |
| 12 | #include <linux/kernel.h> | 12 | #include <linux/kernel.h> |
| 13 | #include <linux/timer.h> | ||
| 14 | #include <linux/mm.h> | ||
| 15 | #include <linux/ioport.h> | ||
| 16 | #include <linux/interrupt.h> | 13 | #include <linux/interrupt.h> |
| 17 | #include <linux/blkdev.h> | ||
| 18 | #include <linux/hdreg.h> | 14 | #include <linux/hdreg.h> |
| 19 | #include <linux/pci.h> | 15 | #include <linux/pci.h> |
| 20 | #include <linux/delay.h> | 16 | #include <linux/delay.h> |
diff --git a/drivers/ide/pci/opti621.c b/drivers/ide/pci/opti621.c index 0ce92d323036..46e8748f507e 100644 --- a/drivers/ide/pci/opti621.c +++ b/drivers/ide/pci/opti621.c | |||
| @@ -87,11 +87,6 @@ | |||
| 87 | #include <linux/types.h> | 87 | #include <linux/types.h> |
| 88 | #include <linux/module.h> | 88 | #include <linux/module.h> |
| 89 | #include <linux/kernel.h> | 89 | #include <linux/kernel.h> |
| 90 | #include <linux/delay.h> | ||
| 91 | #include <linux/timer.h> | ||
| 92 | #include <linux/mm.h> | ||
| 93 | #include <linux/ioport.h> | ||
| 94 | #include <linux/blkdev.h> | ||
| 95 | #include <linux/pci.h> | 90 | #include <linux/pci.h> |
| 96 | #include <linux/hdreg.h> | 91 | #include <linux/hdreg.h> |
| 97 | #include <linux/ide.h> | 92 | #include <linux/ide.h> |
| @@ -320,14 +315,18 @@ static void opti621_set_pio_mode(ide_drive_t *drive, const u8 pio) | |||
| 320 | spin_unlock_irqrestore(&opti621_lock, flags); | 315 | spin_unlock_irqrestore(&opti621_lock, flags); |
| 321 | } | 316 | } |
| 322 | 317 | ||
| 318 | static void __devinit opti621_port_init_devs(ide_hwif_t *hwif) | ||
| 319 | { | ||
| 320 | hwif->drives[0].drive_data = PIO_DONT_KNOW; | ||
| 321 | hwif->drives[1].drive_data = PIO_DONT_KNOW; | ||
| 322 | } | ||
| 323 | |||
| 323 | /* | 324 | /* |
| 324 | * init_hwif_opti621() is called once for each hwif found at boot. | 325 | * init_hwif_opti621() is called once for each hwif found at boot. |
| 325 | */ | 326 | */ |
| 326 | static void __devinit init_hwif_opti621 (ide_hwif_t *hwif) | 327 | static void __devinit init_hwif_opti621 (ide_hwif_t *hwif) |
| 327 | { | 328 | { |
| 328 | hwif->drives[0].drive_data = PIO_DONT_KNOW; | 329 | hwif->port_init_devs = opti621_port_init_devs; |
| 329 | hwif->drives[1].drive_data = PIO_DONT_KNOW; | ||
| 330 | |||
| 331 | hwif->set_pio_mode = &opti621_set_pio_mode; | 330 | hwif->set_pio_mode = &opti621_set_pio_mode; |
| 332 | } | 331 | } |
| 333 | 332 | ||
diff --git a/drivers/ide/pci/pdc202xx_new.c b/drivers/ide/pci/pdc202xx_new.c index bb29db03540e..1c8cb7797a4a 100644 --- a/drivers/ide/pci/pdc202xx_new.c +++ b/drivers/ide/pci/pdc202xx_new.c | |||
| @@ -19,18 +19,12 @@ | |||
| 19 | #include <linux/types.h> | 19 | #include <linux/types.h> |
| 20 | #include <linux/kernel.h> | 20 | #include <linux/kernel.h> |
| 21 | #include <linux/delay.h> | 21 | #include <linux/delay.h> |
| 22 | #include <linux/timer.h> | ||
| 23 | #include <linux/mm.h> | ||
| 24 | #include <linux/ioport.h> | ||
| 25 | #include <linux/blkdev.h> | ||
| 26 | #include <linux/hdreg.h> | 22 | #include <linux/hdreg.h> |
| 27 | #include <linux/interrupt.h> | ||
| 28 | #include <linux/pci.h> | 23 | #include <linux/pci.h> |
| 29 | #include <linux/init.h> | 24 | #include <linux/init.h> |
| 30 | #include <linux/ide.h> | 25 | #include <linux/ide.h> |
| 31 | 26 | ||
| 32 | #include <asm/io.h> | 27 | #include <asm/io.h> |
| 33 | #include <asm/irq.h> | ||
| 34 | 28 | ||
| 35 | #ifdef CONFIG_PPC_PMAC | 29 | #ifdef CONFIG_PPC_PMAC |
| 36 | #include <asm/prom.h> | 30 | #include <asm/prom.h> |
| @@ -197,7 +191,7 @@ static void pdcnew_set_pio_mode(ide_drive_t *drive, const u8 pio) | |||
| 197 | } | 191 | } |
| 198 | } | 192 | } |
| 199 | 193 | ||
| 200 | static u8 pdcnew_cable_detect(ide_hwif_t *hwif) | 194 | static u8 __devinit pdcnew_cable_detect(ide_hwif_t *hwif) |
| 201 | { | 195 | { |
| 202 | if (get_indexed_reg(hwif, 0x0b) & 0x04) | 196 | if (get_indexed_reg(hwif, 0x0b) & 0x04) |
| 203 | return ATA_CBL_PATA40; | 197 | return ATA_CBL_PATA40; |
| @@ -456,11 +450,7 @@ static void __devinit init_hwif_pdc202new(ide_hwif_t *hwif) | |||
| 456 | hwif->quirkproc = &pdcnew_quirkproc; | 450 | hwif->quirkproc = &pdcnew_quirkproc; |
| 457 | hwif->resetproc = &pdcnew_reset; | 451 | hwif->resetproc = &pdcnew_reset; |
| 458 | 452 | ||
| 459 | if (hwif->dma_base == 0) | 453 | hwif->cable_detect = pdcnew_cable_detect; |
| 460 | return; | ||
| 461 | |||
| 462 | if (hwif->cbl != ATA_CBL_PATA40_SHORT) | ||
| 463 | hwif->cbl = pdcnew_cable_detect(hwif); | ||
| 464 | } | 454 | } |
| 465 | 455 | ||
| 466 | static struct pci_dev * __devinit pdc20270_get_dev2(struct pci_dev *dev) | 456 | static struct pci_dev * __devinit pdc20270_get_dev2(struct pci_dev *dev) |
diff --git a/drivers/ide/pci/pdc202xx_old.c b/drivers/ide/pci/pdc202xx_old.c index 31a1308414a0..da4329790387 100644 --- a/drivers/ide/pci/pdc202xx_old.c +++ b/drivers/ide/pci/pdc202xx_old.c | |||
| @@ -32,18 +32,13 @@ | |||
| 32 | #include <linux/module.h> | 32 | #include <linux/module.h> |
| 33 | #include <linux/kernel.h> | 33 | #include <linux/kernel.h> |
| 34 | #include <linux/delay.h> | 34 | #include <linux/delay.h> |
| 35 | #include <linux/timer.h> | ||
| 36 | #include <linux/mm.h> | ||
| 37 | #include <linux/ioport.h> | ||
| 38 | #include <linux/blkdev.h> | 35 | #include <linux/blkdev.h> |
| 39 | #include <linux/hdreg.h> | 36 | #include <linux/hdreg.h> |
| 40 | #include <linux/interrupt.h> | ||
| 41 | #include <linux/pci.h> | 37 | #include <linux/pci.h> |
| 42 | #include <linux/init.h> | 38 | #include <linux/init.h> |
| 43 | #include <linux/ide.h> | 39 | #include <linux/ide.h> |
| 44 | 40 | ||
| 45 | #include <asm/io.h> | 41 | #include <asm/io.h> |
| 46 | #include <asm/irq.h> | ||
| 47 | 42 | ||
| 48 | #define PDC202XX_DEBUG_DRIVE_INFO 0 | 43 | #define PDC202XX_DEBUG_DRIVE_INFO 0 |
| 49 | 44 | ||
| @@ -140,10 +135,10 @@ static void pdc202xx_set_pio_mode(ide_drive_t *drive, const u8 pio) | |||
| 140 | pdc202xx_set_mode(drive, XFER_PIO_0 + pio); | 135 | pdc202xx_set_mode(drive, XFER_PIO_0 + pio); |
| 141 | } | 136 | } |
| 142 | 137 | ||
| 143 | static u8 pdc202xx_old_cable_detect (ide_hwif_t *hwif) | 138 | static u8 __devinit pdc2026x_old_cable_detect(ide_hwif_t *hwif) |
| 144 | { | 139 | { |
| 145 | struct pci_dev *dev = to_pci_dev(hwif->dev); | 140 | struct pci_dev *dev = to_pci_dev(hwif->dev); |
| 146 | u16 CIS = 0, mask = (hwif->channel) ? (1<<11) : (1<<10); | 141 | u16 CIS, mask = hwif->channel ? (1 << 11) : (1 << 10); |
| 147 | 142 | ||
| 148 | pci_read_config_word(dev, 0x50, &CIS); | 143 | pci_read_config_word(dev, 0x50, &CIS); |
| 149 | 144 | ||
| @@ -311,9 +306,12 @@ static void __devinit init_hwif_pdc202xx(ide_hwif_t *hwif) | |||
| 311 | 306 | ||
| 312 | hwif->quirkproc = &pdc202xx_quirkproc; | 307 | hwif->quirkproc = &pdc202xx_quirkproc; |
| 313 | 308 | ||
| 314 | if (dev->device != PCI_DEVICE_ID_PROMISE_20246) | 309 | if (dev->device != PCI_DEVICE_ID_PROMISE_20246) { |
| 315 | hwif->resetproc = &pdc202xx_reset; | 310 | hwif->resetproc = &pdc202xx_reset; |
| 316 | 311 | ||
| 312 | hwif->cable_detect = pdc2026x_old_cable_detect; | ||
| 313 | } | ||
| 314 | |||
| 317 | if (hwif->dma_base == 0) | 315 | if (hwif->dma_base == 0) |
| 318 | return; | 316 | return; |
| 319 | 317 | ||
| @@ -321,9 +319,6 @@ static void __devinit init_hwif_pdc202xx(ide_hwif_t *hwif) | |||
| 321 | hwif->dma_timeout = &pdc202xx_dma_timeout; | 319 | hwif->dma_timeout = &pdc202xx_dma_timeout; |
| 322 | 320 | ||
| 323 | if (dev->device != PCI_DEVICE_ID_PROMISE_20246) { | 321 | if (dev->device != PCI_DEVICE_ID_PROMISE_20246) { |
| 324 | if (hwif->cbl != ATA_CBL_PATA40_SHORT) | ||
| 325 | hwif->cbl = pdc202xx_old_cable_detect(hwif); | ||
| 326 | |||
| 327 | hwif->dma_start = &pdc202xx_old_ide_dma_start; | 322 | hwif->dma_start = &pdc202xx_old_ide_dma_start; |
| 328 | hwif->ide_dma_end = &pdc202xx_old_ide_dma_end; | 323 | hwif->ide_dma_end = &pdc202xx_old_ide_dma_end; |
| 329 | } | 324 | } |
diff --git a/drivers/ide/pci/piix.c b/drivers/ide/pci/piix.c index c1a6b68337d5..decef0f47674 100644 --- a/drivers/ide/pci/piix.c +++ b/drivers/ide/pci/piix.c | |||
| @@ -47,11 +47,9 @@ | |||
| 47 | #include <linux/types.h> | 47 | #include <linux/types.h> |
| 48 | #include <linux/module.h> | 48 | #include <linux/module.h> |
| 49 | #include <linux/kernel.h> | 49 | #include <linux/kernel.h> |
| 50 | #include <linux/ioport.h> | ||
| 51 | #include <linux/pci.h> | 50 | #include <linux/pci.h> |
| 52 | #include <linux/hdreg.h> | 51 | #include <linux/hdreg.h> |
| 53 | #include <linux/ide.h> | 52 | #include <linux/ide.h> |
| 54 | #include <linux/delay.h> | ||
| 55 | #include <linux/init.h> | 53 | #include <linux/init.h> |
| 56 | 54 | ||
| 57 | #include <asm/io.h> | 55 | #include <asm/io.h> |
| @@ -290,14 +288,11 @@ static void __devinit init_hwif_piix(ide_hwif_t *hwif) | |||
| 290 | hwif->set_pio_mode = &piix_set_pio_mode; | 288 | hwif->set_pio_mode = &piix_set_pio_mode; |
| 291 | hwif->set_dma_mode = &piix_set_dma_mode; | 289 | hwif->set_dma_mode = &piix_set_dma_mode; |
| 292 | 290 | ||
| 291 | hwif->cable_detect = piix_cable_detect; | ||
| 292 | |||
| 293 | if (!hwif->dma_base) | 293 | if (!hwif->dma_base) |
| 294 | return; | 294 | return; |
| 295 | 295 | ||
| 296 | if (hwif->ultra_mask & 0x78) { | ||
| 297 | if (hwif->cbl != ATA_CBL_PATA40_SHORT) | ||
| 298 | hwif->cbl = piix_cable_detect(hwif); | ||
| 299 | } | ||
| 300 | |||
| 301 | if (no_piix_dma) | 296 | if (no_piix_dma) |
| 302 | hwif->ultra_mask = hwif->mwdma_mask = hwif->swdma_mask = 0; | 297 | hwif->ultra_mask = hwif->mwdma_mask = hwif->swdma_mask = 0; |
| 303 | } | 298 | } |
diff --git a/drivers/ide/pci/rz1000.c b/drivers/ide/pci/rz1000.c index 7ed6625819d4..51676612f78f 100644 --- a/drivers/ide/pci/rz1000.c +++ b/drivers/ide/pci/rz1000.c | |||
| @@ -16,18 +16,11 @@ | |||
| 16 | #include <linux/types.h> | 16 | #include <linux/types.h> |
| 17 | #include <linux/module.h> | 17 | #include <linux/module.h> |
| 18 | #include <linux/kernel.h> | 18 | #include <linux/kernel.h> |
| 19 | #include <linux/delay.h> | ||
| 20 | #include <linux/timer.h> | ||
| 21 | #include <linux/mm.h> | ||
| 22 | #include <linux/ioport.h> | ||
| 23 | #include <linux/blkdev.h> | ||
| 24 | #include <linux/hdreg.h> | 19 | #include <linux/hdreg.h> |
| 25 | #include <linux/pci.h> | 20 | #include <linux/pci.h> |
| 26 | #include <linux/ide.h> | 21 | #include <linux/ide.h> |
| 27 | #include <linux/init.h> | 22 | #include <linux/init.h> |
| 28 | 23 | ||
| 29 | #include <asm/io.h> | ||
| 30 | |||
| 31 | static void __devinit init_hwif_rz1000 (ide_hwif_t *hwif) | 24 | static void __devinit init_hwif_rz1000 (ide_hwif_t *hwif) |
| 32 | { | 25 | { |
| 33 | struct pci_dev *dev = to_pci_dev(hwif->dev); | 26 | struct pci_dev *dev = to_pci_dev(hwif->dev); |
| @@ -40,8 +33,7 @@ static void __devinit init_hwif_rz1000 (ide_hwif_t *hwif) | |||
| 40 | } else { | 33 | } else { |
| 41 | if (hwif->mate) | 34 | if (hwif->mate) |
| 42 | hwif->mate->serialized = hwif->serialized = 1; | 35 | hwif->mate->serialized = hwif->serialized = 1; |
| 43 | hwif->drives[0].no_unmask = 1; | 36 | hwif->host_flags |= IDE_HFLAG_NO_UNMASK_IRQS; |
| 44 | hwif->drives[1].no_unmask = 1; | ||
| 45 | printk(KERN_INFO "%s: serialized, disabled unmasking " | 37 | printk(KERN_INFO "%s: serialized, disabled unmasking " |
| 46 | "(buggy RZ1000/RZ1001)\n", hwif->name); | 38 | "(buggy RZ1000/RZ1001)\n", hwif->name); |
| 47 | } | 39 | } |
diff --git a/drivers/ide/pci/sc1200.c b/drivers/ide/pci/sc1200.c index af499a60eb31..561aa47c7720 100644 --- a/drivers/ide/pci/sc1200.c +++ b/drivers/ide/pci/sc1200.c | |||
| @@ -14,19 +14,13 @@ | |||
| 14 | #include <linux/module.h> | 14 | #include <linux/module.h> |
| 15 | #include <linux/types.h> | 15 | #include <linux/types.h> |
| 16 | #include <linux/kernel.h> | 16 | #include <linux/kernel.h> |
| 17 | #include <linux/delay.h> | ||
| 18 | #include <linux/timer.h> | ||
| 19 | #include <linux/mm.h> | ||
| 20 | #include <linux/ioport.h> | ||
| 21 | #include <linux/blkdev.h> | ||
| 22 | #include <linux/hdreg.h> | 17 | #include <linux/hdreg.h> |
| 23 | #include <linux/interrupt.h> | ||
| 24 | #include <linux/pci.h> | 18 | #include <linux/pci.h> |
| 25 | #include <linux/init.h> | 19 | #include <linux/init.h> |
| 26 | #include <linux/ide.h> | 20 | #include <linux/ide.h> |
| 27 | #include <linux/pm.h> | 21 | #include <linux/pm.h> |
| 22 | |||
| 28 | #include <asm/io.h> | 23 | #include <asm/io.h> |
| 29 | #include <asm/irq.h> | ||
| 30 | 24 | ||
| 31 | #define SC1200_REV_A 0x00 | 25 | #define SC1200_REV_A 0x00 |
| 32 | #define SC1200_REV_B1 0x01 | 26 | #define SC1200_REV_B1 0x01 |
diff --git a/drivers/ide/pci/scc_pata.c b/drivers/ide/pci/scc_pata.c index 7694969b02ce..238e3e181e87 100644 --- a/drivers/ide/pci/scc_pata.c +++ b/drivers/ide/pci/scc_pata.c | |||
| @@ -644,6 +644,11 @@ static void __devinit init_iops_scc(ide_hwif_t *hwif) | |||
| 644 | init_mmio_iops_scc(hwif); | 644 | init_mmio_iops_scc(hwif); |
| 645 | } | 645 | } |
| 646 | 646 | ||
| 647 | static u8 __devinit scc_cable_detect(ide_hwif_t *hwif) | ||
| 648 | { | ||
| 649 | return ATA_CBL_PATA80; | ||
| 650 | } | ||
| 651 | |||
| 647 | /** | 652 | /** |
| 648 | * init_hwif_scc - set up hwif | 653 | * init_hwif_scc - set up hwif |
| 649 | * @hwif: interface to set up | 654 | * @hwif: interface to set up |
| @@ -678,8 +683,7 @@ static void __devinit init_hwif_scc(ide_hwif_t *hwif) | |||
| 678 | else | 683 | else |
| 679 | hwif->ultra_mask = ATA_UDMA5; /* 100MHz */ | 684 | hwif->ultra_mask = ATA_UDMA5; /* 100MHz */ |
| 680 | 685 | ||
| 681 | /* we support 80c cable only. */ | 686 | hwif->cable_detect = scc_cable_detect; |
| 682 | hwif->cbl = ATA_CBL_PATA80; | ||
| 683 | } | 687 | } |
| 684 | 688 | ||
| 685 | #define DECLARE_SCC_DEV(name_str) \ | 689 | #define DECLARE_SCC_DEV(name_str) \ |
| @@ -732,7 +736,7 @@ static void __devexit scc_remove(struct pci_dev *dev) | |||
| 732 | hwif->dmatable_cpu = NULL; | 736 | hwif->dmatable_cpu = NULL; |
| 733 | } | 737 | } |
| 734 | 738 | ||
| 735 | ide_unregister(hwif->index); | 739 | ide_unregister(hwif->index, 0, 0); |
| 736 | 740 | ||
| 737 | hwif->chipset = ide_unknown; | 741 | hwif->chipset = ide_unknown; |
| 738 | iounmap((void*)ports->dma); | 742 | iounmap((void*)ports->dma); |
diff --git a/drivers/ide/pci/serverworks.c b/drivers/ide/pci/serverworks.c index f495253b7d41..c11880b0709f 100644 --- a/drivers/ide/pci/serverworks.c +++ b/drivers/ide/pci/serverworks.c | |||
| @@ -31,12 +31,10 @@ | |||
| 31 | #include <linux/types.h> | 31 | #include <linux/types.h> |
| 32 | #include <linux/module.h> | 32 | #include <linux/module.h> |
| 33 | #include <linux/kernel.h> | 33 | #include <linux/kernel.h> |
| 34 | #include <linux/ioport.h> | ||
| 35 | #include <linux/pci.h> | 34 | #include <linux/pci.h> |
| 36 | #include <linux/hdreg.h> | 35 | #include <linux/hdreg.h> |
| 37 | #include <linux/ide.h> | 36 | #include <linux/ide.h> |
| 38 | #include <linux/init.h> | 37 | #include <linux/init.h> |
| 39 | #include <linux/delay.h> | ||
| 40 | 38 | ||
| 41 | #include <asm/io.h> | 39 | #include <asm/io.h> |
| 42 | 40 | ||
| @@ -346,13 +344,8 @@ static void __devinit init_hwif_svwks (ide_hwif_t *hwif) | |||
| 346 | hwif->set_dma_mode = &svwks_set_dma_mode; | 344 | hwif->set_dma_mode = &svwks_set_dma_mode; |
| 347 | hwif->udma_filter = &svwks_udma_filter; | 345 | hwif->udma_filter = &svwks_udma_filter; |
| 348 | 346 | ||
| 349 | if (!hwif->dma_base) | 347 | if (dev->device != PCI_DEVICE_ID_SERVERWORKS_OSB4IDE) |
| 350 | return; | 348 | hwif->cable_detect = ata66_svwks; |
| 351 | |||
| 352 | if (dev->device != PCI_DEVICE_ID_SERVERWORKS_OSB4IDE) { | ||
| 353 | if (hwif->cbl != ATA_CBL_PATA40_SHORT) | ||
| 354 | hwif->cbl = ata66_svwks(hwif); | ||
| 355 | } | ||
| 356 | } | 349 | } |
| 357 | 350 | ||
| 358 | #define IDE_HFLAGS_SVWKS \ | 351 | #define IDE_HFLAGS_SVWKS \ |
diff --git a/drivers/ide/pci/sgiioc4.c b/drivers/ide/pci/sgiioc4.c index 85902074b1fc..054626497be4 100644 --- a/drivers/ide/pci/sgiioc4.c +++ b/drivers/ide/pci/sgiioc4.c | |||
| @@ -25,8 +25,6 @@ | |||
| 25 | #include <linux/hdreg.h> | 25 | #include <linux/hdreg.h> |
| 26 | #include <linux/init.h> | 26 | #include <linux/init.h> |
| 27 | #include <linux/kernel.h> | 27 | #include <linux/kernel.h> |
| 28 | #include <linux/timer.h> | ||
| 29 | #include <linux/mm.h> | ||
| 30 | #include <linux/ioport.h> | 28 | #include <linux/ioport.h> |
| 31 | #include <linux/blkdev.h> | 29 | #include <linux/blkdev.h> |
| 32 | #include <linux/scatterlist.h> | 30 | #include <linux/scatterlist.h> |
| @@ -555,7 +553,6 @@ static void __devinit | |||
| 555 | ide_init_sgiioc4(ide_hwif_t * hwif) | 553 | ide_init_sgiioc4(ide_hwif_t * hwif) |
| 556 | { | 554 | { |
| 557 | hwif->mmio = 1; | 555 | hwif->mmio = 1; |
| 558 | hwif->pio_mask = 0x00; | ||
| 559 | hwif->set_pio_mode = NULL; /* Sets timing for PIO mode */ | 556 | hwif->set_pio_mode = NULL; /* Sets timing for PIO mode */ |
| 560 | hwif->set_dma_mode = &sgiioc4_set_dma_mode; | 557 | hwif->set_dma_mode = &sgiioc4_set_dma_mode; |
| 561 | hwif->selectproc = NULL;/* Use the default routine to select drive */ | 558 | hwif->selectproc = NULL;/* Use the default routine to select drive */ |
| @@ -572,8 +569,6 @@ ide_init_sgiioc4(ide_hwif_t * hwif) | |||
| 572 | if (hwif->dma_base == 0) | 569 | if (hwif->dma_base == 0) |
| 573 | return; | 570 | return; |
| 574 | 571 | ||
| 575 | hwif->mwdma_mask = ATA_MWDMA2_ONLY; | ||
| 576 | |||
| 577 | hwif->dma_host_set = &sgiioc4_dma_host_set; | 572 | hwif->dma_host_set = &sgiioc4_dma_host_set; |
| 578 | hwif->dma_setup = &sgiioc4_ide_dma_setup; | 573 | hwif->dma_setup = &sgiioc4_ide_dma_setup; |
| 579 | hwif->dma_start = &sgiioc4_ide_dma_start; | 574 | hwif->dma_start = &sgiioc4_ide_dma_start; |
| @@ -583,6 +578,13 @@ ide_init_sgiioc4(ide_hwif_t * hwif) | |||
| 583 | hwif->dma_timeout = &ide_dma_timeout; | 578 | hwif->dma_timeout = &ide_dma_timeout; |
| 584 | } | 579 | } |
| 585 | 580 | ||
| 581 | static const struct ide_port_info sgiioc4_port_info __devinitdata = { | ||
| 582 | .chipset = ide_pci, | ||
| 583 | .host_flags = IDE_HFLAG_NO_DMA | /* no SFF-style DMA */ | ||
| 584 | IDE_HFLAG_NO_AUTOTUNE, | ||
| 585 | .mwdma_mask = ATA_MWDMA2_ONLY, | ||
| 586 | }; | ||
| 587 | |||
| 586 | static int __devinit | 588 | static int __devinit |
| 587 | sgiioc4_ide_setup_pci_device(struct pci_dev *dev) | 589 | sgiioc4_ide_setup_pci_device(struct pci_dev *dev) |
| 588 | { | 590 | { |
| @@ -593,6 +595,7 @@ sgiioc4_ide_setup_pci_device(struct pci_dev *dev) | |||
| 593 | int h; | 595 | int h; |
| 594 | u8 idx[4] = { 0xff, 0xff, 0xff, 0xff }; | 596 | u8 idx[4] = { 0xff, 0xff, 0xff, 0xff }; |
| 595 | hw_regs_t hw; | 597 | hw_regs_t hw; |
| 598 | struct ide_port_info d = sgiioc4_port_info; | ||
| 596 | 599 | ||
| 597 | /* | 600 | /* |
| 598 | * Find an empty HWIF; if none available, return -ENOMEM. | 601 | * Find an empty HWIF; if none available, return -ENOMEM. |
| @@ -641,7 +644,6 @@ sgiioc4_ide_setup_pci_device(struct pci_dev *dev) | |||
| 641 | ide_init_port_hw(hwif, &hw); | 644 | ide_init_port_hw(hwif, &hw); |
| 642 | 645 | ||
| 643 | hwif->dev = &dev->dev; | 646 | hwif->dev = &dev->dev; |
| 644 | hwif->channel = 0; /* Single Channel chip */ | ||
| 645 | 647 | ||
| 646 | /* The IOC4 uses MMIO rather than Port IO. */ | 648 | /* The IOC4 uses MMIO rather than Port IO. */ |
| 647 | default_hwif_mmiops(hwif); | 649 | default_hwif_mmiops(hwif); |
| @@ -649,15 +651,17 @@ sgiioc4_ide_setup_pci_device(struct pci_dev *dev) | |||
| 649 | /* Initializing chipset IRQ Registers */ | 651 | /* Initializing chipset IRQ Registers */ |
| 650 | writel(0x03, (void __iomem *)(irqport + IOC4_INTR_SET * 4)); | 652 | writel(0x03, (void __iomem *)(irqport + IOC4_INTR_SET * 4)); |
| 651 | 653 | ||
| 652 | if (dma_base == 0 || ide_dma_sgiioc4(hwif, dma_base)) | 654 | if (dma_base == 0 || ide_dma_sgiioc4(hwif, dma_base)) { |
| 653 | printk(KERN_INFO "%s: %s Bus-Master DMA disabled\n", | 655 | printk(KERN_INFO "%s: %s Bus-Master DMA disabled\n", |
| 654 | hwif->name, DRV_NAME); | 656 | hwif->name, DRV_NAME); |
| 657 | d.mwdma_mask = 0; | ||
| 658 | } | ||
| 655 | 659 | ||
| 656 | ide_init_sgiioc4(hwif); | 660 | ide_init_sgiioc4(hwif); |
| 657 | 661 | ||
| 658 | idx[0] = hwif->index; | 662 | idx[0] = hwif->index; |
| 659 | 663 | ||
| 660 | if (ide_device_add(idx)) | 664 | if (ide_device_add(idx, &d)) |
| 661 | return -EIO; | 665 | return -EIO; |
| 662 | 666 | ||
| 663 | return 0; | 667 | return 0; |
diff --git a/drivers/ide/pci/siimage.c b/drivers/ide/pci/siimage.c index 4877bc8cd599..ef5b39fa042b 100644 --- a/drivers/ide/pci/siimage.c +++ b/drivers/ide/pci/siimage.c | |||
| @@ -39,7 +39,6 @@ | |||
| 39 | #include <linux/types.h> | 39 | #include <linux/types.h> |
| 40 | #include <linux/module.h> | 40 | #include <linux/module.h> |
| 41 | #include <linux/pci.h> | 41 | #include <linux/pci.h> |
| 42 | #include <linux/delay.h> | ||
| 43 | #include <linux/hdreg.h> | 42 | #include <linux/hdreg.h> |
| 44 | #include <linux/ide.h> | 43 | #include <linux/ide.h> |
| 45 | #include <linux/init.h> | 44 | #include <linux/init.h> |
| @@ -332,15 +331,18 @@ static int siimage_mmio_ide_dma_test_irq (ide_drive_t *drive) | |||
| 332 | { | 331 | { |
| 333 | ide_hwif_t *hwif = HWIF(drive); | 332 | ide_hwif_t *hwif = HWIF(drive); |
| 334 | unsigned long addr = siimage_selreg(hwif, 0x1); | 333 | unsigned long addr = siimage_selreg(hwif, 0x1); |
| 334 | void __iomem *sata_error_addr | ||
| 335 | = (void __iomem *)hwif->sata_scr[SATA_ERROR_OFFSET]; | ||
| 335 | 336 | ||
| 336 | if (SATA_ERROR_REG) { | 337 | if (sata_error_addr) { |
| 337 | unsigned long base = (unsigned long)hwif->hwif_data; | 338 | unsigned long base = (unsigned long)hwif->hwif_data; |
| 338 | |||
| 339 | u32 ext_stat = readl((void __iomem *)(base + 0x10)); | 339 | u32 ext_stat = readl((void __iomem *)(base + 0x10)); |
| 340 | u8 watchdog = 0; | 340 | u8 watchdog = 0; |
| 341 | |||
| 341 | if (ext_stat & ((hwif->channel) ? 0x40 : 0x10)) { | 342 | if (ext_stat & ((hwif->channel) ? 0x40 : 0x10)) { |
| 342 | u32 sata_error = readl((void __iomem *)SATA_ERROR_REG); | 343 | u32 sata_error = readl(sata_error_addr); |
| 343 | writel(sata_error, (void __iomem *)SATA_ERROR_REG); | 344 | |
| 345 | writel(sata_error, sata_error_addr); | ||
| 344 | watchdog = (sata_error & 0x00680000) ? 1 : 0; | 346 | watchdog = (sata_error & 0x00680000) ? 1 : 0; |
| 345 | printk(KERN_WARNING "%s: sata_error = 0x%08x, " | 347 | printk(KERN_WARNING "%s: sata_error = 0x%08x, " |
| 346 | "watchdog = %d, %s\n", | 348 | "watchdog = %d, %s\n", |
| @@ -419,13 +421,17 @@ static int sil_sata_busproc(ide_drive_t * drive, int state) | |||
| 419 | 421 | ||
| 420 | static int sil_sata_reset_poll(ide_drive_t *drive) | 422 | static int sil_sata_reset_poll(ide_drive_t *drive) |
| 421 | { | 423 | { |
| 422 | if (SATA_STATUS_REG) { | 424 | ide_hwif_t *hwif = drive->hwif; |
| 423 | ide_hwif_t *hwif = HWIF(drive); | 425 | void __iomem *sata_status_addr |
| 426 | = (void __iomem *)hwif->sata_scr[SATA_STATUS_OFFSET]; | ||
| 424 | 427 | ||
| 425 | /* SATA_STATUS_REG is valid only when in MMIO mode */ | 428 | if (sata_status_addr) { |
| 426 | if ((readl((void __iomem *)SATA_STATUS_REG) & 0x03) != 0x03) { | 429 | /* SATA Status is available only when in MMIO mode */ |
| 430 | u32 sata_stat = readl(sata_status_addr); | ||
| 431 | |||
| 432 | if ((sata_stat & 0x03) != 0x03) { | ||
| 427 | printk(KERN_WARNING "%s: reset phy dead, status=0x%08x\n", | 433 | printk(KERN_WARNING "%s: reset phy dead, status=0x%08x\n", |
| 428 | hwif->name, readl((void __iomem *)SATA_STATUS_REG)); | 434 | hwif->name, sata_stat); |
| 429 | HWGROUP(drive)->polling = 0; | 435 | HWGROUP(drive)->polling = 0; |
| 430 | return ide_started; | 436 | return ide_started; |
| 431 | } | 437 | } |
| @@ -827,15 +833,14 @@ static void __devinit init_hwif_siimage(ide_hwif_t *hwif) | |||
| 827 | } else | 833 | } else |
| 828 | hwif->udma_filter = &sil_pata_udma_filter; | 834 | hwif->udma_filter = &sil_pata_udma_filter; |
| 829 | 835 | ||
| 836 | hwif->cable_detect = ata66_siimage; | ||
| 837 | |||
| 830 | if (hwif->dma_base == 0) | 838 | if (hwif->dma_base == 0) |
| 831 | return; | 839 | return; |
| 832 | 840 | ||
| 833 | if (sata) | 841 | if (sata) |
| 834 | hwif->host_flags |= IDE_HFLAG_NO_ATAPI_DMA; | 842 | hwif->host_flags |= IDE_HFLAG_NO_ATAPI_DMA; |
| 835 | 843 | ||
| 836 | if (hwif->cbl != ATA_CBL_PATA40_SHORT) | ||
| 837 | hwif->cbl = ata66_siimage(hwif); | ||
| 838 | |||
| 839 | if (hwif->mmio) { | 844 | if (hwif->mmio) { |
| 840 | hwif->ide_dma_test_irq = &siimage_mmio_ide_dma_test_irq; | 845 | hwif->ide_dma_test_irq = &siimage_mmio_ide_dma_test_irq; |
| 841 | } else { | 846 | } else { |
diff --git a/drivers/ide/pci/sis5513.c b/drivers/ide/pci/sis5513.c index 2a461de22aa0..512bb4c1fd5c 100644 --- a/drivers/ide/pci/sis5513.c +++ b/drivers/ide/pci/sis5513.c | |||
| @@ -47,20 +47,11 @@ | |||
| 47 | #include <linux/types.h> | 47 | #include <linux/types.h> |
| 48 | #include <linux/module.h> | 48 | #include <linux/module.h> |
| 49 | #include <linux/kernel.h> | 49 | #include <linux/kernel.h> |
| 50 | #include <linux/delay.h> | ||
| 51 | #include <linux/timer.h> | ||
| 52 | #include <linux/mm.h> | ||
| 53 | #include <linux/ioport.h> | ||
| 54 | #include <linux/blkdev.h> | ||
| 55 | #include <linux/hdreg.h> | 50 | #include <linux/hdreg.h> |
| 56 | |||
| 57 | #include <linux/interrupt.h> | ||
| 58 | #include <linux/pci.h> | 51 | #include <linux/pci.h> |
| 59 | #include <linux/init.h> | 52 | #include <linux/init.h> |
| 60 | #include <linux/ide.h> | 53 | #include <linux/ide.h> |
| 61 | 54 | ||
| 62 | #include <asm/irq.h> | ||
| 63 | |||
| 64 | #include "ide-timing.h" | 55 | #include "ide-timing.h" |
| 65 | 56 | ||
| 66 | /* registers layout and init values are chipset family dependant */ | 57 | /* registers layout and init values are chipset family dependant */ |
| @@ -565,13 +556,12 @@ static void __devinit init_hwif_sis5513 (ide_hwif_t *hwif) | |||
| 565 | if (chipset_family >= ATA_133) | 556 | if (chipset_family >= ATA_133) |
| 566 | hwif->udma_filter = sis5513_ata133_udma_filter; | 557 | hwif->udma_filter = sis5513_ata133_udma_filter; |
| 567 | 558 | ||
| 559 | hwif->cable_detect = ata66_sis5513; | ||
| 560 | |||
| 568 | if (hwif->dma_base == 0) | 561 | if (hwif->dma_base == 0) |
| 569 | return; | 562 | return; |
| 570 | 563 | ||
| 571 | hwif->ultra_mask = udma_rates[chipset_family]; | 564 | hwif->ultra_mask = udma_rates[chipset_family]; |
| 572 | |||
| 573 | if (hwif->cbl != ATA_CBL_PATA40_SHORT) | ||
| 574 | hwif->cbl = ata66_sis5513(hwif); | ||
| 575 | } | 565 | } |
| 576 | 566 | ||
| 577 | static const struct ide_port_info sis5513_chipset __devinitdata = { | 567 | static const struct ide_port_info sis5513_chipset __devinitdata = { |
diff --git a/drivers/ide/pci/sl82c105.c b/drivers/ide/pci/sl82c105.c index da13a1298ada..ee261ae15b6f 100644 --- a/drivers/ide/pci/sl82c105.c +++ b/drivers/ide/pci/sl82c105.c | |||
| @@ -17,17 +17,11 @@ | |||
| 17 | #include <linux/types.h> | 17 | #include <linux/types.h> |
| 18 | #include <linux/module.h> | 18 | #include <linux/module.h> |
| 19 | #include <linux/kernel.h> | 19 | #include <linux/kernel.h> |
| 20 | #include <linux/timer.h> | ||
| 21 | #include <linux/mm.h> | ||
| 22 | #include <linux/ioport.h> | ||
| 23 | #include <linux/interrupt.h> | ||
| 24 | #include <linux/blkdev.h> | ||
| 25 | #include <linux/hdreg.h> | 20 | #include <linux/hdreg.h> |
| 26 | #include <linux/pci.h> | 21 | #include <linux/pci.h> |
| 27 | #include <linux/ide.h> | 22 | #include <linux/ide.h> |
| 28 | 23 | ||
| 29 | #include <asm/io.h> | 24 | #include <asm/io.h> |
| 30 | #include <asm/dma.h> | ||
| 31 | 25 | ||
| 32 | #undef DEBUG | 26 | #undef DEBUG |
| 33 | 27 | ||
diff --git a/drivers/ide/pci/slc90e66.c b/drivers/ide/pci/slc90e66.c index a6cf810c4699..65f4c2ffaa59 100644 --- a/drivers/ide/pci/slc90e66.c +++ b/drivers/ide/pci/slc90e66.c | |||
| @@ -10,15 +10,11 @@ | |||
| 10 | #include <linux/types.h> | 10 | #include <linux/types.h> |
| 11 | #include <linux/module.h> | 11 | #include <linux/module.h> |
| 12 | #include <linux/kernel.h> | 12 | #include <linux/kernel.h> |
| 13 | #include <linux/ioport.h> | ||
| 14 | #include <linux/pci.h> | 13 | #include <linux/pci.h> |
| 15 | #include <linux/hdreg.h> | 14 | #include <linux/hdreg.h> |
| 16 | #include <linux/ide.h> | 15 | #include <linux/ide.h> |
| 17 | #include <linux/delay.h> | ||
| 18 | #include <linux/init.h> | 16 | #include <linux/init.h> |
| 19 | 17 | ||
| 20 | #include <asm/io.h> | ||
| 21 | |||
| 22 | static DEFINE_SPINLOCK(slc90e66_lock); | 18 | static DEFINE_SPINLOCK(slc90e66_lock); |
| 23 | 19 | ||
| 24 | static void slc90e66_set_pio_mode(ide_drive_t *drive, const u8 pio) | 20 | static void slc90e66_set_pio_mode(ide_drive_t *drive, const u8 pio) |
| @@ -118,23 +114,23 @@ static void slc90e66_set_dma_mode(ide_drive_t *drive, const u8 speed) | |||
| 118 | } | 114 | } |
| 119 | } | 115 | } |
| 120 | 116 | ||
| 121 | static void __devinit init_hwif_slc90e66 (ide_hwif_t *hwif) | 117 | static u8 __devinit slc90e66_cable_detect(ide_hwif_t *hwif) |
| 122 | { | 118 | { |
| 123 | struct pci_dev *dev = to_pci_dev(hwif->dev); | 119 | struct pci_dev *dev = to_pci_dev(hwif->dev); |
| 124 | u8 reg47 = 0; | 120 | u8 reg47 = 0, mask = hwif->channel ? 0x01 : 0x02; |
| 125 | u8 mask = hwif->channel ? 0x01 : 0x02; /* bit0:Primary */ | ||
| 126 | |||
| 127 | hwif->set_pio_mode = &slc90e66_set_pio_mode; | ||
| 128 | hwif->set_dma_mode = &slc90e66_set_dma_mode; | ||
| 129 | 121 | ||
| 130 | pci_read_config_byte(dev, 0x47, ®47); | 122 | pci_read_config_byte(dev, 0x47, ®47); |
| 131 | 123 | ||
| 132 | if (hwif->dma_base == 0) | 124 | /* bit[0(1)]: 0:80, 1:40 */ |
| 133 | return; | 125 | return (reg47 & mask) ? ATA_CBL_PATA40 : ATA_CBL_PATA80; |
| 126 | } | ||
| 127 | |||
| 128 | static void __devinit init_hwif_slc90e66(ide_hwif_t *hwif) | ||
| 129 | { | ||
| 130 | hwif->set_pio_mode = &slc90e66_set_pio_mode; | ||
| 131 | hwif->set_dma_mode = &slc90e66_set_dma_mode; | ||
| 134 | 132 | ||
| 135 | if (hwif->cbl != ATA_CBL_PATA40_SHORT) | 133 | hwif->cable_detect = slc90e66_cable_detect; |
| 136 | /* bit[0(1)]: 0:80, 1:40 */ | ||
| 137 | hwif->cbl = (reg47 & mask) ? ATA_CBL_PATA40 : ATA_CBL_PATA80; | ||
| 138 | } | 134 | } |
| 139 | 135 | ||
| 140 | static const struct ide_port_info slc90e66_chipset __devinitdata = { | 136 | static const struct ide_port_info slc90e66_chipset __devinitdata = { |
diff --git a/drivers/ide/pci/tc86c001.c b/drivers/ide/pci/tc86c001.c index 9fbbb4f2dd54..2ef2ed2f2b32 100644 --- a/drivers/ide/pci/tc86c001.c +++ b/drivers/ide/pci/tc86c001.c | |||
| @@ -160,6 +160,19 @@ static int tc86c001_busproc(ide_drive_t *drive, int state) | |||
| 160 | return 0; | 160 | return 0; |
| 161 | } | 161 | } |
| 162 | 162 | ||
| 163 | static u8 __devinit tc86c001_cable_detect(ide_hwif_t *hwif) | ||
| 164 | { | ||
| 165 | struct pci_dev *dev = to_pci_dev(hwif->dev); | ||
| 166 | unsigned long sc_base = pci_resource_start(dev, 5); | ||
| 167 | u16 scr1 = inw(sc_base + 0x00); | ||
| 168 | |||
| 169 | /* | ||
| 170 | * System Control 1 Register bit 13 (PDIAGN): | ||
| 171 | * 0=80-pin cable, 1=40-pin cable | ||
| 172 | */ | ||
| 173 | return (scr1 & 0x2000) ? ATA_CBL_PATA40 : ATA_CBL_PATA80; | ||
| 174 | } | ||
| 175 | |||
| 163 | static void __devinit init_hwif_tc86c001(ide_hwif_t *hwif) | 176 | static void __devinit init_hwif_tc86c001(ide_hwif_t *hwif) |
| 164 | { | 177 | { |
| 165 | struct pci_dev *dev = to_pci_dev(hwif->dev); | 178 | struct pci_dev *dev = to_pci_dev(hwif->dev); |
| @@ -183,6 +196,8 @@ static void __devinit init_hwif_tc86c001(ide_hwif_t *hwif) | |||
| 183 | 196 | ||
| 184 | hwif->busproc = &tc86c001_busproc; | 197 | hwif->busproc = &tc86c001_busproc; |
| 185 | 198 | ||
| 199 | hwif->cable_detect = tc86c001_cable_detect; | ||
| 200 | |||
| 186 | if (!hwif->dma_base) | 201 | if (!hwif->dma_base) |
| 187 | return; | 202 | return; |
| 188 | 203 | ||
| @@ -196,15 +211,6 @@ static void __devinit init_hwif_tc86c001(ide_hwif_t *hwif) | |||
| 196 | hwif->rqsize = 0xffff; | 211 | hwif->rqsize = 0xffff; |
| 197 | 212 | ||
| 198 | hwif->dma_start = &tc86c001_dma_start; | 213 | hwif->dma_start = &tc86c001_dma_start; |
| 199 | |||
| 200 | if (hwif->cbl != ATA_CBL_PATA40_SHORT) { | ||
| 201 | /* | ||
| 202 | * System Control 1 Register bit 13 (PDIAGN): | ||
| 203 | * 0=80-pin cable, 1=40-pin cable | ||
| 204 | */ | ||
| 205 | scr1 = inw(sc_base + 0x00); | ||
| 206 | hwif->cbl = (scr1 & 0x2000) ? ATA_CBL_PATA40 : ATA_CBL_PATA80; | ||
| 207 | } | ||
| 208 | } | 214 | } |
| 209 | 215 | ||
| 210 | static unsigned int __devinit init_chipset_tc86c001(struct pci_dev *dev, | 216 | static unsigned int __devinit init_chipset_tc86c001(struct pci_dev *dev, |
diff --git a/drivers/ide/pci/triflex.c b/drivers/ide/pci/triflex.c index 852b72693736..a67d02a3f96e 100644 --- a/drivers/ide/pci/triflex.c +++ b/drivers/ide/pci/triflex.c | |||
| @@ -28,11 +28,6 @@ | |||
| 28 | #include <linux/types.h> | 28 | #include <linux/types.h> |
| 29 | #include <linux/module.h> | 29 | #include <linux/module.h> |
| 30 | #include <linux/kernel.h> | 30 | #include <linux/kernel.h> |
| 31 | #include <linux/delay.h> | ||
| 32 | #include <linux/timer.h> | ||
| 33 | #include <linux/mm.h> | ||
| 34 | #include <linux/ioport.h> | ||
| 35 | #include <linux/blkdev.h> | ||
| 36 | #include <linux/hdreg.h> | 31 | #include <linux/hdreg.h> |
| 37 | #include <linux/pci.h> | 32 | #include <linux/pci.h> |
| 38 | #include <linux/ide.h> | 33 | #include <linux/ide.h> |
diff --git a/drivers/ide/pci/trm290.c b/drivers/ide/pci/trm290.c index d9ebb698953a..de750f7a43e9 100644 --- a/drivers/ide/pci/trm290.c +++ b/drivers/ide/pci/trm290.c | |||
| @@ -131,14 +131,12 @@ | |||
| 131 | #include <linux/types.h> | 131 | #include <linux/types.h> |
| 132 | #include <linux/module.h> | 132 | #include <linux/module.h> |
| 133 | #include <linux/kernel.h> | 133 | #include <linux/kernel.h> |
| 134 | #include <linux/mm.h> | ||
| 135 | #include <linux/ioport.h> | 134 | #include <linux/ioport.h> |
| 136 | #include <linux/interrupt.h> | 135 | #include <linux/interrupt.h> |
| 137 | #include <linux/blkdev.h> | 136 | #include <linux/blkdev.h> |
| 138 | #include <linux/init.h> | 137 | #include <linux/init.h> |
| 139 | #include <linux/hdreg.h> | 138 | #include <linux/hdreg.h> |
| 140 | #include <linux/pci.h> | 139 | #include <linux/pci.h> |
| 141 | #include <linux/delay.h> | ||
| 142 | #include <linux/ide.h> | 140 | #include <linux/ide.h> |
| 143 | 141 | ||
| 144 | #include <asm/io.h> | 142 | #include <asm/io.h> |
| @@ -179,10 +177,7 @@ static void trm290_selectproc (ide_drive_t *drive) | |||
| 179 | 177 | ||
| 180 | static void trm290_dma_exec_cmd(ide_drive_t *drive, u8 command) | 178 | static void trm290_dma_exec_cmd(ide_drive_t *drive, u8 command) |
| 181 | { | 179 | { |
| 182 | BUG_ON(HWGROUP(drive)->handler != NULL); /* paranoia check */ | 180 | ide_execute_command(drive, command, &ide_dma_intr, WAIT_CMD, NULL); |
| 183 | ide_set_handler(drive, &ide_dma_intr, WAIT_CMD, NULL); | ||
| 184 | /* issue cmd to drive */ | ||
| 185 | outb(command, IDE_COMMAND_REG); | ||
| 186 | } | 181 | } |
| 187 | 182 | ||
| 188 | static int trm290_dma_setup(ide_drive_t *drive) | 183 | static int trm290_dma_setup(ide_drive_t *drive) |
diff --git a/drivers/ide/pci/via82cxxx.c b/drivers/ide/pci/via82cxxx.c index 24cb9047fb41..f3f79f805813 100644 --- a/drivers/ide/pci/via82cxxx.c +++ b/drivers/ide/pci/via82cxxx.c | |||
| @@ -26,15 +26,11 @@ | |||
| 26 | 26 | ||
| 27 | #include <linux/module.h> | 27 | #include <linux/module.h> |
| 28 | #include <linux/kernel.h> | 28 | #include <linux/kernel.h> |
| 29 | #include <linux/ioport.h> | ||
| 30 | #include <linux/blkdev.h> | ||
| 31 | #include <linux/pci.h> | 29 | #include <linux/pci.h> |
| 32 | #include <linux/init.h> | 30 | #include <linux/init.h> |
| 33 | #include <linux/ide.h> | 31 | #include <linux/ide.h> |
| 34 | #include <linux/dmi.h> | 32 | #include <linux/dmi.h> |
| 35 | 33 | ||
| 36 | #include <asm/io.h> | ||
| 37 | |||
| 38 | #ifdef CONFIG_PPC_CHRP | 34 | #ifdef CONFIG_PPC_CHRP |
| 39 | #include <asm/processor.h> | 35 | #include <asm/processor.h> |
| 40 | #endif | 36 | #endif |
| @@ -424,11 +420,7 @@ static void __devinit init_hwif_via82cxxx(ide_hwif_t *hwif) | |||
| 424 | hwif->set_pio_mode = &via_set_pio_mode; | 420 | hwif->set_pio_mode = &via_set_pio_mode; |
| 425 | hwif->set_dma_mode = &via_set_drive; | 421 | hwif->set_dma_mode = &via_set_drive; |
| 426 | 422 | ||
| 427 | if (!hwif->dma_base) | 423 | hwif->cable_detect = via82cxxx_cable_detect; |
| 428 | return; | ||
| 429 | |||
| 430 | if (hwif->cbl != ATA_CBL_PATA40_SHORT) | ||
| 431 | hwif->cbl = via82cxxx_cable_detect(hwif); | ||
| 432 | } | 424 | } |
| 433 | 425 | ||
| 434 | static const struct ide_port_info via82cxxx_chipset __devinitdata = { | 426 | static const struct ide_port_info via82cxxx_chipset __devinitdata = { |
diff --git a/drivers/ide/ppc/mpc8xx.c b/drivers/ide/ppc/mpc8xx.c index 45c1d55e60df..06190b1c4ec5 100644 --- a/drivers/ide/ppc/mpc8xx.c +++ b/drivers/ide/ppc/mpc8xx.c | |||
| @@ -848,7 +848,7 @@ static int __init mpc8xx_ide_probe(void) | |||
| 848 | #endif | 848 | #endif |
| 849 | #endif | 849 | #endif |
| 850 | 850 | ||
| 851 | ide_device_add(idx); | 851 | ide_device_add(idx, NULL); |
| 852 | 852 | ||
| 853 | return 0; | 853 | return 0; |
| 854 | } | 854 | } |
diff --git a/drivers/ide/ppc/pmac.c b/drivers/ide/ppc/pmac.c index 23112ef68f67..12ac3bfb4f9a 100644 --- a/drivers/ide/ppc/pmac.c +++ b/drivers/ide/ppc/pmac.c | |||
| @@ -412,7 +412,7 @@ kauai_lookup_timing(struct kauai_timing* table, int cycle_time) | |||
| 412 | */ | 412 | */ |
| 413 | #define IDE_WAKEUP_DELAY (1*HZ) | 413 | #define IDE_WAKEUP_DELAY (1*HZ) |
| 414 | 414 | ||
| 415 | static void pmac_ide_setup_dma(pmac_ide_hwif_t *pmif, ide_hwif_t *hwif); | 415 | static int pmac_ide_setup_dma(pmac_ide_hwif_t *pmif, ide_hwif_t *hwif); |
| 416 | static int pmac_ide_build_dmatable(ide_drive_t *drive, struct request *rq); | 416 | static int pmac_ide_build_dmatable(ide_drive_t *drive, struct request *rq); |
| 417 | static void pmac_ide_selectproc(ide_drive_t *drive); | 417 | static void pmac_ide_selectproc(ide_drive_t *drive); |
| 418 | static void pmac_ide_kauai_selectproc(ide_drive_t *drive); | 418 | static void pmac_ide_kauai_selectproc(ide_drive_t *drive); |
| @@ -1003,6 +1003,17 @@ pmac_ide_do_resume(ide_hwif_t *hwif) | |||
| 1003 | return 0; | 1003 | return 0; |
| 1004 | } | 1004 | } |
| 1005 | 1005 | ||
| 1006 | static const struct ide_port_info pmac_port_info = { | ||
| 1007 | .chipset = ide_pmac, | ||
| 1008 | .host_flags = IDE_HFLAG_SET_PIO_MODE_KEEP_DMA | | ||
| 1009 | IDE_HFLAG_PIO_NO_DOWNGRADE | | ||
| 1010 | IDE_HFLAG_POST_SET_MODE | | ||
| 1011 | IDE_HFLAG_NO_DMA | /* no SFF-style DMA */ | ||
| 1012 | IDE_HFLAG_UNMASK_IRQS, | ||
| 1013 | .pio_mask = ATA_PIO4, | ||
| 1014 | .mwdma_mask = ATA_MWDMA2, | ||
| 1015 | }; | ||
| 1016 | |||
| 1006 | /* | 1017 | /* |
| 1007 | * Setup, register & probe an IDE channel driven by this driver, this is | 1018 | * Setup, register & probe an IDE channel driven by this driver, this is |
| 1008 | * called by one of the 2 probe functions (macio or PCI). Note that a channel | 1019 | * called by one of the 2 probe functions (macio or PCI). Note that a channel |
| @@ -1016,23 +1027,28 @@ pmac_ide_setup_device(pmac_ide_hwif_t *pmif, ide_hwif_t *hwif, hw_regs_t *hw) | |||
| 1016 | struct device_node *np = pmif->node; | 1027 | struct device_node *np = pmif->node; |
| 1017 | const int *bidp; | 1028 | const int *bidp; |
| 1018 | u8 idx[4] = { 0xff, 0xff, 0xff, 0xff }; | 1029 | u8 idx[4] = { 0xff, 0xff, 0xff, 0xff }; |
| 1030 | struct ide_port_info d = pmac_port_info; | ||
| 1019 | 1031 | ||
| 1020 | pmif->cable_80 = 0; | 1032 | pmif->cable_80 = 0; |
| 1021 | pmif->broken_dma = pmif->broken_dma_warn = 0; | 1033 | pmif->broken_dma = pmif->broken_dma_warn = 0; |
| 1022 | if (of_device_is_compatible(np, "shasta-ata")) | 1034 | if (of_device_is_compatible(np, "shasta-ata")) { |
| 1023 | pmif->kind = controller_sh_ata6; | 1035 | pmif->kind = controller_sh_ata6; |
| 1024 | else if (of_device_is_compatible(np, "kauai-ata")) | 1036 | d.udma_mask = ATA_UDMA6; |
| 1037 | } else if (of_device_is_compatible(np, "kauai-ata")) { | ||
| 1025 | pmif->kind = controller_un_ata6; | 1038 | pmif->kind = controller_un_ata6; |
| 1026 | else if (of_device_is_compatible(np, "K2-UATA")) | 1039 | d.udma_mask = ATA_UDMA5; |
| 1040 | } else if (of_device_is_compatible(np, "K2-UATA")) { | ||
| 1027 | pmif->kind = controller_k2_ata6; | 1041 | pmif->kind = controller_k2_ata6; |
| 1028 | else if (of_device_is_compatible(np, "keylargo-ata")) { | 1042 | d.udma_mask = ATA_UDMA5; |
| 1029 | if (strcmp(np->name, "ata-4") == 0) | 1043 | } else if (of_device_is_compatible(np, "keylargo-ata")) { |
| 1044 | if (strcmp(np->name, "ata-4") == 0) { | ||
| 1030 | pmif->kind = controller_kl_ata4; | 1045 | pmif->kind = controller_kl_ata4; |
| 1031 | else | 1046 | d.udma_mask = ATA_UDMA4; |
| 1047 | } else | ||
| 1032 | pmif->kind = controller_kl_ata3; | 1048 | pmif->kind = controller_kl_ata3; |
| 1033 | } else if (of_device_is_compatible(np, "heathrow-ata")) | 1049 | } else if (of_device_is_compatible(np, "heathrow-ata")) { |
| 1034 | pmif->kind = controller_heathrow; | 1050 | pmif->kind = controller_heathrow; |
| 1035 | else { | 1051 | } else { |
| 1036 | pmif->kind = controller_ohare; | 1052 | pmif->kind = controller_ohare; |
| 1037 | pmif->broken_dma = 1; | 1053 | pmif->broken_dma = 1; |
| 1038 | } | 1054 | } |
| @@ -1101,19 +1117,10 @@ pmac_ide_setup_device(pmac_ide_hwif_t *pmif, ide_hwif_t *hwif, hw_regs_t *hw) | |||
| 1101 | /* Tell common code _not_ to mess with resources */ | 1117 | /* Tell common code _not_ to mess with resources */ |
| 1102 | hwif->mmio = 1; | 1118 | hwif->mmio = 1; |
| 1103 | hwif->hwif_data = pmif; | 1119 | hwif->hwif_data = pmif; |
| 1104 | hw->chipset = ide_pmac; | ||
| 1105 | ide_init_port_hw(hwif, hw); | 1120 | ide_init_port_hw(hwif, hw); |
| 1106 | hwif->noprobe = pmif->mediabay; | 1121 | hwif->noprobe = pmif->mediabay; |
| 1107 | hwif->hold = pmif->mediabay; | 1122 | hwif->hold = pmif->mediabay; |
| 1108 | hwif->cbl = pmif->cable_80 ? ATA_CBL_PATA80 : ATA_CBL_PATA40; | 1123 | hwif->cbl = pmif->cable_80 ? ATA_CBL_PATA80 : ATA_CBL_PATA40; |
| 1109 | hwif->drives[0].unmask = 1; | ||
| 1110 | hwif->drives[1].unmask = 1; | ||
| 1111 | hwif->drives[0].autotune = IDE_TUNE_AUTO; | ||
| 1112 | hwif->drives[1].autotune = IDE_TUNE_AUTO; | ||
| 1113 | hwif->host_flags = IDE_HFLAG_SET_PIO_MODE_KEEP_DMA | | ||
| 1114 | IDE_HFLAG_PIO_NO_DOWNGRADE | | ||
| 1115 | IDE_HFLAG_POST_SET_MODE; | ||
| 1116 | hwif->pio_mask = ATA_PIO4; | ||
| 1117 | hwif->set_pio_mode = pmac_ide_set_pio_mode; | 1124 | hwif->set_pio_mode = pmac_ide_set_pio_mode; |
| 1118 | if (pmif->kind == controller_un_ata6 | 1125 | if (pmif->kind == controller_un_ata6 |
| 1119 | || pmif->kind == controller_k2_ata6 | 1126 | || pmif->kind == controller_k2_ata6 |
| @@ -1133,14 +1140,16 @@ pmac_ide_setup_device(pmac_ide_hwif_t *pmif, ide_hwif_t *hwif, hw_regs_t *hw) | |||
| 1133 | #endif /* CONFIG_PMAC_MEDIABAY */ | 1140 | #endif /* CONFIG_PMAC_MEDIABAY */ |
| 1134 | 1141 | ||
| 1135 | #ifdef CONFIG_BLK_DEV_IDEDMA_PMAC | 1142 | #ifdef CONFIG_BLK_DEV_IDEDMA_PMAC |
| 1143 | if (pmif->cable_80 == 0) | ||
| 1144 | d.udma_mask &= ATA_UDMA2; | ||
| 1136 | /* has a DBDMA controller channel */ | 1145 | /* has a DBDMA controller channel */ |
| 1137 | if (pmif->dma_regs) | 1146 | if (pmif->dma_regs == 0 || pmac_ide_setup_dma(pmif, hwif) < 0) |
| 1138 | pmac_ide_setup_dma(pmif, hwif); | 1147 | #endif |
| 1139 | #endif /* CONFIG_BLK_DEV_IDEDMA_PMAC */ | 1148 | d.udma_mask = d.mwdma_mask = 0; |
| 1140 | 1149 | ||
| 1141 | idx[0] = hwif->index; | 1150 | idx[0] = hwif->index; |
| 1142 | 1151 | ||
| 1143 | ide_device_add(idx); | 1152 | ide_device_add(idx, &d); |
| 1144 | 1153 | ||
| 1145 | return 0; | 1154 | return 0; |
| 1146 | } | 1155 | } |
| @@ -1721,8 +1730,7 @@ pmac_ide_dma_lost_irq (ide_drive_t *drive) | |||
| 1721 | * Allocate the data structures needed for using DMA with an interface | 1730 | * Allocate the data structures needed for using DMA with an interface |
| 1722 | * and fill the proper list of functions pointers | 1731 | * and fill the proper list of functions pointers |
| 1723 | */ | 1732 | */ |
| 1724 | static void __devinit | 1733 | static int __devinit pmac_ide_setup_dma(pmac_ide_hwif_t *pmif, ide_hwif_t *hwif) |
| 1725 | pmac_ide_setup_dma(pmac_ide_hwif_t *pmif, ide_hwif_t *hwif) | ||
| 1726 | { | 1734 | { |
| 1727 | struct pci_dev *dev = to_pci_dev(hwif->dev); | 1735 | struct pci_dev *dev = to_pci_dev(hwif->dev); |
| 1728 | 1736 | ||
| @@ -1730,7 +1738,7 @@ pmac_ide_setup_dma(pmac_ide_hwif_t *pmif, ide_hwif_t *hwif) | |||
| 1730 | * DMA routines ... | 1738 | * DMA routines ... |
| 1731 | */ | 1739 | */ |
| 1732 | if (dev == NULL) | 1740 | if (dev == NULL) |
| 1733 | return; | 1741 | return -ENODEV; |
| 1734 | /* | 1742 | /* |
| 1735 | * Allocate space for the DBDMA commands. | 1743 | * Allocate space for the DBDMA commands. |
| 1736 | * The +2 is +1 for the stop command and +1 to allow for | 1744 | * The +2 is +1 for the stop command and +1 to allow for |
| @@ -1743,7 +1751,7 @@ pmac_ide_setup_dma(pmac_ide_hwif_t *pmif, ide_hwif_t *hwif) | |||
| 1743 | if (pmif->dma_table_cpu == NULL) { | 1751 | if (pmif->dma_table_cpu == NULL) { |
| 1744 | printk(KERN_ERR "%s: unable to allocate DMA command list\n", | 1752 | printk(KERN_ERR "%s: unable to allocate DMA command list\n", |
| 1745 | hwif->name); | 1753 | hwif->name); |
| 1746 | return; | 1754 | return -ENOMEM; |
| 1747 | } | 1755 | } |
| 1748 | 1756 | ||
| 1749 | hwif->sg_max_nents = MAX_DCMDS; | 1757 | hwif->sg_max_nents = MAX_DCMDS; |
| @@ -1757,29 +1765,7 @@ pmac_ide_setup_dma(pmac_ide_hwif_t *pmif, ide_hwif_t *hwif) | |||
| 1757 | hwif->dma_timeout = &ide_dma_timeout; | 1765 | hwif->dma_timeout = &ide_dma_timeout; |
| 1758 | hwif->dma_lost_irq = &pmac_ide_dma_lost_irq; | 1766 | hwif->dma_lost_irq = &pmac_ide_dma_lost_irq; |
| 1759 | 1767 | ||
| 1760 | switch(pmif->kind) { | 1768 | return 0; |
| 1761 | case controller_sh_ata6: | ||
| 1762 | hwif->ultra_mask = pmif->cable_80 ? 0x7f : 0x07; | ||
| 1763 | hwif->mwdma_mask = 0x07; | ||
| 1764 | hwif->swdma_mask = 0x00; | ||
| 1765 | break; | ||
| 1766 | case controller_un_ata6: | ||
| 1767 | case controller_k2_ata6: | ||
| 1768 | hwif->ultra_mask = pmif->cable_80 ? 0x3f : 0x07; | ||
| 1769 | hwif->mwdma_mask = 0x07; | ||
| 1770 | hwif->swdma_mask = 0x00; | ||
| 1771 | break; | ||
| 1772 | case controller_kl_ata4: | ||
| 1773 | hwif->ultra_mask = pmif->cable_80 ? 0x1f : 0x07; | ||
| 1774 | hwif->mwdma_mask = 0x07; | ||
| 1775 | hwif->swdma_mask = 0x00; | ||
| 1776 | break; | ||
| 1777 | default: | ||
| 1778 | hwif->ultra_mask = 0x00; | ||
| 1779 | hwif->mwdma_mask = 0x07; | ||
| 1780 | hwif->swdma_mask = 0x00; | ||
| 1781 | break; | ||
| 1782 | } | ||
| 1783 | } | 1769 | } |
| 1784 | 1770 | ||
| 1785 | #endif /* CONFIG_BLK_DEV_IDEDMA_PMAC */ | 1771 | #endif /* CONFIG_BLK_DEV_IDEDMA_PMAC */ |
diff --git a/drivers/ide/setup-pci.c b/drivers/ide/setup-pci.c index 05db429a7da8..634e3f6a9608 100644 --- a/drivers/ide/setup-pci.c +++ b/drivers/ide/setup-pci.c | |||
| @@ -339,7 +339,8 @@ static int ide_pci_check_iomem(struct pci_dev *dev, const struct ide_port_info * | |||
| 339 | * ide_hwif_configure - configure an IDE interface | 339 | * ide_hwif_configure - configure an IDE interface |
| 340 | * @dev: PCI device holding interface | 340 | * @dev: PCI device holding interface |
| 341 | * @d: IDE port info | 341 | * @d: IDE port info |
| 342 | * @mate: Paired interface if any | 342 | * @port: port number |
| 343 | * @irq: PCI IRQ | ||
| 343 | * | 344 | * |
| 344 | * Perform the initial set up for the hardware interface structure. This | 345 | * Perform the initial set up for the hardware interface structure. This |
| 345 | * is done per interface port rather than per PCI device. There may be | 346 | * is done per interface port rather than per PCI device. There may be |
| @@ -348,7 +349,9 @@ static int ide_pci_check_iomem(struct pci_dev *dev, const struct ide_port_info * | |||
| 348 | * Returns the new hardware interface structure, or NULL on a failure | 349 | * Returns the new hardware interface structure, or NULL on a failure |
| 349 | */ | 350 | */ |
| 350 | 351 | ||
| 351 | static ide_hwif_t *ide_hwif_configure(struct pci_dev *dev, const struct ide_port_info *d, ide_hwif_t *mate, int port, int irq) | 352 | static ide_hwif_t *ide_hwif_configure(struct pci_dev *dev, |
| 353 | const struct ide_port_info *d, | ||
| 354 | unsigned int port, int irq) | ||
| 352 | { | 355 | { |
| 353 | unsigned long ctl = 0, base = 0; | 356 | unsigned long ctl = 0, base = 0; |
| 354 | ide_hwif_t *hwif; | 357 | ide_hwif_t *hwif; |
| @@ -394,29 +397,24 @@ static ide_hwif_t *ide_hwif_configure(struct pci_dev *dev, const struct ide_port | |||
| 394 | 397 | ||
| 395 | hwif->dev = &dev->dev; | 398 | hwif->dev = &dev->dev; |
| 396 | hwif->cds = d; | 399 | hwif->cds = d; |
| 397 | hwif->channel = port; | ||
| 398 | 400 | ||
| 399 | if (mate) { | ||
| 400 | hwif->mate = mate; | ||
| 401 | mate->mate = hwif; | ||
| 402 | } | ||
| 403 | return hwif; | 401 | return hwif; |
| 404 | } | 402 | } |
| 405 | 403 | ||
| 404 | #ifdef CONFIG_BLK_DEV_IDEDMA_PCI | ||
| 406 | /** | 405 | /** |
| 407 | * ide_hwif_setup_dma - configure DMA interface | 406 | * ide_hwif_setup_dma - configure DMA interface |
| 408 | * @dev: PCI device | ||
| 409 | * @d: IDE port info | ||
| 410 | * @hwif: IDE interface | 407 | * @hwif: IDE interface |
| 408 | * @d: IDE port info | ||
| 411 | * | 409 | * |
| 412 | * Set up the DMA base for the interface. Enable the master bits as | 410 | * Set up the DMA base for the interface. Enable the master bits as |
| 413 | * necessary and attempt to bring the device DMA into a ready to use | 411 | * necessary and attempt to bring the device DMA into a ready to use |
| 414 | * state | 412 | * state |
| 415 | */ | 413 | */ |
| 416 | 414 | ||
| 417 | static void ide_hwif_setup_dma(struct pci_dev *dev, const struct ide_port_info *d, ide_hwif_t *hwif) | 415 | void ide_hwif_setup_dma(ide_hwif_t *hwif, const struct ide_port_info *d) |
| 418 | { | 416 | { |
| 419 | #ifdef CONFIG_BLK_DEV_IDEDMA_PCI | 417 | struct pci_dev *dev = to_pci_dev(hwif->dev); |
| 420 | u16 pcicmd; | 418 | u16 pcicmd; |
| 421 | 419 | ||
| 422 | pci_read_config_word(dev, PCI_COMMAND, &pcicmd); | 420 | pci_read_config_word(dev, PCI_COMMAND, &pcicmd); |
| @@ -448,8 +446,8 @@ static void ide_hwif_setup_dma(struct pci_dev *dev, const struct ide_port_info * | |||
| 448 | "(BIOS)\n", hwif->name, d->name); | 446 | "(BIOS)\n", hwif->name, d->name); |
| 449 | } | 447 | } |
| 450 | } | 448 | } |
| 451 | #endif /* CONFIG_BLK_DEV_IDEDMA_PCI*/ | ||
| 452 | } | 449 | } |
| 450 | #endif /* CONFIG_BLK_DEV_IDEDMA_PCI */ | ||
| 453 | 451 | ||
| 454 | /** | 452 | /** |
| 455 | * ide_setup_pci_controller - set up IDE PCI | 453 | * ide_setup_pci_controller - set up IDE PCI |
| @@ -511,7 +509,7 @@ out: | |||
| 511 | void ide_pci_setup_ports(struct pci_dev *dev, const struct ide_port_info *d, int pciirq, u8 *idx) | 509 | void ide_pci_setup_ports(struct pci_dev *dev, const struct ide_port_info *d, int pciirq, u8 *idx) |
| 512 | { | 510 | { |
| 513 | int channels = (d->host_flags & IDE_HFLAG_SINGLE) ? 1 : 2, port; | 511 | int channels = (d->host_flags & IDE_HFLAG_SINGLE) ? 1 : 2, port; |
| 514 | ide_hwif_t *hwif, *mate = NULL; | 512 | ide_hwif_t *hwif; |
| 515 | u8 tmp; | 513 | u8 tmp; |
| 516 | 514 | ||
| 517 | /* | 515 | /* |
| @@ -527,56 +525,11 @@ void ide_pci_setup_ports(struct pci_dev *dev, const struct ide_port_info *d, int | |||
| 527 | continue; /* port not enabled */ | 525 | continue; /* port not enabled */ |
| 528 | } | 526 | } |
| 529 | 527 | ||
| 530 | if ((hwif = ide_hwif_configure(dev, d, mate, port, pciirq)) == NULL) | 528 | hwif = ide_hwif_configure(dev, d, port, pciirq); |
| 529 | if (hwif == NULL) | ||
| 531 | continue; | 530 | continue; |
| 532 | 531 | ||
| 533 | *(idx + port) = hwif->index; | 532 | *(idx + port) = hwif->index; |
| 534 | |||
| 535 | if (d->init_iops) | ||
| 536 | d->init_iops(hwif); | ||
| 537 | |||
| 538 | if ((d->host_flags & IDE_HFLAG_NO_DMA) == 0) | ||
| 539 | ide_hwif_setup_dma(dev, d, hwif); | ||
| 540 | |||
| 541 | if ((!hwif->irq && (d->host_flags & IDE_HFLAG_LEGACY_IRQS)) || | ||
| 542 | (d->host_flags & IDE_HFLAG_FORCE_LEGACY_IRQS)) | ||
| 543 | hwif->irq = port ? 15 : 14; | ||
| 544 | |||
| 545 | hwif->host_flags = d->host_flags; | ||
| 546 | hwif->pio_mask = d->pio_mask; | ||
| 547 | |||
| 548 | if ((d->host_flags & IDE_HFLAG_SERIALIZE) && hwif->mate) | ||
| 549 | hwif->mate->serialized = hwif->serialized = 1; | ||
| 550 | |||
| 551 | if (d->host_flags & IDE_HFLAG_IO_32BIT) { | ||
| 552 | hwif->drives[0].io_32bit = 1; | ||
| 553 | hwif->drives[1].io_32bit = 1; | ||
| 554 | } | ||
| 555 | |||
| 556 | if (d->host_flags & IDE_HFLAG_UNMASK_IRQS) { | ||
| 557 | hwif->drives[0].unmask = 1; | ||
| 558 | hwif->drives[1].unmask = 1; | ||
| 559 | } | ||
| 560 | |||
| 561 | if (hwif->dma_base) { | ||
| 562 | hwif->swdma_mask = d->swdma_mask; | ||
| 563 | hwif->mwdma_mask = d->mwdma_mask; | ||
| 564 | hwif->ultra_mask = d->udma_mask; | ||
| 565 | } | ||
| 566 | |||
| 567 | hwif->drives[0].autotune = 1; | ||
| 568 | hwif->drives[1].autotune = 1; | ||
| 569 | |||
| 570 | if (d->host_flags & IDE_HFLAG_RQSIZE_256) | ||
| 571 | hwif->rqsize = 256; | ||
| 572 | |||
| 573 | if (d->init_hwif) | ||
| 574 | /* Call chipset-specific routine | ||
| 575 | * for each enabled hwif | ||
| 576 | */ | ||
| 577 | d->init_hwif(hwif); | ||
| 578 | |||
| 579 | mate = hwif; | ||
| 580 | } | 533 | } |
| 581 | } | 534 | } |
| 582 | 535 | ||
| @@ -658,7 +611,7 @@ int ide_setup_pci_device(struct pci_dev *dev, const struct ide_port_info *d) | |||
| 658 | ret = do_ide_setup_pci_device(dev, d, &idx[0], 1); | 611 | ret = do_ide_setup_pci_device(dev, d, &idx[0], 1); |
| 659 | 612 | ||
| 660 | if (ret >= 0) | 613 | if (ret >= 0) |
| 661 | ide_device_add(idx); | 614 | ide_device_add(idx, d); |
| 662 | 615 | ||
| 663 | return ret; | 616 | return ret; |
| 664 | } | 617 | } |
| @@ -682,7 +635,7 @@ int ide_setup_pci_devices(struct pci_dev *dev1, struct pci_dev *dev2, | |||
| 682 | goto out; | 635 | goto out; |
| 683 | } | 636 | } |
| 684 | 637 | ||
| 685 | ide_device_add(idx); | 638 | ide_device_add(idx, d); |
| 686 | out: | 639 | out: |
| 687 | return ret; | 640 | return ret; |
| 688 | } | 641 | } |
diff --git a/drivers/macintosh/mediabay.c b/drivers/macintosh/mediabay.c index 18dde2a27209..de9ebbfbf122 100644 --- a/drivers/macintosh/mediabay.c +++ b/drivers/macintosh/mediabay.c | |||
| @@ -595,7 +595,7 @@ static void media_bay_step(int i) | |||
| 595 | if (bay->cd_index >= 0) { | 595 | if (bay->cd_index >= 0) { |
| 596 | printk(KERN_DEBUG "Unregistering mb %d ide, index:%d\n", i, | 596 | printk(KERN_DEBUG "Unregistering mb %d ide, index:%d\n", i, |
| 597 | bay->cd_index); | 597 | bay->cd_index); |
| 598 | ide_unregister(bay->cd_index); | 598 | ide_unregister(bay->cd_index, 1, 1); |
| 599 | bay->cd_index = -1; | 599 | bay->cd_index = -1; |
| 600 | } | 600 | } |
| 601 | if (bay->cd_retry) { | 601 | if (bay->cd_retry) { |
diff --git a/drivers/scsi/ide-scsi.c b/drivers/scsi/ide-scsi.c index 5ed00069846d..6c4f0f081785 100644 --- a/drivers/scsi/ide-scsi.c +++ b/drivers/scsi/ide-scsi.c | |||
| @@ -588,19 +588,14 @@ static ide_startstop_t idescsi_issue_pc (ide_drive_t *drive, idescsi_pc_t *pc) | |||
| 588 | hwif->sg_mapped = 0; | 588 | hwif->sg_mapped = 0; |
| 589 | } | 589 | } |
| 590 | 590 | ||
| 591 | SELECT_DRIVE(drive); | ||
| 592 | |||
| 593 | ide_pktcmd_tf_load(drive, IDE_TFLAG_NO_SELECT_MASK, bcount, dma); | 591 | ide_pktcmd_tf_load(drive, IDE_TFLAG_NO_SELECT_MASK, bcount, dma); |
| 594 | 592 | ||
| 595 | if (dma) | 593 | if (dma) |
| 596 | set_bit(PC_DMA_OK, &pc->flags); | 594 | set_bit(PC_DMA_OK, &pc->flags); |
| 597 | 595 | ||
| 598 | if (test_bit(IDESCSI_DRQ_INTERRUPT, &scsi->flags)) { | 596 | if (test_bit(IDESCSI_DRQ_INTERRUPT, &scsi->flags)) { |
| 599 | BUG_ON(HWGROUP(drive)->handler != NULL); | 597 | ide_execute_command(drive, WIN_PACKETCMD, &idescsi_transfer_pc, |
| 600 | ide_set_handler(drive, &idescsi_transfer_pc, | 598 | get_timeout(pc), idescsi_expiry); |
| 601 | get_timeout(pc), idescsi_expiry); | ||
| 602 | /* Issue the packet command */ | ||
| 603 | HWIF(drive)->OUTB(WIN_PACKETCMD, IDE_COMMAND_REG); | ||
| 604 | return ide_started; | 599 | return ide_started; |
| 605 | } else { | 600 | } else { |
| 606 | /* Issue the packet command */ | 601 | /* Issue the packet command */ |
diff --git a/include/linux/hdreg.h b/include/linux/hdreg.h index ff43f8d6b5b3..3882013d29ea 100644 --- a/include/linux/hdreg.h +++ b/include/linux/hdreg.h | |||
| @@ -706,8 +706,10 @@ struct hd_driveid { | |||
| 706 | */ | 706 | */ |
| 707 | #define IDE_NICE_DSC_OVERLAP (0) /* per the DSC overlap protocol */ | 707 | #define IDE_NICE_DSC_OVERLAP (0) /* per the DSC overlap protocol */ |
| 708 | #define IDE_NICE_ATAPI_OVERLAP (1) /* not supported yet */ | 708 | #define IDE_NICE_ATAPI_OVERLAP (1) /* not supported yet */ |
| 709 | #define IDE_NICE_0 (2) /* when sure that it won't affect us */ | ||
| 710 | #define IDE_NICE_1 (3) /* when probably won't affect us much */ | 709 | #define IDE_NICE_1 (3) /* when probably won't affect us much */ |
| 710 | #ifndef __KERNEL__ | ||
| 711 | #define IDE_NICE_0 (2) /* when sure that it won't affect us */ | ||
| 711 | #define IDE_NICE_2 (4) /* when we know it's on our expense */ | 712 | #define IDE_NICE_2 (4) /* when we know it's on our expense */ |
| 713 | #endif | ||
| 712 | 714 | ||
| 713 | #endif /* _LINUX_HDREG_H */ | 715 | #endif /* _LINUX_HDREG_H */ |
diff --git a/include/linux/ide.h b/include/linux/ide.h index ec10b2a3bb6e..367c17084a28 100644 --- a/include/linux/ide.h +++ b/include/linux/ide.h | |||
| @@ -112,18 +112,12 @@ typedef unsigned char byte; /* used everywhere */ | |||
| 112 | #define SATA_NR_PORTS (3) /* 16 possible ?? */ | 112 | #define SATA_NR_PORTS (3) /* 16 possible ?? */ |
| 113 | 113 | ||
| 114 | #define SATA_STATUS_OFFSET (0) | 114 | #define SATA_STATUS_OFFSET (0) |
| 115 | #define SATA_STATUS_REG (HWIF(drive)->sata_scr[SATA_STATUS_OFFSET]) | ||
| 116 | #define SATA_ERROR_OFFSET (1) | 115 | #define SATA_ERROR_OFFSET (1) |
| 117 | #define SATA_ERROR_REG (HWIF(drive)->sata_scr[SATA_ERROR_OFFSET]) | ||
| 118 | #define SATA_CONTROL_OFFSET (2) | 116 | #define SATA_CONTROL_OFFSET (2) |
| 119 | #define SATA_CONTROL_REG (HWIF(drive)->sata_scr[SATA_CONTROL_OFFSET]) | ||
| 120 | 117 | ||
| 121 | #define SATA_MISC_OFFSET (0) | 118 | #define SATA_MISC_OFFSET (0) |
| 122 | #define SATA_MISC_REG (HWIF(drive)->sata_misc[SATA_MISC_OFFSET]) | ||
| 123 | #define SATA_PHY_OFFSET (1) | 119 | #define SATA_PHY_OFFSET (1) |
| 124 | #define SATA_PHY_REG (HWIF(drive)->sata_misc[SATA_PHY_OFFSET]) | ||
| 125 | #define SATA_IEN_OFFSET (2) | 120 | #define SATA_IEN_OFFSET (2) |
| 126 | #define SATA_IEN_REG (HWIF(drive)->sata_misc[SATA_IEN_OFFSET]) | ||
| 127 | 121 | ||
| 128 | /* | 122 | /* |
| 129 | * Our Physical Region Descriptor (PRD) table should be large enough | 123 | * Our Physical Region Descriptor (PRD) table should be large enough |
| @@ -196,6 +190,7 @@ typedef struct hw_regs_s { | |||
| 196 | } hw_regs_t; | 190 | } hw_regs_t; |
| 197 | 191 | ||
| 198 | struct hwif_s * ide_find_port(unsigned long); | 192 | struct hwif_s * ide_find_port(unsigned long); |
| 193 | struct hwif_s *ide_deprecated_find_port(unsigned long); | ||
| 199 | void ide_init_port_data(struct hwif_s *, unsigned int); | 194 | void ide_init_port_data(struct hwif_s *, unsigned int); |
| 200 | void ide_init_port_hw(struct hwif_s *, hw_regs_t *); | 195 | void ide_init_port_hw(struct hwif_s *, hw_regs_t *); |
| 201 | 196 | ||
| @@ -406,8 +401,6 @@ typedef struct ide_drive_s { | |||
| 406 | unsigned no_unmask : 1; /* disallow setting unmask bit */ | 401 | unsigned no_unmask : 1; /* disallow setting unmask bit */ |
| 407 | unsigned no_io_32bit : 1; /* disallow enabling 32bit I/O */ | 402 | unsigned no_io_32bit : 1; /* disallow enabling 32bit I/O */ |
| 408 | unsigned atapi_overlap : 1; /* ATAPI overlap (not supported) */ | 403 | unsigned atapi_overlap : 1; /* ATAPI overlap (not supported) */ |
| 409 | unsigned nice0 : 1; /* give obvious excess bandwidth */ | ||
| 410 | unsigned nice2 : 1; /* give a share in our own bandwidth */ | ||
| 411 | unsigned doorlocking : 1; /* for removable only: door lock/unlock works */ | 404 | unsigned doorlocking : 1; /* for removable only: door lock/unlock works */ |
| 412 | unsigned nodma : 1; /* disallow DMA */ | 405 | unsigned nodma : 1; /* disallow DMA */ |
| 413 | unsigned autotune : 2; /* 0=default, 1=autotune, 2=noautotune */ | 406 | unsigned autotune : 2; /* 0=default, 1=autotune, 2=noautotune */ |
| @@ -487,7 +480,6 @@ typedef struct hwif_s { | |||
| 487 | u8 major; /* our major number */ | 480 | u8 major; /* our major number */ |
| 488 | u8 index; /* 0 for ide0; 1 for ide1; ... */ | 481 | u8 index; /* 0 for ide0; 1 for ide1; ... */ |
| 489 | u8 channel; /* for dual-port chips: 0=primary, 1=secondary */ | 482 | u8 channel; /* for dual-port chips: 0=primary, 1=secondary */ |
| 490 | u8 straight8; /* Alan's straight 8 check */ | ||
| 491 | u8 bus_state; /* power state of the IDE bus */ | 483 | u8 bus_state; /* power state of the IDE bus */ |
| 492 | 484 | ||
| 493 | u32 host_flags; | 485 | u32 host_flags; |
| @@ -513,6 +505,8 @@ typedef struct hwif_s { | |||
| 513 | #if 0 | 505 | #if 0 |
| 514 | ide_hwif_ops_t *hwifops; | 506 | ide_hwif_ops_t *hwifops; |
| 515 | #else | 507 | #else |
| 508 | /* host specific initialization of devices on a port */ | ||
| 509 | void (*port_init_devs)(struct hwif_s *); | ||
| 516 | /* routine to program host for PIO mode */ | 510 | /* routine to program host for PIO mode */ |
| 517 | void (*set_pio_mode)(ide_drive_t *, const u8); | 511 | void (*set_pio_mode)(ide_drive_t *, const u8); |
| 518 | /* routine to program host for DMA mode */ | 512 | /* routine to program host for DMA mode */ |
| @@ -535,6 +529,8 @@ typedef struct hwif_s { | |||
| 535 | u8 (*mdma_filter)(ide_drive_t *); | 529 | u8 (*mdma_filter)(ide_drive_t *); |
| 536 | u8 (*udma_filter)(ide_drive_t *); | 530 | u8 (*udma_filter)(ide_drive_t *); |
| 537 | 531 | ||
| 532 | u8 (*cable_detect)(struct hwif_s *); | ||
| 533 | |||
| 538 | void (*ata_input_data)(ide_drive_t *, void *, u32); | 534 | void (*ata_input_data)(ide_drive_t *, void *, u32); |
| 539 | void (*ata_output_data)(ide_drive_t *, void *, u32); | 535 | void (*ata_output_data)(ide_drive_t *, void *, u32); |
| 540 | 536 | ||
| @@ -602,10 +598,9 @@ typedef struct hwif_s { | |||
| 602 | unsigned serialized : 1; /* serialized all channel operation */ | 598 | unsigned serialized : 1; /* serialized all channel operation */ |
| 603 | unsigned sharing_irq: 1; /* 1 = sharing irq with another hwif */ | 599 | unsigned sharing_irq: 1; /* 1 = sharing irq with another hwif */ |
| 604 | unsigned reset : 1; /* reset after probe */ | 600 | unsigned reset : 1; /* reset after probe */ |
| 605 | unsigned auto_poll : 1; /* supports nop auto-poll */ | ||
| 606 | unsigned sg_mapped : 1; /* sg_table and sg_nents are ready */ | 601 | unsigned sg_mapped : 1; /* sg_table and sg_nents are ready */ |
| 607 | unsigned no_io_32bit : 1; /* 1 = can not do 32-bit IO ops */ | ||
| 608 | unsigned mmio : 1; /* host uses MMIO */ | 602 | unsigned mmio : 1; /* host uses MMIO */ |
| 603 | unsigned straight8 : 1; /* Alan's straight 8 check */ | ||
| 609 | 604 | ||
| 610 | struct device gendev; | 605 | struct device gendev; |
| 611 | struct completion gendev_rel_comp; /* To deal with device release() */ | 606 | struct completion gendev_rel_comp; /* To deal with device release() */ |
| @@ -625,6 +620,9 @@ typedef struct hwif_s { | |||
| 625 | typedef ide_startstop_t (ide_handler_t)(ide_drive_t *); | 620 | typedef ide_startstop_t (ide_handler_t)(ide_drive_t *); |
| 626 | typedef int (ide_expiry_t)(ide_drive_t *); | 621 | typedef int (ide_expiry_t)(ide_drive_t *); |
| 627 | 622 | ||
| 623 | /* used by ide-cd, ide-floppy, etc. */ | ||
| 624 | typedef void (xfer_func_t)(ide_drive_t *, void *, u32); | ||
| 625 | |||
| 628 | typedef struct hwgroup_s { | 626 | typedef struct hwgroup_s { |
| 629 | /* irq handler, if active */ | 627 | /* irq handler, if active */ |
| 630 | ide_startstop_t (*handler)(ide_drive_t *); | 628 | ide_startstop_t (*handler)(ide_drive_t *); |
| @@ -708,6 +706,7 @@ typedef struct { | |||
| 708 | void proc_ide_create(void); | 706 | void proc_ide_create(void); |
| 709 | void proc_ide_destroy(void); | 707 | void proc_ide_destroy(void); |
| 710 | void ide_proc_register_port(ide_hwif_t *); | 708 | void ide_proc_register_port(ide_hwif_t *); |
| 709 | void ide_proc_port_register_devices(ide_hwif_t *); | ||
| 711 | void ide_proc_unregister_port(ide_hwif_t *); | 710 | void ide_proc_unregister_port(ide_hwif_t *); |
| 712 | void ide_proc_register_driver(ide_drive_t *, ide_driver_t *); | 711 | void ide_proc_register_driver(ide_drive_t *, ide_driver_t *); |
| 713 | void ide_proc_unregister_driver(ide_drive_t *, ide_driver_t *); | 712 | void ide_proc_unregister_driver(ide_drive_t *, ide_driver_t *); |
| @@ -740,6 +739,7 @@ void ide_pci_create_host_proc(const char *, get_info_t *); | |||
| 740 | static inline void proc_ide_create(void) { ; } | 739 | static inline void proc_ide_create(void) { ; } |
| 741 | static inline void proc_ide_destroy(void) { ; } | 740 | static inline void proc_ide_destroy(void) { ; } |
| 742 | static inline void ide_proc_register_port(ide_hwif_t *hwif) { ; } | 741 | static inline void ide_proc_register_port(ide_hwif_t *hwif) { ; } |
| 742 | static inline void ide_proc_port_register_devices(ide_hwif_t *hwif) { ; } | ||
| 743 | static inline void ide_proc_unregister_port(ide_hwif_t *hwif) { ; } | 743 | static inline void ide_proc_unregister_port(ide_hwif_t *hwif) { ; } |
| 744 | static inline void ide_proc_register_driver(ide_drive_t *drive, ide_driver_t *driver) { ; } | 744 | static inline void ide_proc_register_driver(ide_drive_t *drive, ide_driver_t *driver) { ; } |
| 745 | static inline void ide_proc_unregister_driver(ide_drive_t *drive, ide_driver_t *driver) { ; } | 745 | static inline void ide_proc_unregister_driver(ide_drive_t *drive, ide_driver_t *driver) { ; } |
| @@ -988,10 +988,8 @@ int ide_task_ioctl(ide_drive_t *, unsigned int, unsigned long); | |||
| 988 | extern int system_bus_clock(void); | 988 | extern int system_bus_clock(void); |
| 989 | 989 | ||
| 990 | extern int ide_driveid_update(ide_drive_t *); | 990 | extern int ide_driveid_update(ide_drive_t *); |
| 991 | extern int ide_ata66_check(ide_drive_t *, ide_task_t *); | ||
| 992 | extern int ide_config_drive_speed(ide_drive_t *, u8); | 991 | extern int ide_config_drive_speed(ide_drive_t *, u8); |
| 993 | extern u8 eighty_ninty_three (ide_drive_t *); | 992 | extern u8 eighty_ninty_three (ide_drive_t *); |
| 994 | extern int set_transfer(ide_drive_t *, ide_task_t *); | ||
| 995 | extern int taskfile_lib_get_identify(ide_drive_t *drive, u8 *); | 993 | extern int taskfile_lib_get_identify(ide_drive_t *drive, u8 *); |
| 996 | 994 | ||
| 997 | extern int ide_wait_not_busy(ide_hwif_t *hwif, unsigned long timeout); | 995 | extern int ide_wait_not_busy(ide_hwif_t *hwif, unsigned long timeout); |
| @@ -1016,6 +1014,13 @@ extern int __ide_pci_register_driver(struct pci_driver *driver, struct module *o | |||
| 1016 | void ide_pci_setup_ports(struct pci_dev *, const struct ide_port_info *, int, u8 *); | 1014 | void ide_pci_setup_ports(struct pci_dev *, const struct ide_port_info *, int, u8 *); |
| 1017 | void ide_setup_pci_noise(struct pci_dev *, const struct ide_port_info *); | 1015 | void ide_setup_pci_noise(struct pci_dev *, const struct ide_port_info *); |
| 1018 | 1016 | ||
| 1017 | #ifdef CONFIG_BLK_DEV_IDEDMA_PCI | ||
| 1018 | void ide_hwif_setup_dma(ide_hwif_t *, const struct ide_port_info *); | ||
| 1019 | #else | ||
| 1020 | static inline void ide_hwif_setup_dma(ide_hwif_t *hwif, | ||
| 1021 | const struct ide_port_info *d) { } | ||
| 1022 | #endif | ||
| 1023 | |||
| 1019 | extern void default_hwif_iops(ide_hwif_t *); | 1024 | extern void default_hwif_iops(ide_hwif_t *); |
| 1020 | extern void default_hwif_mmiops(ide_hwif_t *); | 1025 | extern void default_hwif_mmiops(ide_hwif_t *); |
| 1021 | extern void default_hwif_transport(ide_hwif_t *); | 1026 | extern void default_hwif_transport(ide_hwif_t *); |
| @@ -1052,7 +1057,7 @@ enum { | |||
| 1052 | IDE_HFLAG_NO_SET_MODE = (1 << 9), | 1057 | IDE_HFLAG_NO_SET_MODE = (1 << 9), |
| 1053 | /* trust BIOS for programming chipset/device for DMA */ | 1058 | /* trust BIOS for programming chipset/device for DMA */ |
| 1054 | IDE_HFLAG_TRUST_BIOS_FOR_DMA = (1 << 10), | 1059 | IDE_HFLAG_TRUST_BIOS_FOR_DMA = (1 << 10), |
| 1055 | /* host uses VDMA */ | 1060 | /* host uses VDMA (tied with IDE_HFLAG_CS5520 for now) */ |
| 1056 | IDE_HFLAG_VDMA = (1 << 11), | 1061 | IDE_HFLAG_VDMA = (1 << 11), |
| 1057 | /* ATAPI DMA is unsupported */ | 1062 | /* ATAPI DMA is unsupported */ |
| 1058 | IDE_HFLAG_NO_ATAPI_DMA = (1 << 12), | 1063 | IDE_HFLAG_NO_ATAPI_DMA = (1 << 12), |
| @@ -1062,8 +1067,10 @@ enum { | |||
| 1062 | IDE_HFLAG_NO_DMA = (1 << 14), | 1067 | IDE_HFLAG_NO_DMA = (1 << 14), |
| 1063 | /* check if host is PCI IDE device before allowing DMA */ | 1068 | /* check if host is PCI IDE device before allowing DMA */ |
| 1064 | IDE_HFLAG_NO_AUTODMA = (1 << 15), | 1069 | IDE_HFLAG_NO_AUTODMA = (1 << 15), |
| 1070 | /* don't autotune PIO */ | ||
| 1071 | IDE_HFLAG_NO_AUTOTUNE = (1 << 16), | ||
| 1065 | /* host is CS5510/CS5520 */ | 1072 | /* host is CS5510/CS5520 */ |
| 1066 | IDE_HFLAG_CS5520 = (1 << 16), | 1073 | IDE_HFLAG_CS5520 = IDE_HFLAG_VDMA, |
| 1067 | /* no LBA48 */ | 1074 | /* no LBA48 */ |
| 1068 | IDE_HFLAG_NO_LBA48 = (1 << 17), | 1075 | IDE_HFLAG_NO_LBA48 = (1 << 17), |
| 1069 | /* no LBA48 DMA */ | 1076 | /* no LBA48 DMA */ |
| @@ -1089,6 +1096,10 @@ enum { | |||
| 1089 | IDE_HFLAG_CLEAR_SIMPLEX = (1 << 28), | 1096 | IDE_HFLAG_CLEAR_SIMPLEX = (1 << 28), |
| 1090 | /* DSC overlap is unsupported */ | 1097 | /* DSC overlap is unsupported */ |
| 1091 | IDE_HFLAG_NO_DSC = (1 << 29), | 1098 | IDE_HFLAG_NO_DSC = (1 << 29), |
| 1099 | /* never use 32-bit I/O ops */ | ||
| 1100 | IDE_HFLAG_NO_IO_32BIT = (1 << 30), | ||
| 1101 | /* never unmask IRQs */ | ||
| 1102 | IDE_HFLAG_NO_UNMASK_IRQS = (1 << 31), | ||
| 1092 | }; | 1103 | }; |
| 1093 | 1104 | ||
| 1094 | #ifdef CONFIG_BLK_DEV_OFFBOARD | 1105 | #ifdef CONFIG_BLK_DEV_OFFBOARD |
| @@ -1144,6 +1155,7 @@ void ide_dma_off_quietly(ide_drive_t *); | |||
| 1144 | void ide_dma_off(ide_drive_t *); | 1155 | void ide_dma_off(ide_drive_t *); |
| 1145 | void ide_dma_on(ide_drive_t *); | 1156 | void ide_dma_on(ide_drive_t *); |
| 1146 | int ide_set_dma(ide_drive_t *); | 1157 | int ide_set_dma(ide_drive_t *); |
| 1158 | void ide_check_dma_crc(ide_drive_t *); | ||
| 1147 | ide_startstop_t ide_dma_intr(ide_drive_t *); | 1159 | ide_startstop_t ide_dma_intr(ide_drive_t *); |
| 1148 | 1160 | ||
| 1149 | int ide_build_sglist(ide_drive_t *, struct request *); | 1161 | int ide_build_sglist(ide_drive_t *, struct request *); |
| @@ -1171,6 +1183,7 @@ static inline void ide_dma_off(ide_drive_t *drive) { ; } | |||
| 1171 | static inline void ide_dma_on(ide_drive_t *drive) { ; } | 1183 | static inline void ide_dma_on(ide_drive_t *drive) { ; } |
| 1172 | static inline void ide_dma_verbose(ide_drive_t *drive) { ; } | 1184 | static inline void ide_dma_verbose(ide_drive_t *drive) { ; } |
| 1173 | static inline int ide_set_dma(ide_drive_t *drive) { return 1; } | 1185 | static inline int ide_set_dma(ide_drive_t *drive) { return 1; } |
| 1186 | static inline void ide_check_dma_crc(ide_drive_t *drive) { ; } | ||
| 1174 | #endif /* CONFIG_BLK_DEV_IDEDMA */ | 1187 | #endif /* CONFIG_BLK_DEV_IDEDMA */ |
| 1175 | 1188 | ||
| 1176 | #ifndef CONFIG_BLK_DEV_IDEDMA_PCI | 1189 | #ifndef CONFIG_BLK_DEV_IDEDMA_PCI |
| @@ -1182,27 +1195,29 @@ extern int ide_acpi_exec_tfs(ide_drive_t *drive); | |||
| 1182 | extern void ide_acpi_get_timing(ide_hwif_t *hwif); | 1195 | extern void ide_acpi_get_timing(ide_hwif_t *hwif); |
| 1183 | extern void ide_acpi_push_timing(ide_hwif_t *hwif); | 1196 | extern void ide_acpi_push_timing(ide_hwif_t *hwif); |
| 1184 | extern void ide_acpi_init(ide_hwif_t *hwif); | 1197 | extern void ide_acpi_init(ide_hwif_t *hwif); |
| 1198 | void ide_acpi_port_init_devices(ide_hwif_t *); | ||
| 1185 | extern void ide_acpi_set_state(ide_hwif_t *hwif, int on); | 1199 | extern void ide_acpi_set_state(ide_hwif_t *hwif, int on); |
| 1186 | #else | 1200 | #else |
| 1187 | static inline int ide_acpi_exec_tfs(ide_drive_t *drive) { return 0; } | 1201 | static inline int ide_acpi_exec_tfs(ide_drive_t *drive) { return 0; } |
| 1188 | static inline void ide_acpi_get_timing(ide_hwif_t *hwif) { ; } | 1202 | static inline void ide_acpi_get_timing(ide_hwif_t *hwif) { ; } |
| 1189 | static inline void ide_acpi_push_timing(ide_hwif_t *hwif) { ; } | 1203 | static inline void ide_acpi_push_timing(ide_hwif_t *hwif) { ; } |
| 1190 | static inline void ide_acpi_init(ide_hwif_t *hwif) { ; } | 1204 | static inline void ide_acpi_init(ide_hwif_t *hwif) { ; } |
| 1205 | static inline void ide_acpi_port_init_devices(ide_hwif_t *hwif) { ; } | ||
| 1191 | static inline void ide_acpi_set_state(ide_hwif_t *hwif, int on) {} | 1206 | static inline void ide_acpi_set_state(ide_hwif_t *hwif, int on) {} |
| 1192 | #endif | 1207 | #endif |
| 1193 | 1208 | ||
| 1194 | void ide_remove_port_from_hwgroup(ide_hwif_t *); | 1209 | void ide_remove_port_from_hwgroup(ide_hwif_t *); |
| 1195 | extern int ide_hwif_request_regions(ide_hwif_t *hwif); | 1210 | extern int ide_hwif_request_regions(ide_hwif_t *hwif); |
| 1196 | extern void ide_hwif_release_regions(ide_hwif_t* hwif); | 1211 | extern void ide_hwif_release_regions(ide_hwif_t* hwif); |
| 1197 | extern void ide_unregister (unsigned int index); | 1212 | void ide_unregister(unsigned int, int, int); |
| 1198 | 1213 | ||
| 1199 | void ide_register_region(struct gendisk *); | 1214 | void ide_register_region(struct gendisk *); |
| 1200 | void ide_unregister_region(struct gendisk *); | 1215 | void ide_unregister_region(struct gendisk *); |
| 1201 | 1216 | ||
| 1202 | void ide_undecoded_slave(ide_drive_t *); | 1217 | void ide_undecoded_slave(ide_drive_t *); |
| 1203 | 1218 | ||
| 1204 | int ide_device_add_all(u8 *idx); | 1219 | int ide_device_add_all(u8 *idx, const struct ide_port_info *); |
| 1205 | int ide_device_add(u8 idx[4]); | 1220 | int ide_device_add(u8 idx[4], const struct ide_port_info *); |
| 1206 | 1221 | ||
| 1207 | static inline void *ide_get_hwifdata (ide_hwif_t * hwif) | 1222 | static inline void *ide_get_hwifdata (ide_hwif_t * hwif) |
| 1208 | { | 1223 | { |
