|
Lines 3632-3637
Link Here
|
| 3632 |
* LOCKING: |
3632 |
* LOCKING: |
| 3633 |
*/ |
3633 |
*/ |
| 3634 |
|
3634 |
|
|
|
3635 |
/* |
| 3636 |
* Execute a 'simple' command, that only consists of the opcode 'cmd' itself, |
| 3637 |
* without filling any other registers |
| 3638 |
*/ |
| 3639 |
static int ata_do_simple_cmd(struct ata_port *ap, struct ata_device *dev, |
| 3640 |
u8 cmd) |
| 3641 |
{ |
| 3642 |
DECLARE_COMPLETION(wait); |
| 3643 |
struct ata_queued_cmd *qc; |
| 3644 |
unsigned long flags; |
| 3645 |
int rc; |
| 3646 |
|
| 3647 |
qc = ata_qc_new_init(ap, dev); |
| 3648 |
BUG_ON(qc == NULL); |
| 3649 |
|
| 3650 |
qc->tf.command = cmd; |
| 3651 |
qc->tf.flags |= ATA_TFLAG_DEVICE; |
| 3652 |
qc->tf.protocol = ATA_PROT_NODATA; |
| 3653 |
|
| 3654 |
qc->waiting = &wait; |
| 3655 |
qc->complete_fn = ata_qc_complete_noop; |
| 3656 |
|
| 3657 |
spin_lock_irqsave(&ap->host_set->lock, flags); |
| 3658 |
rc = ata_qc_issue(qc); |
| 3659 |
spin_unlock_irqrestore(&ap->host_set->lock, flags); |
| 3660 |
|
| 3661 |
if (!rc) |
| 3662 |
wait_for_completion(&wait); |
| 3663 |
|
| 3664 |
return rc; |
| 3665 |
} |
| 3666 |
|
| 3667 |
static int ata_flush_cache(struct ata_port *ap, struct ata_device *dev) |
| 3668 |
{ |
| 3669 |
u8 cmd; |
| 3670 |
|
| 3671 |
if (!ata_try_flush_cache(dev)) |
| 3672 |
return 0; |
| 3673 |
|
| 3674 |
if (ata_id_has_flush_ext(dev->id)) |
| 3675 |
cmd = ATA_CMD_FLUSH_EXT; |
| 3676 |
else |
| 3677 |
cmd = ATA_CMD_FLUSH; |
| 3678 |
|
| 3679 |
return ata_do_simple_cmd(ap, dev, cmd); |
| 3680 |
} |
| 3681 |
|
| 3682 |
static int ata_standby_drive(struct ata_port *ap, struct ata_device *dev) |
| 3683 |
{ |
| 3684 |
return ata_do_simple_cmd(ap, dev, ATA_CMD_STANDBYNOW1); |
| 3685 |
} |
| 3686 |
|
| 3687 |
static int ata_start_drive(struct ata_port *ap, struct ata_device *dev) |
| 3688 |
{ |
| 3689 |
return ata_do_simple_cmd(ap, dev, ATA_CMD_IDLEIMMEDIATE); |
| 3690 |
} |
| 3691 |
|
| 3692 |
/** |
| 3693 |
* ata_device_resume - wakeup a previously suspended devices |
| 3694 |
* |
| 3695 |
* Kick the drive back into action, by sending it an idle immediate |
| 3696 |
* command and making sure its transfer mode matches between drive |
| 3697 |
* and host. |
| 3698 |
* |
| 3699 |
*/ |
| 3700 |
int ata_device_resume(struct ata_port *ap, struct ata_device *dev) |
| 3701 |
{ |
| 3702 |
if (ap->flags & ATA_FLAG_SUSPENDED) { |
| 3703 |
ap->flags &= ~ATA_FLAG_SUSPENDED; |
| 3704 |
ata_set_mode(ap); |
| 3705 |
} |
| 3706 |
if (!ata_dev_present(dev)) |
| 3707 |
return 0; |
| 3708 |
if (dev->class == ATA_DEV_ATA) |
| 3709 |
ata_start_drive(ap, dev); |
| 3710 |
|
| 3711 |
return 0; |
| 3712 |
} |
| 3713 |
|
| 3714 |
/** |
| 3715 |
* ata_device_suspend - prepare a device for suspend |
| 3716 |
* |
| 3717 |
* Flush the cache on the drive, if appropriate, then issue a |
| 3718 |
* standbynow command. |
| 3719 |
* |
| 3720 |
*/ |
| 3721 |
int ata_device_suspend(struct ata_port *ap, struct ata_device *dev) |
| 3722 |
{ |
| 3723 |
if (!ata_dev_present(dev)) |
| 3724 |
return 0; |
| 3725 |
if (dev->class == ATA_DEV_ATA) |
| 3726 |
ata_flush_cache(ap, dev); |
| 3727 |
|
| 3728 |
ata_standby_drive(ap, dev); |
| 3729 |
ap->flags |= ATA_FLAG_SUSPENDED; |
| 3730 |
return 0; |
| 3731 |
} |
| 3732 |
|
| 3635 |
int ata_port_start (struct ata_port *ap) |
3733 |
int ata_port_start (struct ata_port *ap) |
| 3636 |
{ |
3734 |
{ |
| 3637 |
struct device *dev = ap->host_set->dev; |
3735 |
struct device *dev = ap->host_set->dev; |
|
Lines 4337-4342
Link Here
|
| 4337 |
|
4435 |
|
| 4338 |
return (tmp == bits->val) ? 1 : 0; |
4436 |
return (tmp == bits->val) ? 1 : 0; |
| 4339 |
} |
4437 |
} |
|
|
4438 |
|
| 4439 |
int ata_pci_device_suspend(struct pci_dev *pdev, pm_message_t state) |
| 4440 |
{ |
| 4441 |
pci_save_state(pdev); |
| 4442 |
pci_disable_device(pdev); |
| 4443 |
pci_set_power_state(pdev, PCI_D3hot); |
| 4444 |
return 0; |
| 4445 |
} |
| 4446 |
|
| 4447 |
int ata_pci_device_resume(struct pci_dev *pdev) |
| 4448 |
{ |
| 4449 |
pci_set_power_state(pdev, PCI_D0); |
| 4450 |
pci_restore_state(pdev); |
| 4451 |
pci_enable_device(pdev); |
| 4452 |
pci_set_master(pdev); |
| 4453 |
return 0; |
| 4454 |
} |
| 4340 |
#endif /* CONFIG_PCI */ |
4455 |
#endif /* CONFIG_PCI */ |
| 4341 |
|
4456 |
|
| 4342 |
|
4457 |
|
|
Lines 4413-4416
Link Here
|
| 4413 |
EXPORT_SYMBOL_GPL(ata_pci_init_native_mode); |
4528 |
EXPORT_SYMBOL_GPL(ata_pci_init_native_mode); |
| 4414 |
EXPORT_SYMBOL_GPL(ata_pci_init_one); |
4529 |
EXPORT_SYMBOL_GPL(ata_pci_init_one); |
| 4415 |
EXPORT_SYMBOL_GPL(ata_pci_remove_one); |
4530 |
EXPORT_SYMBOL_GPL(ata_pci_remove_one); |
|
|
4531 |
EXPORT_SYMBOL_GPL(ata_pci_device_suspend); |
| 4532 |
EXPORT_SYMBOL_GPL(ata_pci_device_resume); |
| 4416 |
#endif /* CONFIG_PCI */ |
4533 |
#endif /* CONFIG_PCI */ |
|
|
4534 |
|
| 4535 |
EXPORT_SYMBOL_GPL(ata_device_suspend); |
| 4536 |
EXPORT_SYMBOL_GPL(ata_device_resume); |
| 4537 |
EXPORT_SYMBOL_GPL(ata_scsi_device_suspend); |
| 4538 |
EXPORT_SYMBOL_GPL(ata_scsi_device_resume); |