diff options
author | Jeff Garzik <jgarzik@pobox.com> | 2005-10-30 21:37:17 -0500 |
---|---|---|
committer | Jeff Garzik <jgarzik@pobox.com> | 2005-10-30 21:37:17 -0500 |
commit | e533825447dcb60a82b7cc9d73d06423c849b9a2 (patch) | |
tree | c838f16f023e24118a0e5669b2dbcfb70f666504 /drivers | |
parent | 6e9d6b8ee4e0c37d3952256e6472c57490d6780d (diff) |
[libata] ata_tf_to_host cleanups
Integrate ata_exec() and ata_tf_to_host() into their only caller,
ata_bus_edd().
Rename ata_tf_to_host_nolock() to ata_tf_to_host().
This makes locking a bit easier to review, and may help pave the way for
future changes.
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/scsi/libata-core.c | 57 | ||||
-rw-r--r-- | drivers/scsi/libata.h | 1 |
2 files changed, 10 insertions, 48 deletions
diff --git a/drivers/scsi/libata-core.c b/drivers/scsi/libata-core.c index 8be7dc0b47b8..a17e12032f65 100644 --- a/drivers/scsi/libata-core.c +++ b/drivers/scsi/libata-core.c | |||
@@ -295,28 +295,6 @@ void ata_exec_command(struct ata_port *ap, const struct ata_taskfile *tf) | |||
295 | } | 295 | } |
296 | 296 | ||
297 | /** | 297 | /** |
298 | * ata_exec - issue ATA command to host controller | ||
299 | * @ap: port to which command is being issued | ||
300 | * @tf: ATA taskfile register set | ||
301 | * | ||
302 | * Issues PIO/MMIO write to ATA command register, with proper | ||
303 | * synchronization with interrupt handler / other threads. | ||
304 | * | ||
305 | * LOCKING: | ||
306 | * Obtains host_set lock. | ||
307 | */ | ||
308 | |||
309 | static inline void ata_exec(struct ata_port *ap, const struct ata_taskfile *tf) | ||
310 | { | ||
311 | unsigned long flags; | ||
312 | |||
313 | DPRINTK("ata%u: cmd 0x%X\n", ap->id, tf->command); | ||
314 | spin_lock_irqsave(&ap->host_set->lock, flags); | ||
315 | ap->ops->exec_command(ap, tf); | ||
316 | spin_unlock_irqrestore(&ap->host_set->lock, flags); | ||
317 | } | ||
318 | |||
319 | /** | ||
320 | * ata_tf_to_host - issue ATA taskfile to host controller | 298 | * ata_tf_to_host - issue ATA taskfile to host controller |
321 | * @ap: port to which command is being issued | 299 | * @ap: port to which command is being issued |
322 | * @tf: ATA taskfile register set | 300 | * @tf: ATA taskfile register set |
@@ -326,30 +304,11 @@ static inline void ata_exec(struct ata_port *ap, const struct ata_taskfile *tf) | |||
326 | * other threads. | 304 | * other threads. |
327 | * | 305 | * |
328 | * LOCKING: | 306 | * LOCKING: |
329 | * Obtains host_set lock. | ||
330 | */ | ||
331 | |||
332 | static void ata_tf_to_host(struct ata_port *ap, const struct ata_taskfile *tf) | ||
333 | { | ||
334 | ap->ops->tf_load(ap, tf); | ||
335 | |||
336 | ata_exec(ap, tf); | ||
337 | } | ||
338 | |||
339 | /** | ||
340 | * ata_tf_to_host_nolock - issue ATA taskfile to host controller | ||
341 | * @ap: port to which command is being issued | ||
342 | * @tf: ATA taskfile register set | ||
343 | * | ||
344 | * Issues ATA taskfile register set to ATA host controller, | ||
345 | * with proper synchronization with interrupt handler and | ||
346 | * other threads. | ||
347 | * | ||
348 | * LOCKING: | ||
349 | * spin_lock_irqsave(host_set lock) | 307 | * spin_lock_irqsave(host_set lock) |
350 | */ | 308 | */ |
351 | 309 | ||
352 | void ata_tf_to_host_nolock(struct ata_port *ap, const struct ata_taskfile *tf) | 310 | static inline void ata_tf_to_host(struct ata_port *ap, |
311 | const struct ata_taskfile *tf) | ||
353 | { | 312 | { |
354 | ap->ops->tf_load(ap, tf); | 313 | ap->ops->tf_load(ap, tf); |
355 | ap->ops->exec_command(ap, tf); | 314 | ap->ops->exec_command(ap, tf); |
@@ -1912,12 +1871,14 @@ static void ata_bus_post_reset(struct ata_port *ap, unsigned int devmask) | |||
1912 | * | 1871 | * |
1913 | * LOCKING: | 1872 | * LOCKING: |
1914 | * PCI/etc. bus probe sem. | 1873 | * PCI/etc. bus probe sem. |
1874 | * Obtains host_set lock. | ||
1915 | * | 1875 | * |
1916 | */ | 1876 | */ |
1917 | 1877 | ||
1918 | static unsigned int ata_bus_edd(struct ata_port *ap) | 1878 | static unsigned int ata_bus_edd(struct ata_port *ap) |
1919 | { | 1879 | { |
1920 | struct ata_taskfile tf; | 1880 | struct ata_taskfile tf; |
1881 | unsigned long flags; | ||
1921 | 1882 | ||
1922 | /* set up execute-device-diag (bus reset) taskfile */ | 1883 | /* set up execute-device-diag (bus reset) taskfile */ |
1923 | /* also, take interrupts to a known state (disabled) */ | 1884 | /* also, take interrupts to a known state (disabled) */ |
@@ -1928,7 +1889,9 @@ static unsigned int ata_bus_edd(struct ata_port *ap) | |||
1928 | tf.protocol = ATA_PROT_NODATA; | 1889 | tf.protocol = ATA_PROT_NODATA; |
1929 | 1890 | ||
1930 | /* do bus reset */ | 1891 | /* do bus reset */ |
1892 | spin_lock_irqsave(&ap->host_set->lock, flags); | ||
1931 | ata_tf_to_host(ap, &tf); | 1893 | ata_tf_to_host(ap, &tf); |
1894 | spin_unlock_irqrestore(&ap->host_set->lock, flags); | ||
1932 | 1895 | ||
1933 | /* spec says at least 2ms. but who knows with those | 1896 | /* spec says at least 2ms. but who knows with those |
1934 | * crazy ATAPI devices... | 1897 | * crazy ATAPI devices... |
@@ -3555,7 +3518,7 @@ int ata_qc_issue_prot(struct ata_queued_cmd *qc) | |||
3555 | 3518 | ||
3556 | switch (qc->tf.protocol) { | 3519 | switch (qc->tf.protocol) { |
3557 | case ATA_PROT_NODATA: | 3520 | case ATA_PROT_NODATA: |
3558 | ata_tf_to_host_nolock(ap, &qc->tf); | 3521 | ata_tf_to_host(ap, &qc->tf); |
3559 | break; | 3522 | break; |
3560 | 3523 | ||
3561 | case ATA_PROT_DMA: | 3524 | case ATA_PROT_DMA: |
@@ -3566,20 +3529,20 @@ int ata_qc_issue_prot(struct ata_queued_cmd *qc) | |||
3566 | 3529 | ||
3567 | case ATA_PROT_PIO: /* load tf registers, initiate polling pio */ | 3530 | case ATA_PROT_PIO: /* load tf registers, initiate polling pio */ |
3568 | ata_qc_set_polling(qc); | 3531 | ata_qc_set_polling(qc); |
3569 | ata_tf_to_host_nolock(ap, &qc->tf); | 3532 | ata_tf_to_host(ap, &qc->tf); |
3570 | ap->hsm_task_state = HSM_ST; | 3533 | ap->hsm_task_state = HSM_ST; |
3571 | queue_work(ata_wq, &ap->pio_task); | 3534 | queue_work(ata_wq, &ap->pio_task); |
3572 | break; | 3535 | break; |
3573 | 3536 | ||
3574 | case ATA_PROT_ATAPI: | 3537 | case ATA_PROT_ATAPI: |
3575 | ata_qc_set_polling(qc); | 3538 | ata_qc_set_polling(qc); |
3576 | ata_tf_to_host_nolock(ap, &qc->tf); | 3539 | ata_tf_to_host(ap, &qc->tf); |
3577 | queue_work(ata_wq, &ap->packet_task); | 3540 | queue_work(ata_wq, &ap->packet_task); |
3578 | break; | 3541 | break; |
3579 | 3542 | ||
3580 | case ATA_PROT_ATAPI_NODATA: | 3543 | case ATA_PROT_ATAPI_NODATA: |
3581 | ap->flags |= ATA_FLAG_NOINTR; | 3544 | ap->flags |= ATA_FLAG_NOINTR; |
3582 | ata_tf_to_host_nolock(ap, &qc->tf); | 3545 | ata_tf_to_host(ap, &qc->tf); |
3583 | queue_work(ata_wq, &ap->packet_task); | 3546 | queue_work(ata_wq, &ap->packet_task); |
3584 | break; | 3547 | break; |
3585 | 3548 | ||
diff --git a/drivers/scsi/libata.h b/drivers/scsi/libata.h index 10ecd9e15e4f..fad051ca4672 100644 --- a/drivers/scsi/libata.h +++ b/drivers/scsi/libata.h | |||
@@ -48,7 +48,6 @@ extern int ata_qc_issue(struct ata_queued_cmd *qc); | |||
48 | extern int ata_check_atapi_dma(struct ata_queued_cmd *qc); | 48 | extern int ata_check_atapi_dma(struct ata_queued_cmd *qc); |
49 | extern void ata_dev_select(struct ata_port *ap, unsigned int device, | 49 | extern void ata_dev_select(struct ata_port *ap, unsigned int device, |
50 | unsigned int wait, unsigned int can_sleep); | 50 | unsigned int wait, unsigned int can_sleep); |
51 | extern void ata_tf_to_host_nolock(struct ata_port *ap, const struct ata_taskfile *tf); | ||
52 | extern void swap_buf_le16(u16 *buf, unsigned int buf_words); | 51 | extern void swap_buf_le16(u16 *buf, unsigned int buf_words); |
53 | extern int ata_task_ioctl(struct scsi_device *scsidev, void __user *arg); | 52 | extern int ata_task_ioctl(struct scsi_device *scsidev, void __user *arg); |
54 | extern int ata_cmd_ioctl(struct scsi_device *scsidev, void __user *arg); | 53 | extern int ata_cmd_ioctl(struct scsi_device *scsidev, void __user *arg); |