Lines 4099-4104
err_out:
Link Here
|
4099 |
} |
4099 |
} |
4100 |
|
4100 |
|
4101 |
|
4101 |
|
|
|
4102 |
/* |
4103 |
* Execute a 'simple' command, that only consists of the opcode 'cmd' itself, |
4104 |
* without filling any other registers |
4105 |
*/ |
4106 |
static int ata_do_simple_cmd(struct ata_port *ap, struct ata_device *dev, |
4107 |
u8 cmd) |
4108 |
{ |
4109 |
DECLARE_COMPLETION(wait); |
4110 |
struct ata_queued_cmd *qc; |
4111 |
unsigned long flags; |
4112 |
int rc; |
4113 |
|
4114 |
while ((qc = ata_qc_new_init(ap, dev)) == NULL) |
4115 |
msleep(10); |
4116 |
|
4117 |
qc->tf.command = cmd; |
4118 |
qc->tf.flags |= ATA_TFLAG_DEVICE; |
4119 |
qc->tf.protocol = ATA_PROT_NODATA; |
4120 |
|
4121 |
qc->waiting = &wait; |
4122 |
qc->complete_fn = ata_qc_complete_noop; |
4123 |
|
4124 |
spin_lock_irqsave(&ap->host_set->lock, flags); |
4125 |
rc = ata_qc_issue(qc); |
4126 |
spin_unlock_irqrestore(&ap->host_set->lock, flags); |
4127 |
|
4128 |
if (!rc) |
4129 |
wait_for_completion(&wait); |
4130 |
|
4131 |
return rc; |
4132 |
} |
4133 |
|
4134 |
static int ata_flush_cache(struct ata_port *ap, struct ata_device *dev) |
4135 |
{ |
4136 |
u8 cmd; |
4137 |
|
4138 |
if (!ata_try_flush_cache(dev)) |
4139 |
return 0; |
4140 |
|
4141 |
if (ata_id_has_flush_ext(dev->id)) |
4142 |
cmd = ATA_CMD_FLUSH_EXT; |
4143 |
else |
4144 |
cmd = ATA_CMD_FLUSH; |
4145 |
|
4146 |
return ata_do_simple_cmd(ap, dev, cmd); |
4147 |
} |
4148 |
|
4149 |
static int ata_standby_drive(struct ata_port *ap, struct ata_device *dev) |
4150 |
{ |
4151 |
return ata_do_simple_cmd(ap, dev, ATA_CMD_STANDBYNOW1); |
4152 |
} |
4153 |
|
4154 |
static int ata_start_drive(struct ata_port *ap, struct ata_device *dev) |
4155 |
{ |
4156 |
return ata_do_simple_cmd(ap, dev, ATA_CMD_IDLEIMMEDIATE); |
4157 |
} |
4158 |
|
4159 |
/** |
4160 |
* ata_device_resume - wakeup a previously suspended devices |
4161 |
* |
4162 |
* Kick the drive back into action, by sending it an idle immediate |
4163 |
* command and making sure its transfer mode matches between drive |
4164 |
* and host. |
4165 |
* |
4166 |
*/ |
4167 |
int ata_device_resume(struct ata_port *ap, struct ata_device *dev) |
4168 |
{ |
4169 |
if (ap->flags & ATA_FLAG_SUSPENDED) { |
4170 |
ap->flags &= ~ATA_FLAG_SUSPENDED; |
4171 |
ata_set_mode(ap); |
4172 |
} |
4173 |
if (!ata_dev_present(dev)) |
4174 |
return 0; |
4175 |
if (dev->class == ATA_DEV_ATA) |
4176 |
ata_start_drive(ap, dev); |
4177 |
|
4178 |
return 0; |
4179 |
} |
4180 |
|
4181 |
/** |
4182 |
* ata_device_suspend - prepare a device for suspend |
4183 |
* |
4184 |
* Flush the cache on the drive, if appropriate, then issue a |
4185 |
* standbynow command. |
4186 |
* |
4187 |
*/ |
4188 |
int ata_device_suspend(struct ata_port *ap, struct ata_device *dev) |
4189 |
{ |
4190 |
if (!ata_dev_present(dev)) |
4191 |
return 0; |
4192 |
if (dev->class == ATA_DEV_ATA) |
4193 |
ata_flush_cache(ap, dev); |
4194 |
|
4195 |
ata_standby_drive(ap, dev); |
4196 |
ap->flags |= ATA_FLAG_SUSPENDED; |
4197 |
return 0; |
4198 |
} |
4199 |
|
4102 |
/** |
4200 |
/** |
4103 |
* ata_port_start - Set port up for dma. |
4201 |
* ata_port_start - Set port up for dma. |
4104 |
* @ap: Port to initialize |
4202 |
* @ap: Port to initialize |
Lines 4860-4865
int pci_test_config_bits(struct pci_dev
Link Here
|
4860 |
|
4958 |
|
4861 |
return (tmp == bits->val) ? 1 : 0; |
4959 |
return (tmp == bits->val) ? 1 : 0; |
4862 |
} |
4960 |
} |
|
|
4961 |
|
4962 |
int ata_pci_device_suspend(struct pci_dev *pdev, pm_message_t state) |
4963 |
{ |
4964 |
pci_save_state(pdev); |
4965 |
pci_disable_device(pdev); |
4966 |
pci_set_power_state(pdev, PCI_D3hot); |
4967 |
return 0; |
4968 |
} |
4969 |
|
4970 |
int ata_pci_device_resume(struct pci_dev *pdev) |
4971 |
{ |
4972 |
pci_set_power_state(pdev, PCI_D0); |
4973 |
pci_restore_state(pdev); |
4974 |
pci_enable_device(pdev); |
4975 |
pci_set_master(pdev); |
4976 |
return 0; |
4977 |
} |
4863 |
#endif /* CONFIG_PCI */ |
4978 |
#endif /* CONFIG_PCI */ |
4864 |
|
4979 |
|
4865 |
|
4980 |
|
Lines 4963-4966
EXPORT_SYMBOL_GPL(ata_pci_host_stop);
Link Here
|
4963 |
EXPORT_SYMBOL_GPL(ata_pci_init_native_mode); |
5078 |
EXPORT_SYMBOL_GPL(ata_pci_init_native_mode); |
4964 |
EXPORT_SYMBOL_GPL(ata_pci_init_one); |
5079 |
EXPORT_SYMBOL_GPL(ata_pci_init_one); |
4965 |
EXPORT_SYMBOL_GPL(ata_pci_remove_one); |
5080 |
EXPORT_SYMBOL_GPL(ata_pci_remove_one); |
|
|
5081 |
EXPORT_SYMBOL_GPL(ata_pci_device_suspend); |
5082 |
EXPORT_SYMBOL_GPL(ata_pci_device_resume); |
4966 |
#endif /* CONFIG_PCI */ |
5083 |
#endif /* CONFIG_PCI */ |
|
|
5084 |
|
5085 |
EXPORT_SYMBOL_GPL(ata_device_suspend); |
5086 |
EXPORT_SYMBOL_GPL(ata_device_resume); |
5087 |
EXPORT_SYMBOL_GPL(ata_scsi_device_suspend); |
5088 |
EXPORT_SYMBOL_GPL(ata_scsi_device_resume); |