--- zzzz-none-000/linux-3.10.107/drivers/ata/libata-zpodd.c 2017-06-27 09:49:32.000000000 +0000 +++ scorpion-7490-727/linux-3.10.107/drivers/ata/libata-zpodd.c 2021-02-04 17:41:59.000000000 +0000 @@ -2,6 +2,7 @@ #include #include #include +#include #include #include "libata.h" @@ -84,23 +85,6 @@ return ODD_MECH_TYPE_UNSUPPORTED; } -static bool odd_can_poweroff(struct ata_device *ata_dev) -{ - acpi_handle handle; - acpi_status status; - struct acpi_device *acpi_dev; - - handle = ata_dev_acpi_handle(ata_dev); - if (!handle) - return false; - - status = acpi_bus_get_device(handle, &acpi_dev); - if (ACPI_FAILURE(status)) - return false; - - return acpi_device_can_poweroff(acpi_dev); -} - /* Test if ODD is zero power ready by sense code */ static bool zpready(struct ata_device *dev) { @@ -190,8 +174,8 @@ sdev_disable_disk_events(dev->sdev); zpodd->powered_off = true; - device_set_run_wake(&dev->sdev->sdev_gendev, true); - acpi_pm_device_run_wake(&dev->sdev->sdev_gendev, true); + device_set_run_wake(&dev->tdev, true); + acpi_pm_device_run_wake(&dev->tdev, true); } /* Disable runtime wake capability if it is enabled */ @@ -200,8 +184,8 @@ struct zpodd *zpodd = dev->zpodd; if (zpodd->powered_off) { - acpi_pm_device_run_wake(&dev->sdev->sdev_gendev, false); - device_set_run_wake(&dev->sdev->sdev_gendev, false); + acpi_pm_device_run_wake(&dev->tdev, false); + device_set_run_wake(&dev->tdev, false); } } @@ -262,19 +246,17 @@ static void ata_acpi_remove_pm_notifier(struct ata_device *dev) { - acpi_handle handle = DEVICE_ACPI_HANDLE(&dev->sdev->sdev_gendev); + acpi_handle handle = ata_dev_acpi_handle(dev); acpi_remove_notify_handler(handle, ACPI_SYSTEM_NOTIFY, zpodd_wake_dev); } void zpodd_init(struct ata_device *dev) { + struct acpi_device *adev = ACPI_COMPANION(&dev->tdev); enum odd_mech_type mech_type; struct zpodd *zpodd; - if (dev->zpodd) - return; - - if (!odd_can_poweroff(dev)) + if (dev->zpodd || !adev || !acpi_device_can_poweroff(adev)) return; mech_type = zpodd_get_mech_type(dev); @@ -290,6 +272,7 @@ ata_acpi_add_pm_notifier(dev); zpodd->dev = dev; dev->zpodd = zpodd; + dev_pm_qos_expose_flags(&dev->tdev, 0); } void zpodd_exit(struct ata_device *dev)