[PATCH net-next 1/5] net: ipa: don't use ipa_clock_get() in "ipa_main.c"

From: Alex Elder
Date: Thu Aug 19 2021 - 18:19:40 EST


We need the hardware to be powered starting at the config stage of
initialization when the IPA driver probes. And we need it powered
when the driver is removed, at least until the deconfig stage has
completed.

Replace callers of ipa_clock_get() in ipa_probe() and ipa_exit(),
calling pm_runtime_get_sync() instead. Replace the corresponding
callers of ipa_clock_put(), calling pm_runtime_put() instead.

The only error we expect when getting power would occur when the
system is suspended. The ->probe and ->remove driver callbacks
won't be called when suspended, so issue a WARN() call if an error
is seen getting power.

Signed-off-by: Alex Elder <elder@xxxxxxxxxx>
---
drivers/net/ipa/ipa_main.c | 21 +++++++++++----------
1 file changed, 11 insertions(+), 10 deletions(-)

diff --git a/drivers/net/ipa/ipa_main.c b/drivers/net/ipa/ipa_main.c
index 69fa4b3120fd3..3969aef6c4370 100644
--- a/drivers/net/ipa/ipa_main.c
+++ b/drivers/net/ipa/ipa_main.c
@@ -15,6 +15,7 @@
#include <linux/of.h>
#include <linux/of_device.h>
#include <linux/of_address.h>
+#include <linux/pm_runtime.h>
#include <linux/qcom_scm.h>
#include <linux/soc/qcom/mdt_loader.h>

@@ -737,13 +738,13 @@ static int ipa_probe(struct platform_device *pdev)
goto err_table_exit;

/* The clock needs to be active for config and setup */
- ret = ipa_clock_get(ipa);
+ ret = pm_runtime_get_sync(dev);
if (WARN_ON(ret < 0))
- goto err_clock_put;
+ goto err_power_put;

ret = ipa_config(ipa, data);
if (ret)
- goto err_clock_put;
+ goto err_power_put;

dev_info(dev, "IPA driver initialized");

@@ -765,14 +766,14 @@ static int ipa_probe(struct platform_device *pdev)
if (ret)
goto err_deconfig;
done:
- (void)ipa_clock_put(ipa);
+ (void)pm_runtime_put(dev);

return 0;

err_deconfig:
ipa_deconfig(ipa);
-err_clock_put:
- (void)ipa_clock_put(ipa);
+err_power_put:
+ (void)pm_runtime_put(dev);
ipa_modem_exit(ipa);
err_table_exit:
ipa_table_exit(ipa);
@@ -798,9 +799,9 @@ static int ipa_remove(struct platform_device *pdev)
struct ipa_clock *clock = ipa->clock;
int ret;

- ret = ipa_clock_get(ipa);
+ ret = pm_runtime_get_sync(&pdev->dev);
if (WARN_ON(ret < 0))
- goto out_clock_put;
+ goto out_power_put;

if (ipa->setup_complete) {
ret = ipa_modem_stop(ipa);
@@ -816,8 +817,8 @@ static int ipa_remove(struct platform_device *pdev)
}

ipa_deconfig(ipa);
-out_clock_put:
- (void)ipa_clock_put(ipa);
+out_power_put:
+ (void)pm_runtime_put(&pdev->dev);

ipa_modem_exit(ipa);
ipa_table_exit(ipa);
--
2.27.0