]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
Merge remote-tracking branch 'libata/NEXT'
authorStephen Rothwell <sfr@canb.auug.org.au>
Wed, 25 Jul 2012 00:19:53 +0000 (10:19 +1000)
committerStephen Rothwell <sfr@canb.auug.org.au>
Wed, 25 Jul 2012 00:19:57 +0000 (10:19 +1000)
1  2 
drivers/acpi/power.c
drivers/acpi/sleep.c
drivers/ata/libata-acpi.c

Simple merge
index 1cc02ca2af2a5c9243a639d4a0f3ea3aeb3424d3,1784cb30e7cf239444e17292fab365012aa9a46c..028dd425702c0b83b73990093a10c323d6bb24c0
@@@ -796,19 -791,11 +796,20 @@@ int acpi_pm_device_sleep_state(struct d
                }
        }
  
 +      if (d_max_in < d_min)
 +              return -EINVAL;
        if (d_min_p)
                *d_min_p = d_min;
 +      /* constrain d_max with specified lowest limit (max number) */
 +      if (d_max > d_max_in) {
 +              for (d_max = d_max_in; d_max > d_min; d_max--) {
 +                      if (adev->power.states[d_max].flags.valid)
 +                              break;
 +              }
 +      }
        return d_max;
  }
+ EXPORT_SYMBOL(acpi_pm_device_sleep_state);
  #endif /* CONFIG_PM */
  
  #ifdef CONFIG_PM_SLEEP
index bb7c5f1085ccdfa997671520afc87c4f887eed39,4112eaa0621f1225171ab1176e339d447f02d694..a2b16c9c91f43b96065be632d128a9fc77cb7757
@@@ -913,17 -858,34 +858,34 @@@ void ata_acpi_set_state(struct ata_por
  
        /* channel first and then drives for power on and vica versa
           for power off */
-       if (state.event == PM_EVENT_ON)
-               acpi_bus_set_power(ap->acpi_handle, ACPI_STATE_D0);
+       handle = ata_ap_acpi_handle(ap);
+       if (handle && state.event == PM_EVENT_ON)
+               acpi_bus_set_power(handle, ACPI_STATE_D0);
  
        ata_for_each_dev(dev, &ap->link, ENABLED) {
-               if (dev->acpi_handle)
-                       acpi_bus_set_power(dev->acpi_handle,
-                               state.event == PM_EVENT_ON ?
-                                       ACPI_STATE_D0 : ACPI_STATE_D3);
+               handle = ata_dev_acpi_handle(dev);
+               if (!handle)
+                       continue;
+               if (state.event != PM_EVENT_ON) {
+                       acpi_state = acpi_pm_device_sleep_state(
 -                              &dev->sdev->sdev_gendev, NULL);
++                              &dev->sdev->sdev_gendev, NULL, ACPI_STATE_D3);
+                       if (acpi_state > 0)
+                               acpi_bus_set_power(handle, acpi_state);
+                       /* TBD: need to check if it's runtime pm request */
+                       acpi_pm_device_run_wake(
+                               &dev->sdev->sdev_gendev, true);
+               } else {
+                       /* Ditto */
+                       acpi_pm_device_run_wake(
+                               &dev->sdev->sdev_gendev, false);
+                       acpi_bus_set_power(handle, ACPI_STATE_D0);
+               }
        }
-       if (state.event != PM_EVENT_ON)
-               acpi_bus_set_power(ap->acpi_handle, ACPI_STATE_D3);
+       handle = ata_ap_acpi_handle(ap);
+       if (handle && state.event != PM_EVENT_ON)
+               acpi_bus_set_power(handle, ACPI_STATE_D3);
  }
  
  /**