ide-atapi: remove ide-scsi remnants from ide_transfer_pc()
[safe/jmp/linux-2.6] / drivers / ide / ide-atapi.c
1 /*
2  * ATAPI support.
3  */
4
5 #include <linux/kernel.h>
6 #include <linux/cdrom.h>
7 #include <linux/delay.h>
8 #include <linux/ide.h>
9 #include <scsi/scsi.h>
10
11 #ifdef DEBUG
12 #define debug_log(fmt, args...) \
13         printk(KERN_INFO "ide: " fmt, ## args)
14 #else
15 #define debug_log(fmt, args...) do {} while (0)
16 #endif
17
18 static inline int dev_is_idecd(ide_drive_t *drive)
19 {
20         return (drive->media == ide_cdrom || drive->media == ide_optical) &&
21                 !(drive->dev_flags & IDE_DFLAG_SCSI);
22 }
23
24 /*
25  * Check whether we can support a device,
26  * based on the ATAPI IDENTIFY command results.
27  */
28 int ide_check_atapi_device(ide_drive_t *drive, const char *s)
29 {
30         u16 *id = drive->id;
31         u8 gcw[2], protocol, device_type, removable, drq_type, packet_size;
32
33         *((u16 *)&gcw) = id[ATA_ID_CONFIG];
34
35         protocol    = (gcw[1] & 0xC0) >> 6;
36         device_type =  gcw[1] & 0x1F;
37         removable   = (gcw[0] & 0x80) >> 7;
38         drq_type    = (gcw[0] & 0x60) >> 5;
39         packet_size =  gcw[0] & 0x03;
40
41 #ifdef CONFIG_PPC
42         /* kludge for Apple PowerBook internal zip */
43         if (drive->media == ide_floppy && device_type == 5 &&
44             !strstr((char *)&id[ATA_ID_PROD], "CD-ROM") &&
45             strstr((char *)&id[ATA_ID_PROD], "ZIP"))
46                 device_type = 0;
47 #endif
48
49         if (protocol != 2)
50                 printk(KERN_ERR "%s: %s: protocol (0x%02x) is not ATAPI\n",
51                         s, drive->name, protocol);
52         else if ((drive->media == ide_floppy && device_type != 0) ||
53                  (drive->media == ide_tape && device_type != 1))
54                 printk(KERN_ERR "%s: %s: invalid device type (0x%02x)\n",
55                         s, drive->name, device_type);
56         else if (removable == 0)
57                 printk(KERN_ERR "%s: %s: the removable flag is not set\n",
58                         s, drive->name);
59         else if (drive->media == ide_floppy && drq_type == 3)
60                 printk(KERN_ERR "%s: %s: sorry, DRQ type (0x%02x) not "
61                         "supported\n", s, drive->name, drq_type);
62         else if (packet_size != 0)
63                 printk(KERN_ERR "%s: %s: packet size (0x%02x) is not 12 "
64                         "bytes\n", s, drive->name, packet_size);
65         else
66                 return 1;
67         return 0;
68 }
69 EXPORT_SYMBOL_GPL(ide_check_atapi_device);
70
71 /* PIO data transfer routine using the scatter gather table. */
72 int ide_io_buffers(ide_drive_t *drive, struct ide_atapi_pc *pc,
73                     unsigned int bcount, int write)
74 {
75         ide_hwif_t *hwif = drive->hwif;
76         const struct ide_tp_ops *tp_ops = hwif->tp_ops;
77         xfer_func_t *xf = write ? tp_ops->output_data : tp_ops->input_data;
78         struct scatterlist *sg = pc->sg;
79         char *buf;
80         int count, done = 0;
81
82         while (bcount) {
83                 count = min(sg->length - pc->b_count, bcount);
84
85                 if (PageHighMem(sg_page(sg))) {
86                         unsigned long flags;
87
88                         local_irq_save(flags);
89                         buf = kmap_atomic(sg_page(sg), KM_IRQ0) + sg->offset;
90                         xf(drive, NULL, buf + pc->b_count, count);
91                         kunmap_atomic(buf - sg->offset, KM_IRQ0);
92                         local_irq_restore(flags);
93                 } else {
94                         buf = sg_virt(sg);
95                         xf(drive, NULL, buf + pc->b_count, count);
96                 }
97
98                 bcount -= count;
99                 pc->b_count += count;
100                 done += count;
101
102                 if (pc->b_count == sg->length) {
103                         if (!--pc->sg_cnt)
104                                 break;
105                         pc->sg = sg = sg_next(sg);
106                         pc->b_count = 0;
107                 }
108         }
109
110         if (bcount) {
111                 printk(KERN_ERR "%s: %d leftover bytes, %s\n", drive->name,
112                         bcount, write ? "padding with zeros"
113                                       : "discarding data");
114                 ide_pad_transfer(drive, write, bcount);
115         }
116
117         return done;
118 }
119 EXPORT_SYMBOL_GPL(ide_io_buffers);
120
121 void ide_init_pc(struct ide_atapi_pc *pc)
122 {
123         memset(pc, 0, sizeof(*pc));
124         pc->buf = pc->pc_buf;
125         pc->buf_size = IDE_PC_BUFFER_SIZE;
126 }
127 EXPORT_SYMBOL_GPL(ide_init_pc);
128
129 /*
130  * Generate a new packet command request in front of the request queue, before
131  * the current request, so that it will be processed immediately, on the next
132  * pass through the driver.
133  */
134 static void ide_queue_pc_head(ide_drive_t *drive, struct gendisk *disk,
135                               struct ide_atapi_pc *pc, struct request *rq)
136 {
137         blk_rq_init(NULL, rq);
138         rq->cmd_type = REQ_TYPE_SPECIAL;
139         rq->cmd_flags |= REQ_PREEMPT;
140         rq->buffer = (char *)pc;
141         rq->rq_disk = disk;
142         memcpy(rq->cmd, pc->c, 12);
143         if (drive->media == ide_tape)
144                 rq->cmd[13] = REQ_IDETAPE_PC1;
145         ide_do_drive_cmd(drive, rq);
146 }
147
148 /*
149  * Add a special packet command request to the tail of the request queue,
150  * and wait for it to be serviced.
151  */
152 int ide_queue_pc_tail(ide_drive_t *drive, struct gendisk *disk,
153                       struct ide_atapi_pc *pc)
154 {
155         struct request *rq;
156         int error;
157
158         rq = blk_get_request(drive->queue, READ, __GFP_WAIT);
159         rq->cmd_type = REQ_TYPE_SPECIAL;
160         rq->buffer = (char *)pc;
161         memcpy(rq->cmd, pc->c, 12);
162         if (drive->media == ide_tape)
163                 rq->cmd[13] = REQ_IDETAPE_PC1;
164         error = blk_execute_rq(drive->queue, disk, rq, 0);
165         blk_put_request(rq);
166
167         return error;
168 }
169 EXPORT_SYMBOL_GPL(ide_queue_pc_tail);
170
171 int ide_do_test_unit_ready(ide_drive_t *drive, struct gendisk *disk)
172 {
173         struct ide_atapi_pc pc;
174
175         ide_init_pc(&pc);
176         pc.c[0] = TEST_UNIT_READY;
177
178         return ide_queue_pc_tail(drive, disk, &pc);
179 }
180 EXPORT_SYMBOL_GPL(ide_do_test_unit_ready);
181
182 int ide_do_start_stop(ide_drive_t *drive, struct gendisk *disk, int start)
183 {
184         struct ide_atapi_pc pc;
185
186         ide_init_pc(&pc);
187         pc.c[0] = START_STOP;
188         pc.c[4] = start;
189
190         if (drive->media == ide_tape)
191                 pc.flags |= PC_FLAG_WAIT_FOR_DSC;
192
193         return ide_queue_pc_tail(drive, disk, &pc);
194 }
195 EXPORT_SYMBOL_GPL(ide_do_start_stop);
196
197 int ide_set_media_lock(ide_drive_t *drive, struct gendisk *disk, int on)
198 {
199         struct ide_atapi_pc pc;
200
201         if ((drive->dev_flags & IDE_DFLAG_DOORLOCKING) == 0)
202                 return 0;
203
204         ide_init_pc(&pc);
205         pc.c[0] = ALLOW_MEDIUM_REMOVAL;
206         pc.c[4] = on;
207
208         return ide_queue_pc_tail(drive, disk, &pc);
209 }
210 EXPORT_SYMBOL_GPL(ide_set_media_lock);
211
212 void ide_create_request_sense_cmd(ide_drive_t *drive, struct ide_atapi_pc *pc)
213 {
214         ide_init_pc(pc);
215         pc->c[0] = REQUEST_SENSE;
216         if (drive->media == ide_floppy) {
217                 pc->c[4] = 255;
218                 pc->req_xfer = 18;
219         } else {
220                 pc->c[4] = 20;
221                 pc->req_xfer = 20;
222         }
223 }
224 EXPORT_SYMBOL_GPL(ide_create_request_sense_cmd);
225
226 /*
227  * Called when an error was detected during the last packet command.
228  * We queue a request sense packet command in the head of the request list.
229  */
230 void ide_retry_pc(ide_drive_t *drive, struct gendisk *disk)
231 {
232         struct request *rq = &drive->request_sense_rq;
233         struct ide_atapi_pc *pc = &drive->request_sense_pc;
234
235         (void)ide_read_error(drive);
236         ide_create_request_sense_cmd(drive, pc);
237         if (drive->media == ide_tape)
238                 set_bit(IDE_AFLAG_IGNORE_DSC, &drive->atapi_flags);
239         ide_queue_pc_head(drive, disk, pc, rq);
240 }
241 EXPORT_SYMBOL_GPL(ide_retry_pc);
242
243 int ide_scsi_expiry(ide_drive_t *drive)
244 {
245         struct ide_atapi_pc *pc = drive->pc;
246
247         debug_log("%s called for %lu at %lu\n", __func__,
248                   pc->scsi_cmd->serial_number, jiffies);
249
250         pc->flags |= PC_FLAG_TIMEDOUT;
251
252         return 0; /* we do not want the IDE subsystem to retry */
253 }
254 EXPORT_SYMBOL_GPL(ide_scsi_expiry);
255
256 int ide_cd_expiry(ide_drive_t *drive)
257 {
258         struct request *rq = HWGROUP(drive)->rq;
259         unsigned long wait = 0;
260
261         debug_log("%s: rq->cmd[0]: 0x%x\n", __func__, rq->cmd[0]);
262
263         /*
264          * Some commands are *slow* and normally take a long time to complete.
265          * Usually we can use the ATAPI "disconnect" to bypass this, but not all
266          * commands/drives support that. Let ide_timer_expiry keep polling us
267          * for these.
268          */
269         switch (rq->cmd[0]) {
270         case GPCMD_BLANK:
271         case GPCMD_FORMAT_UNIT:
272         case GPCMD_RESERVE_RZONE_TRACK:
273         case GPCMD_CLOSE_TRACK:
274         case GPCMD_FLUSH_CACHE:
275                 wait = ATAPI_WAIT_PC;
276                 break;
277         default:
278                 if (!(rq->cmd_flags & REQ_QUIET))
279                         printk(KERN_INFO "cmd 0x%x timed out\n",
280                                          rq->cmd[0]);
281                 wait = 0;
282                 break;
283         }
284         return wait;
285 }
286 EXPORT_SYMBOL_GPL(ide_cd_expiry);
287
288 int ide_cd_get_xferlen(struct request *rq)
289 {
290         if (blk_fs_request(rq))
291                 return 32768;
292         else if (blk_sense_request(rq) || blk_pc_request(rq) ||
293                          rq->cmd_type == REQ_TYPE_ATA_PC)
294                 return rq->data_len;
295         else
296                 return 0;
297 }
298 EXPORT_SYMBOL_GPL(ide_cd_get_xferlen);
299
300 /*
301  * This is the usual interrupt handler which will be called during a packet
302  * command.  We will transfer some of the data (as requested by the drive)
303  * and will re-point interrupt handler to us.
304  */
305 static ide_startstop_t ide_pc_intr(ide_drive_t *drive)
306 {
307         struct ide_atapi_pc *pc = drive->pc;
308         ide_hwif_t *hwif = drive->hwif;
309         struct request *rq = hwif->hwgroup->rq;
310         const struct ide_tp_ops *tp_ops = hwif->tp_ops;
311         xfer_func_t *xferfunc;
312         ide_expiry_t *expiry;
313         unsigned int timeout, temp;
314         u16 bcount;
315         u8 stat, ireason, scsi = !!(drive->dev_flags & IDE_DFLAG_SCSI), dsc = 0;
316
317         debug_log("Enter %s - interrupt handler\n", __func__);
318
319         if (scsi) {
320                 timeout = ide_scsi_get_timeout(pc);
321                 expiry = ide_scsi_expiry;
322         } else {
323                 timeout = (drive->media == ide_floppy) ? WAIT_FLOPPY_CMD
324                                                        : WAIT_TAPE_CMD;
325                 expiry = NULL;
326         }
327
328         if (pc->flags & PC_FLAG_TIMEDOUT) {
329                 drive->pc_callback(drive, 0);
330                 return ide_stopped;
331         }
332
333         /* Clear the interrupt */
334         stat = tp_ops->read_status(hwif);
335
336         if (pc->flags & PC_FLAG_DMA_IN_PROGRESS) {
337                 if (hwif->dma_ops->dma_end(drive) ||
338                     (drive->media == ide_tape && !scsi && (stat & ATA_ERR))) {
339                         if (drive->media == ide_floppy && !scsi)
340                                 printk(KERN_ERR "%s: DMA %s error\n",
341                                         drive->name, rq_data_dir(pc->rq)
342                                                      ? "write" : "read");
343                         pc->flags |= PC_FLAG_DMA_ERROR;
344                 } else {
345                         pc->xferred = pc->req_xfer;
346                         if (drive->pc_update_buffers)
347                                 drive->pc_update_buffers(drive, pc);
348                 }
349                 debug_log("%s: DMA finished\n", drive->name);
350         }
351
352         /* No more interrupts */
353         if ((stat & ATA_DRQ) == 0) {
354                 debug_log("Packet command completed, %d bytes transferred\n",
355                           pc->xferred);
356
357                 pc->flags &= ~PC_FLAG_DMA_IN_PROGRESS;
358
359                 local_irq_enable_in_hardirq();
360
361                 if (drive->media == ide_tape && !scsi &&
362                     (stat & ATA_ERR) && rq->cmd[0] == REQUEST_SENSE)
363                         stat &= ~ATA_ERR;
364
365                 if ((stat & ATA_ERR) || (pc->flags & PC_FLAG_DMA_ERROR)) {
366                         /* Error detected */
367                         debug_log("%s: I/O error\n", drive->name);
368
369                         if (drive->media != ide_tape || scsi) {
370                                 pc->rq->errors++;
371                                 if (scsi)
372                                         goto cmd_finished;
373                         }
374
375                         if (rq->cmd[0] == REQUEST_SENSE) {
376                                 printk(KERN_ERR "%s: I/O error in request sense"
377                                                 " command\n", drive->name);
378                                 return ide_do_reset(drive);
379                         }
380
381                         debug_log("[cmd %x]: check condition\n", rq->cmd[0]);
382
383                         /* Retry operation */
384                         ide_retry_pc(drive, rq->rq_disk);
385
386                         /* queued, but not started */
387                         return ide_stopped;
388                 }
389 cmd_finished:
390                 pc->error = 0;
391
392                 if ((pc->flags & PC_FLAG_WAIT_FOR_DSC) && (stat & ATA_DSC) == 0)
393                         dsc = 1;
394
395                 /* Command finished - Call the callback function */
396                 drive->pc_callback(drive, dsc);
397
398                 return ide_stopped;
399         }
400
401         if (pc->flags & PC_FLAG_DMA_IN_PROGRESS) {
402                 pc->flags &= ~PC_FLAG_DMA_IN_PROGRESS;
403                 printk(KERN_ERR "%s: The device wants to issue more interrupts "
404                                 "in DMA mode\n", drive->name);
405                 ide_dma_off(drive);
406                 return ide_do_reset(drive);
407         }
408
409         /* Get the number of bytes to transfer on this interrupt. */
410         ide_read_bcount_and_ireason(drive, &bcount, &ireason);
411
412         if (ireason & ATAPI_COD) {
413                 printk(KERN_ERR "%s: CoD != 0 in %s\n", drive->name, __func__);
414                 return ide_do_reset(drive);
415         }
416
417         if (((ireason & ATAPI_IO) == ATAPI_IO) ==
418                 !!(pc->flags & PC_FLAG_WRITING)) {
419                 /* Hopefully, we will never get here */
420                 printk(KERN_ERR "%s: We wanted to %s, but the device wants us "
421                                 "to %s!\n", drive->name,
422                                 (ireason & ATAPI_IO) ? "Write" : "Read",
423                                 (ireason & ATAPI_IO) ? "Read" : "Write");
424                 return ide_do_reset(drive);
425         }
426
427         if (!(pc->flags & PC_FLAG_WRITING)) {
428                 /* Reading - Check that we have enough space */
429                 temp = pc->xferred + bcount;
430                 if (temp > pc->req_xfer) {
431                         if (temp > pc->buf_size) {
432                                 printk(KERN_ERR "%s: The device wants to send "
433                                                 "us more data than expected - "
434                                                 "discarding data\n",
435                                                 drive->name);
436                                 if (scsi)
437                                         temp = pc->buf_size - pc->xferred;
438                                 else
439                                         temp = 0;
440                                 if (temp) {
441                                         if (pc->sg)
442                                                 drive->pc_io_buffers(drive, pc,
443                                                                      temp, 0);
444                                         else
445                                                 tp_ops->input_data(drive, NULL,
446                                                         pc->cur_pos, temp);
447                                         printk(KERN_ERR "%s: transferred %d of "
448                                                         "%d bytes\n",
449                                                         drive->name,
450                                                         temp, bcount);
451                                 }
452                                 pc->xferred += temp;
453                                 pc->cur_pos += temp;
454                                 ide_pad_transfer(drive, 0, bcount - temp);
455                                 goto next_irq;
456                         }
457                         debug_log("The device wants to send us more data than "
458                                   "expected - allowing transfer\n");
459                 }
460                 xferfunc = tp_ops->input_data;
461         } else
462                 xferfunc = tp_ops->output_data;
463
464         if ((drive->media == ide_floppy && !scsi && !pc->buf) ||
465             (drive->media == ide_tape && !scsi && pc->bh) ||
466             (scsi && pc->sg)) {
467                 int done = drive->pc_io_buffers(drive, pc, bcount,
468                                   !!(pc->flags & PC_FLAG_WRITING));
469
470                 /* FIXME: don't do partial completions */
471                 if (drive->media == ide_floppy && !scsi)
472                         ide_end_request(drive, 1, done >> 9);
473         } else
474                 xferfunc(drive, NULL, pc->cur_pos, bcount);
475
476         /* Update the current position */
477         pc->xferred += bcount;
478         pc->cur_pos += bcount;
479
480         debug_log("[cmd %x] transferred %d bytes on that intr.\n",
481                   rq->cmd[0], bcount);
482 next_irq:
483         /* And set the interrupt handler again */
484         ide_set_handler(drive, ide_pc_intr, timeout, expiry);
485         return ide_started;
486 }
487
488 static u8 ide_read_ireason(ide_drive_t *drive)
489 {
490         ide_task_t task;
491
492         memset(&task, 0, sizeof(task));
493         task.tf_flags = IDE_TFLAG_IN_NSECT;
494
495         drive->hwif->tp_ops->tf_read(drive, &task);
496
497         return task.tf.nsect & 3;
498 }
499
500 static u8 ide_wait_ireason(ide_drive_t *drive, u8 ireason)
501 {
502         int retries = 100;
503
504         while (retries-- && ((ireason & ATAPI_COD) == 0 ||
505                 (ireason & ATAPI_IO))) {
506                 printk(KERN_ERR "%s: (IO,CoD != (0,1) while issuing "
507                                 "a packet command, retrying\n", drive->name);
508                 udelay(100);
509                 ireason = ide_read_ireason(drive);
510                 if (retries == 0) {
511                         printk(KERN_ERR "%s: (IO,CoD != (0,1) while issuing "
512                                         "a packet command, ignoring\n",
513                                         drive->name);
514                         ireason |= ATAPI_COD;
515                         ireason &= ~ATAPI_IO;
516                 }
517         }
518
519         return ireason;
520 }
521
522 static int ide_delayed_transfer_pc(ide_drive_t *drive)
523 {
524         /* Send the actual packet */
525         drive->hwif->tp_ops->output_data(drive, NULL, drive->pc->c, 12);
526
527         /* Timeout for the packet command */
528         return WAIT_FLOPPY_CMD;
529 }
530
531 static ide_startstop_t ide_transfer_pc(ide_drive_t *drive)
532 {
533         struct ide_atapi_pc *pc = drive->pc;
534         ide_hwif_t *hwif = drive->hwif;
535         struct request *rq = hwif->hwgroup->rq;
536         ide_expiry_t *expiry;
537         unsigned int timeout;
538         ide_startstop_t startstop;
539         u8 ireason;
540
541         if (ide_wait_stat(&startstop, drive, ATA_DRQ, ATA_BUSY, WAIT_READY)) {
542                 printk(KERN_ERR "%s: Strange, packet command initiated yet "
543                                 "DRQ isn't asserted\n", drive->name);
544                 return startstop;
545         }
546
547         if (drive->atapi_flags & IDE_AFLAG_DRQ_INTERRUPT) {
548                 if (drive->dma)
549                         drive->waiting_for_dma = 1;
550         }
551
552         ireason = ide_read_ireason(drive);
553         if (drive->media == ide_tape)
554                 ireason = ide_wait_ireason(drive, ireason);
555
556         if ((ireason & ATAPI_COD) == 0 || (ireason & ATAPI_IO)) {
557                 printk(KERN_ERR "%s: (IO,CoD) != (0,1) while issuing "
558                                 "a packet command\n", drive->name);
559                 return ide_do_reset(drive);
560         }
561
562         /*
563          * If necessary schedule the packet transfer to occur 'timeout'
564          * miliseconds later in ide_delayed_transfer_pc() after the device
565          * says it's ready for a packet.
566          */
567         if (drive->atapi_flags & IDE_AFLAG_ZIP_DRIVE) {
568                 timeout = drive->pc_delay;
569                 expiry = &ide_delayed_transfer_pc;
570         } else {
571                 timeout = (drive->media == ide_floppy) ? WAIT_FLOPPY_CMD
572                                                        : WAIT_TAPE_CMD;
573                 expiry = NULL;
574         }
575
576         /* Set the interrupt routine */
577         ide_set_handler(drive, ide_pc_intr, timeout, expiry);
578
579         /* Begin DMA, if necessary */
580         if (pc->flags & PC_FLAG_DMA_OK) {
581                 pc->flags |= PC_FLAG_DMA_IN_PROGRESS;
582                 hwif->dma_ops->dma_start(drive);
583         }
584
585         /* Send the actual packet */
586         if ((drive->atapi_flags & IDE_AFLAG_ZIP_DRIVE) == 0)
587                 hwif->tp_ops->output_data(drive, NULL, rq->cmd, 12);
588
589         return ide_started;
590 }
591
592 ide_startstop_t ide_issue_pc(ide_drive_t *drive, unsigned int timeout)
593 {
594         struct ide_atapi_pc *pc = drive->pc;
595         ide_hwif_t *hwif = drive->hwif;
596         ide_expiry_t *expiry = NULL;
597         u32 tf_flags;
598         u16 bcount;
599
600         /* We haven't transferred any data yet */
601         pc->xferred = 0;
602         pc->cur_pos = pc->buf;
603
604         if (dev_is_idecd(drive)) {
605                 tf_flags = IDE_TFLAG_OUT_NSECT | IDE_TFLAG_OUT_LBAL;
606                 bcount = ide_cd_get_xferlen(hwif->hwgroup->rq);
607                 expiry = ide_cd_expiry;
608         } else {
609                 tf_flags = IDE_TFLAG_OUT_DEVICE;
610                 bcount = ((drive->media == ide_tape) ?
611                                 pc->req_xfer :
612                                 min(pc->req_xfer, 63 * 1024));
613         }
614
615         if (pc->flags & PC_FLAG_DMA_ERROR) {
616                 pc->flags &= ~PC_FLAG_DMA_ERROR;
617                 ide_dma_off(drive);
618         }
619
620         if (((pc->flags & PC_FLAG_DMA_OK) &&
621                 (drive->dev_flags & IDE_DFLAG_USING_DMA)) ||
622             drive->dma)
623                 drive->dma = !hwif->dma_ops->dma_setup(drive);
624
625         if (!drive->dma)
626                 pc->flags &= ~PC_FLAG_DMA_OK;
627
628         ide_pktcmd_tf_load(drive, tf_flags, bcount, drive->dma);
629
630         /* Issue the packet command */
631         if (drive->atapi_flags & IDE_AFLAG_DRQ_INTERRUPT) {
632                 if (drive->dma)
633                         drive->waiting_for_dma = 0;
634                 ide_execute_command(drive, ATA_CMD_PACKET, ide_transfer_pc,
635                                     timeout, expiry);
636                 return ide_started;
637         } else {
638                 ide_execute_pkt_cmd(drive);
639                 return ide_transfer_pc(drive);
640         }
641 }
642 EXPORT_SYMBOL_GPL(ide_issue_pc);