OSDN Git Service

net: ipa: move IPA power operations to ipa_clock.c
authorAlex Elder <elder@linaro.org>
Wed, 4 Aug 2021 15:36:24 +0000 (10:36 -0500)
committerDavid S. Miller <davem@davemloft.net>
Thu, 5 Aug 2021 10:27:05 +0000 (11:27 +0100)
Move ipa_suspend() and ipa_resume(), as well as the definition of
the ipa_pm_ops structure into "ipa_clock.c".  Make ipa_pm_ops public
and declare it as extern in "ipa_clock.h".

This is part of centralizing IPA power management functionality into
"ipa_clock.c" (the file will eventually get a name change).

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ipa/ipa_clock.c
drivers/net/ipa/ipa_clock.h
drivers/net/ipa/ipa_main.c

index 849b6ec..475ea63 100644 (file)
@@ -9,9 +9,12 @@
 #include <linux/clk.h>
 #include <linux/device.h>
 #include <linux/interconnect.h>
+#include <linux/pm.h>
+#include <linux/bitops.h>
 
 #include "ipa.h"
 #include "ipa_clock.h"
+#include "ipa_endpoint.h"
 #include "ipa_modem.h"
 #include "ipa_data.h"
 
@@ -334,3 +337,62 @@ void ipa_clock_exit(struct ipa_clock *clock)
        kfree(clock);
        clk_put(clk);
 }
+
+/**
+ * ipa_suspend() - Power management system suspend callback
+ * @dev:       IPA device structure
+ *
+ * Return:     Always returns zero
+ *
+ * Called by the PM framework when a system suspend operation is invoked.
+ * Suspends endpoints and releases the clock reference held to keep
+ * the IPA clock running until this point.
+ */
+static int ipa_suspend(struct device *dev)
+{
+       struct ipa *ipa = dev_get_drvdata(dev);
+
+       /* Endpoints aren't usable until setup is complete */
+       if (ipa->setup_complete) {
+               __clear_bit(IPA_FLAG_RESUMED, ipa->flags);
+               ipa_endpoint_suspend(ipa);
+               gsi_suspend(&ipa->gsi);
+       }
+
+       ipa_clock_put(ipa);
+
+       return 0;
+}
+
+/**
+ * ipa_resume() - Power management system resume callback
+ * @dev:       IPA device structure
+ *
+ * Return:     Always returns 0
+ *
+ * Called by the PM framework when a system resume operation is invoked.
+ * Takes an IPA clock reference to keep the clock running until suspend,
+ * and resumes endpoints.
+ */
+static int ipa_resume(struct device *dev)
+{
+       struct ipa *ipa = dev_get_drvdata(dev);
+
+       /* This clock reference will keep the IPA out of suspend
+        * until we get a power management suspend request.
+        */
+       ipa_clock_get(ipa);
+
+       /* Endpoints aren't usable until setup is complete */
+       if (ipa->setup_complete) {
+               gsi_resume(&ipa->gsi);
+               ipa_endpoint_resume(ipa);
+       }
+
+       return 0;
+}
+
+const struct dev_pm_ops ipa_pm_ops = {
+       .suspend        = ipa_suspend,
+       .resume         = ipa_resume,
+};
index 1fe6347..2f0310d 100644 (file)
@@ -11,6 +11,9 @@ struct device;
 struct ipa;
 struct ipa_clock_data;
 
+/* IPA device power management function block */
+extern const struct dev_pm_ops ipa_pm_ops;
+
 /**
  * ipa_clock_rate() - Return the current IPA core clock rate
  * @ipa:       IPA structure
index ae51109..28350b7 100644 (file)
@@ -874,65 +874,6 @@ static void ipa_shutdown(struct platform_device *pdev)
                dev_err(&pdev->dev, "shutdown: remove returned %d\n", ret);
 }
 
-/**
- * ipa_suspend() - Power management system suspend callback
- * @dev:       IPA device structure
- *
- * Return:     Always returns zero
- *
- * Called by the PM framework when a system suspend operation is invoked.
- * Suspends endpoints and releases the clock reference held to keep
- * the IPA clock running until this point.
- */
-static int ipa_suspend(struct device *dev)
-{
-       struct ipa *ipa = dev_get_drvdata(dev);
-
-       /* Endpoints aren't usable until setup is complete */
-       if (ipa->setup_complete) {
-               __clear_bit(IPA_FLAG_RESUMED, ipa->flags);
-               ipa_endpoint_suspend(ipa);
-               gsi_suspend(&ipa->gsi);
-       }
-
-       ipa_clock_put(ipa);
-
-       return 0;
-}
-
-/**
- * ipa_resume() - Power management system resume callback
- * @dev:       IPA device structure
- *
- * Return:     Always returns 0
- *
- * Called by the PM framework when a system resume operation is invoked.
- * Takes an IPA clock reference to keep the clock running until suspend,
- * and resumes endpoints.
- */
-static int ipa_resume(struct device *dev)
-{
-       struct ipa *ipa = dev_get_drvdata(dev);
-
-       /* This clock reference will keep the IPA out of suspend
-        * until we get a power management suspend request.
-        */
-       ipa_clock_get(ipa);
-
-       /* Endpoints aren't usable until setup is complete */
-       if (ipa->setup_complete) {
-               gsi_resume(&ipa->gsi);
-               ipa_endpoint_resume(ipa);
-       }
-
-       return 0;
-}
-
-static const struct dev_pm_ops ipa_pm_ops = {
-       .suspend        = ipa_suspend,
-       .resume         = ipa_resume,
-};
-
 static const struct attribute_group *ipa_attribute_groups[] = {
        &ipa_attribute_group,
        &ipa_feature_attribute_group,