aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ata/libata-acpi.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/ata/libata-acpi.c')
-rw-r--r--drivers/ata/libata-acpi.c71
1 files changed, 0 insertions, 71 deletions
diff --git a/drivers/ata/libata-acpi.c b/drivers/ata/libata-acpi.c
index ef01ac07502e..446b4e761af0 100644
--- a/drivers/ata/libata-acpi.c
+++ b/drivers/ata/libata-acpi.c
@@ -974,57 +974,6 @@ void ata_acpi_on_disable(struct ata_device *dev)
974 ata_acpi_clear_gtf(dev); 974 ata_acpi_clear_gtf(dev);
975} 975}
976 976
977static void ata_acpi_wake_dev(acpi_handle handle, u32 event, void *context)
978{
979 struct ata_device *ata_dev = context;
980
981 if (event == ACPI_NOTIFY_DEVICE_WAKE && ata_dev &&
982 pm_runtime_suspended(&ata_dev->sdev->sdev_gendev))
983 scsi_autopm_get_device(ata_dev->sdev);
984}
985
986static void ata_acpi_add_pm_notifier(struct ata_device *dev)
987{
988 struct acpi_device *acpi_dev;
989 acpi_handle handle;
990 acpi_status status;
991
992 handle = ata_dev_acpi_handle(dev);
993 if (!handle)
994 return;
995
996 status = acpi_bus_get_device(handle, &acpi_dev);
997 if (ACPI_FAILURE(status))
998 return;
999
1000 if (dev->sdev->can_power_off) {
1001 acpi_install_notify_handler(handle, ACPI_SYSTEM_NOTIFY,
1002 ata_acpi_wake_dev, dev);
1003 device_set_run_wake(&dev->sdev->sdev_gendev, true);
1004 }
1005}
1006
1007static void ata_acpi_remove_pm_notifier(struct ata_device *dev)
1008{
1009 struct acpi_device *acpi_dev;
1010 acpi_handle handle;
1011 acpi_status status;
1012
1013 handle = ata_dev_acpi_handle(dev);
1014 if (!handle)
1015 return;
1016
1017 status = acpi_bus_get_device(handle, &acpi_dev);
1018 if (ACPI_FAILURE(status))
1019 return;
1020
1021 if (dev->sdev->can_power_off) {
1022 device_set_run_wake(&dev->sdev->sdev_gendev, false);
1023 acpi_remove_notify_handler(handle, ACPI_SYSTEM_NOTIFY,
1024 ata_acpi_wake_dev);
1025 }
1026}
1027
1028static void ata_acpi_register_power_resource(struct ata_device *dev) 977static void ata_acpi_register_power_resource(struct ata_device *dev)
1029{ 978{
1030 struct scsi_device *sdev = dev->sdev; 979 struct scsi_device *sdev = dev->sdev;
@@ -1057,13 +1006,11 @@ static void ata_acpi_unregister_power_resource(struct ata_device *dev)
1057 1006
1058void ata_acpi_bind(struct ata_device *dev) 1007void ata_acpi_bind(struct ata_device *dev)
1059{ 1008{
1060 ata_acpi_add_pm_notifier(dev);
1061 ata_acpi_register_power_resource(dev); 1009 ata_acpi_register_power_resource(dev);
1062} 1010}
1063 1011
1064void ata_acpi_unbind(struct ata_device *dev) 1012void ata_acpi_unbind(struct ata_device *dev)
1065{ 1013{
1066 ata_acpi_remove_pm_notifier(dev);
1067 ata_acpi_unregister_power_resource(dev); 1014 ata_acpi_unregister_power_resource(dev);
1068} 1015}
1069 1016
@@ -1105,9 +1052,6 @@ static int ata_acpi_bind_device(struct ata_port *ap, struct scsi_device *sdev,
1105 acpi_handle *handle) 1052 acpi_handle *handle)
1106{ 1053{
1107 struct ata_device *ata_dev; 1054 struct ata_device *ata_dev;
1108 acpi_status status;
1109 struct acpi_device *acpi_dev;
1110 struct acpi_device_power_state *states;
1111 1055
1112 if (ap->flags & ATA_FLAG_ACPI_SATA) { 1056 if (ap->flags & ATA_FLAG_ACPI_SATA) {
1113 if (!sata_pmp_attached(ap)) 1057 if (!sata_pmp_attached(ap))
@@ -1124,21 +1068,6 @@ static int ata_acpi_bind_device(struct ata_port *ap, struct scsi_device *sdev,
1124 if (!*handle) 1068 if (!*handle)
1125 return -ENODEV; 1069 return -ENODEV;
1126 1070
1127 status = acpi_bus_get_device(*handle, &acpi_dev);
1128 if (ACPI_FAILURE(status))
1129 return 0;
1130
1131 /*
1132 * If firmware has _PS3 or _PR3 for this device,
1133 * and this ata ODD device support device attention,
1134 * it means this device can be powered off
1135 */
1136 states = acpi_dev->power.states;
1137 if ((states[ACPI_STATE_D3_HOT].flags.valid ||
1138 states[ACPI_STATE_D3_COLD].flags.explicit_set) &&
1139 ata_dev->flags & ATA_DFLAG_DA)
1140 sdev->can_power_off = 1;
1141
1142 return 0; 1071 return 0;
1143} 1072}
1144 1073