@@ -257,7 +257,7 @@ static void ahci_platform_put_resources(struct device *dev, void *res)
257257 int c ;
258258
259259 if (hpriv -> got_runtime_pm ) {
260- pm_runtime_put_sync (dev );
260+ pm_runtime_allow (dev );
261261 pm_runtime_disable (dev );
262262 }
263263
@@ -475,8 +475,10 @@ struct ahci_host_priv *ahci_platform_get_resources(struct platform_device *pdev)
475475 if (rc == - EPROBE_DEFER )
476476 goto err_out ;
477477 }
478+
479+ pm_runtime_set_active (dev );
478480 pm_runtime_enable (dev );
479- pm_runtime_get_sync (dev );
481+ pm_runtime_forbid (dev );
480482 hpriv -> got_runtime_pm = true;
481483
482484 devres_remove_group (dev , NULL );
@@ -705,6 +707,21 @@ int ahci_platform_resume_host(struct device *dev)
705707}
706708EXPORT_SYMBOL_GPL (ahci_platform_resume_host );
707709
710+ static int _ahci_platform_suspend (struct device * dev )
711+ {
712+ struct ata_host * host = dev_get_drvdata (dev );
713+ struct ahci_host_priv * hpriv = host -> private_data ;
714+ int rc ;
715+
716+ rc = ahci_platform_suspend_host (dev );
717+ if (rc )
718+ return rc ;
719+
720+ ahci_platform_disable_resources (hpriv );
721+
722+ return 0 ;
723+ }
724+
708725/**
709726 * ahci_platform_suspend - Suspend an ahci-platform device
710727 * @dev: the platform device to suspend
@@ -716,20 +733,45 @@ EXPORT_SYMBOL_GPL(ahci_platform_resume_host);
716733 * 0 on success otherwise a negative error code
717734 */
718735int ahci_platform_suspend (struct device * dev )
736+ {
737+ return _ahci_platform_suspend (dev );
738+ }
739+ EXPORT_SYMBOL_GPL (ahci_platform_suspend );
740+
741+ /**
742+ * ahci_platform_runtime_suspend - Runtime suspend an ahci-platform device
743+ * @dev: the platform device to suspend
744+ *
745+ * This function suspends the host associated with the device, followed by
746+ * disabling all the resources of the device.
747+ *
748+ * RETURNS:
749+ * 0 on success otherwise a negative error code
750+ */
751+ int ahci_platform_runtime_suspend (struct device * dev )
752+ {
753+ return _ahci_platform_suspend (dev );
754+ }
755+ EXPORT_SYMBOL_GPL (ahci_platform_runtime_suspend );
756+
757+ static int _ahci_platform_resume (struct device * dev )
719758{
720759 struct ata_host * host = dev_get_drvdata (dev );
721760 struct ahci_host_priv * hpriv = host -> private_data ;
722761 int rc ;
723762
724- rc = ahci_platform_suspend_host ( dev );
763+ rc = ahci_platform_enable_resources ( hpriv );
725764 if (rc )
726765 return rc ;
727766
728- ahci_platform_disable_resources (hpriv );
767+ rc = ahci_platform_resume_host (dev );
768+ if (rc ) {
769+ ahci_platform_disable_resources (hpriv );
770+ return rc ;
771+ }
729772
730773 return 0 ;
731774}
732- EXPORT_SYMBOL_GPL (ahci_platform_suspend );
733775
734776/**
735777 * ahci_platform_resume - Resume an ahci-platform device
@@ -743,31 +785,37 @@ EXPORT_SYMBOL_GPL(ahci_platform_suspend);
743785 */
744786int ahci_platform_resume (struct device * dev )
745787{
746- struct ata_host * host = dev_get_drvdata (dev );
747- struct ahci_host_priv * hpriv = host -> private_data ;
748788 int rc ;
749789
750- rc = ahci_platform_enable_resources ( hpriv );
790+ rc = _ahci_platform_resume ( dev );
751791 if (rc )
752792 return rc ;
753793
754- rc = ahci_platform_resume_host (dev );
755- if (rc )
756- goto disable_resources ;
757-
758794 /* We resumed so update PM runtime state */
759795 pm_runtime_disable (dev );
760796 pm_runtime_set_active (dev );
761797 pm_runtime_enable (dev );
762798
763799 return 0 ;
764-
765- disable_resources :
766- ahci_platform_disable_resources (hpriv );
767-
768- return rc ;
769800}
770801EXPORT_SYMBOL_GPL (ahci_platform_resume );
802+
803+ /**
804+ * ahci_platform_runtime_resume - Runtime resume an ahci-platform device
805+ * @dev: the platform device to resume
806+ *
807+ * This function enables all the resources of the device followed by
808+ * resuming the host associated with the device.
809+ *
810+ * RETURNS:
811+ * 0 on success otherwise a negative error code
812+ */
813+ int ahci_platform_runtime_resume (struct device * dev )
814+ {
815+ return _ahci_platform_resume (dev );
816+ }
817+ EXPORT_SYMBOL_GPL (ahci_platform_runtime_resume );
818+
771819#endif
772820
773821MODULE_DESCRIPTION ("AHCI SATA platform library" );
0 commit comments