diff options
author | Albert Lee <albertcc@tw.ibm.com> | 2005-10-04 06:03:45 -0400 |
---|---|---|
committer | Jeff Garzik <jgarzik@pobox.com> | 2005-10-04 06:03:45 -0400 |
commit | c71c18576d0d8aa4db876c737c3c597c724cf02f (patch) | |
tree | f485f9f6491275eded41098a09eaf16ac43f3afc /drivers/scsi/libata-core.c | |
parent | 0fbbbf2bde4da5cb01a949c3d7b21c0627f520a8 (diff) |
libata: move atapi_send_cdb() and ata_dataout_task()
to be near ata_pio_*() functions
Diffstat (limited to 'drivers/scsi/libata-core.c')
-rw-r--r-- | drivers/scsi/libata-core.c | 217 |
1 files changed, 108 insertions, 109 deletions
diff --git a/drivers/scsi/libata-core.c b/drivers/scsi/libata-core.c index 546336802579..ff291b365108 100644 --- a/drivers/scsi/libata-core.c +++ b/drivers/scsi/libata-core.c | |||
@@ -2782,6 +2782,114 @@ static void ata_pio_sector(struct ata_queued_cmd *qc) | |||
2782 | } | 2782 | } |
2783 | 2783 | ||
2784 | /** | 2784 | /** |
2785 | * atapi_send_cdb - Write CDB bytes to hardware | ||
2786 | * @ap: Port to which ATAPI device is attached. | ||
2787 | * @qc: Taskfile currently active | ||
2788 | * | ||
2789 | * When device has indicated its readiness to accept | ||
2790 | * a CDB, this function is called. Send the CDB. | ||
2791 | * | ||
2792 | * LOCKING: | ||
2793 | * caller. | ||
2794 | */ | ||
2795 | |||
2796 | static void atapi_send_cdb(struct ata_port *ap, struct ata_queued_cmd *qc) | ||
2797 | { | ||
2798 | /* send SCSI cdb */ | ||
2799 | DPRINTK("send cdb\n"); | ||
2800 | assert(ap->cdb_len >= 12); | ||
2801 | |||
2802 | ata_data_xfer(ap, qc->cdb, ap->cdb_len, 1); | ||
2803 | ata_altstatus(ap); /* flush */ | ||
2804 | |||
2805 | switch (qc->tf.protocol) { | ||
2806 | case ATA_PROT_ATAPI: | ||
2807 | ap->hsm_task_state = HSM_ST; | ||
2808 | break; | ||
2809 | case ATA_PROT_ATAPI_NODATA: | ||
2810 | ap->hsm_task_state = HSM_ST_LAST; | ||
2811 | break; | ||
2812 | case ATA_PROT_ATAPI_DMA: | ||
2813 | ap->hsm_task_state = HSM_ST_LAST; | ||
2814 | /* initiate bmdma */ | ||
2815 | ap->ops->bmdma_start(qc); | ||
2816 | break; | ||
2817 | } | ||
2818 | } | ||
2819 | |||
2820 | /** | ||
2821 | * ata_dataout_task - Write first data block to hardware | ||
2822 | * @_data: Port to which ATA/ATAPI device is attached. | ||
2823 | * | ||
2824 | * When device has indicated its readiness to accept | ||
2825 | * the data, this function sends out the CDB or | ||
2826 | * the first data block by PIO. | ||
2827 | * After this, | ||
2828 | * - If polling, ata_pio_task() handles the rest. | ||
2829 | * - Otherwise, interrupt handler takes over. | ||
2830 | * | ||
2831 | * LOCKING: | ||
2832 | * Kernel thread context (may sleep) | ||
2833 | */ | ||
2834 | |||
2835 | static void ata_dataout_task(void *_data) | ||
2836 | { | ||
2837 | struct ata_port *ap = _data; | ||
2838 | struct ata_queued_cmd *qc; | ||
2839 | u8 status; | ||
2840 | unsigned long flags; | ||
2841 | |||
2842 | qc = ata_qc_from_tag(ap, ap->active_tag); | ||
2843 | assert(qc != NULL); | ||
2844 | assert(qc->flags & ATA_QCFLAG_ACTIVE); | ||
2845 | |||
2846 | /* sleep-wait for BSY to clear */ | ||
2847 | DPRINTK("busy wait\n"); | ||
2848 | if (ata_busy_sleep(ap, ATA_TMOUT_DATAOUT_QUICK, ATA_TMOUT_DATAOUT)) | ||
2849 | goto err_out; | ||
2850 | |||
2851 | /* make sure DRQ is set */ | ||
2852 | status = ata_chk_status(ap); | ||
2853 | if ((status & (ATA_BUSY | ATA_DRQ)) != ATA_DRQ) | ||
2854 | goto err_out; | ||
2855 | |||
2856 | /* Send the CDB (atapi) or the first data block (ata pio out). | ||
2857 | * During the state transition, interrupt handler shouldn't | ||
2858 | * be invoked before the data transfer is complete and | ||
2859 | * hsm_task_state is changed. Hence, the following locking. | ||
2860 | */ | ||
2861 | spin_lock_irqsave(&ap->host_set->lock, flags); | ||
2862 | |||
2863 | if (qc->tf.protocol == ATA_PROT_PIO) { | ||
2864 | /* PIO data out protocol. | ||
2865 | * send first data block. | ||
2866 | */ | ||
2867 | |||
2868 | /* ata_pio_sector() might change the state to HSM_ST_LAST. | ||
2869 | * so, the state is changed here before ata_pio_sector(). | ||
2870 | */ | ||
2871 | ap->hsm_task_state = HSM_ST; | ||
2872 | ata_pio_sector(qc); | ||
2873 | ata_altstatus(ap); /* flush */ | ||
2874 | } else | ||
2875 | /* send CDB */ | ||
2876 | atapi_send_cdb(ap, qc); | ||
2877 | |||
2878 | /* if polling, ata_pio_task() handles the rest. | ||
2879 | * otherwise, interrupt handler takes over from here. | ||
2880 | */ | ||
2881 | if (qc->tf.flags & ATA_TFLAG_POLLING) | ||
2882 | queue_work(ata_wq, &ap->pio_task); | ||
2883 | |||
2884 | spin_unlock_irqrestore(&ap->host_set->lock, flags); | ||
2885 | |||
2886 | return; | ||
2887 | |||
2888 | err_out: | ||
2889 | ata_pio_error(ap); | ||
2890 | } | ||
2891 | |||
2892 | /** | ||
2785 | * __atapi_pio_bytes - Transfer data from/to the ATAPI device. | 2893 | * __atapi_pio_bytes - Transfer data from/to the ATAPI device. |
2786 | * @qc: Command on going | 2894 | * @qc: Command on going |
2787 | * @bytes: number of bytes | 2895 | * @bytes: number of bytes |
@@ -3785,42 +3893,6 @@ void ata_bmdma_stop(struct ata_queued_cmd *qc) | |||
3785 | } | 3893 | } |
3786 | 3894 | ||
3787 | /** | 3895 | /** |
3788 | * atapi_send_cdb - Write CDB bytes to hardware | ||
3789 | * @ap: Port to which ATAPI device is attached. | ||
3790 | * @qc: Taskfile currently active | ||
3791 | * | ||
3792 | * When device has indicated its readiness to accept | ||
3793 | * a CDB, this function is called. Send the CDB. | ||
3794 | * | ||
3795 | * LOCKING: | ||
3796 | * caller. | ||
3797 | */ | ||
3798 | |||
3799 | static void atapi_send_cdb(struct ata_port *ap, struct ata_queued_cmd *qc) | ||
3800 | { | ||
3801 | /* send SCSI cdb */ | ||
3802 | DPRINTK("send cdb\n"); | ||
3803 | assert(ap->cdb_len >= 12); | ||
3804 | |||
3805 | ata_data_xfer(ap, qc->cdb, ap->cdb_len, 1); | ||
3806 | ata_altstatus(ap); /* flush */ | ||
3807 | |||
3808 | switch (qc->tf.protocol) { | ||
3809 | case ATA_PROT_ATAPI: | ||
3810 | ap->hsm_task_state = HSM_ST; | ||
3811 | break; | ||
3812 | case ATA_PROT_ATAPI_NODATA: | ||
3813 | ap->hsm_task_state = HSM_ST_LAST; | ||
3814 | break; | ||
3815 | case ATA_PROT_ATAPI_DMA: | ||
3816 | ap->hsm_task_state = HSM_ST_LAST; | ||
3817 | /* initiate bmdma */ | ||
3818 | ap->ops->bmdma_start(qc); | ||
3819 | break; | ||
3820 | } | ||
3821 | } | ||
3822 | |||
3823 | /** | ||
3824 | * ata_host_intr - Handle host interrupt for given (port, task) | 3896 | * ata_host_intr - Handle host interrupt for given (port, task) |
3825 | * @ap: Port on which interrupt arrived (possibly...) | 3897 | * @ap: Port on which interrupt arrived (possibly...) |
3826 | * @qc: Taskfile currently active in engine | 3898 | * @qc: Taskfile currently active in engine |
@@ -4042,79 +4114,6 @@ irqreturn_t ata_interrupt (int irq, void *dev_instance, struct pt_regs *regs) | |||
4042 | } | 4114 | } |
4043 | 4115 | ||
4044 | /** | 4116 | /** |
4045 | * ata_dataout_task - Write first data block to hardware | ||
4046 | * @_data: Port to which ATA/ATAPI device is attached. | ||
4047 | * | ||
4048 | * When device has indicated its readiness to accept | ||
4049 | * the data, this function sends out the CDB or | ||
4050 | * the first data block by PIO. | ||
4051 | * After this, | ||
4052 | * - If polling, ata_pio_task() handles the rest. | ||
4053 | * - Otherwise, interrupt handler takes over. | ||
4054 | * | ||
4055 | * LOCKING: | ||
4056 | * Kernel thread context (may sleep) | ||
4057 | */ | ||
4058 | |||
4059 | static void ata_dataout_task(void *_data) | ||
4060 | { | ||
4061 | struct ata_port *ap = _data; | ||
4062 | struct ata_queued_cmd *qc; | ||
4063 | u8 status; | ||
4064 | unsigned long flags; | ||
4065 | |||
4066 | qc = ata_qc_from_tag(ap, ap->active_tag); | ||
4067 | assert(qc != NULL); | ||
4068 | assert(qc->flags & ATA_QCFLAG_ACTIVE); | ||
4069 | |||
4070 | /* sleep-wait for BSY to clear */ | ||
4071 | DPRINTK("busy wait\n"); | ||
4072 | if (ata_busy_sleep(ap, ATA_TMOUT_DATAOUT_QUICK, ATA_TMOUT_DATAOUT)) | ||
4073 | goto err_out; | ||
4074 | |||
4075 | /* make sure DRQ is set */ | ||
4076 | status = ata_chk_status(ap); | ||
4077 | if ((status & (ATA_BUSY | ATA_DRQ)) != ATA_DRQ) | ||
4078 | goto err_out; | ||
4079 | |||
4080 | /* Send the CDB (atapi) or the first data block (ata pio out). | ||
4081 | * During the state transition, interrupt handler shouldn't | ||
4082 | * be invoked before the data transfer is complete and | ||
4083 | * hsm_task_state is changed. Hence, the following locking. | ||
4084 | */ | ||
4085 | spin_lock_irqsave(&ap->host_set->lock, flags); | ||
4086 | |||
4087 | if (qc->tf.protocol == ATA_PROT_PIO) { | ||
4088 | /* PIO data out protocol. | ||
4089 | * send first data block. | ||
4090 | */ | ||
4091 | |||
4092 | /* ata_pio_sector() might change the state to HSM_ST_LAST. | ||
4093 | * so, the state is changed here before ata_pio_sector(). | ||
4094 | */ | ||
4095 | ap->hsm_task_state = HSM_ST; | ||
4096 | ata_pio_sector(qc); | ||
4097 | ata_altstatus(ap); /* flush */ | ||
4098 | } else | ||
4099 | /* send CDB */ | ||
4100 | atapi_send_cdb(ap, qc); | ||
4101 | |||
4102 | /* if polling, ata_pio_task() handles the rest. | ||
4103 | * otherwise, interrupt handler takes over from here. | ||
4104 | */ | ||
4105 | if (qc->tf.flags & ATA_TFLAG_POLLING) | ||
4106 | queue_work(ata_wq, &ap->pio_task); | ||
4107 | |||
4108 | spin_unlock_irqrestore(&ap->host_set->lock, flags); | ||
4109 | |||
4110 | return; | ||
4111 | |||
4112 | err_out: | ||
4113 | ata_pio_error(ap); | ||
4114 | } | ||
4115 | |||
4116 | |||
4117 | /** | ||
4118 | * ata_port_start - Set port up for dma. | 4117 | * ata_port_start - Set port up for dma. |
4119 | * @ap: Port to initialize | 4118 | * @ap: Port to initialize |
4120 | * | 4119 | * |