summaryrefslogtreecommitdiff
path: root/drivers/net/ipa/ipa_modem.c
diff options
context:
space:
mode:
authorAlex Elder <elder@linaro.org>2021-08-10 14:26:58 -0500
committerDavid S. Miller <davem@davemloft.net>2021-08-11 13:31:55 +0100
commit7ebd168c3bfc3ebf113545170c2bb28d02f0ba15 (patch)
treed3e3d328ea10b9e964b5bd72ff2a965f029d6937 /drivers/net/ipa/ipa_modem.c
parent6f45933dfed0c1d90c2d9acfe6b782c5560ee038 (diff)
net: ipa: have ipa_clock_get() return a value
We currently assume no errors occur when enabling or disabling the IPA core clock and interconnects. And although this commit exposes errors that could occur, we generally assume this won't happen in practice. This commit changes ipa_clock_get() and ipa_clock_put() so each returns a value. The values returned are meant to mimic what the runtime power management functions return, so we can set up error handling here before we make the switch. Have ipa_clock_get() increment the reference count even if it returns an error, to match the behavior of pm_runtime_get(). More details follow. When taking a reference in ipa_clock_get(), return 0 for the first reference, 1 for subsequent references, or a negative error code if an error occurs. Note that if ipa_clock_get() returns an error, we must not touch hardware; in some cases such errors now cause entire blocks of code to be skipped. When dropping a reference in ipa_clock_put(), we return 0 or an error code. The error would come from ipa_clock_disable(), which now returns what ipa_interconnect_disable() returns (either 0 or a negative error code). For now, callers ignore the return value; if an error occurs, a message will have already been logged, and little more can actually be done to improve the situation. Signed-off-by: Alex Elder <elder@linaro.org> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/ipa/ipa_modem.c')
-rw-r--r--drivers/net/ipa/ipa_modem.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/drivers/net/ipa/ipa_modem.c b/drivers/net/ipa/ipa_modem.c
index ad4019e8016e..06e44afd2cf6 100644
--- a/drivers/net/ipa/ipa_modem.c
+++ b/drivers/net/ipa/ipa_modem.c
@@ -45,7 +45,9 @@ static int ipa_open(struct net_device *netdev)
struct ipa *ipa = priv->ipa;
int ret;
- ipa_clock_get(ipa);
+ ret = ipa_clock_get(ipa);
+ if (WARN_ON(ret < 0))
+ goto err_clock_put;
ret = ipa_endpoint_enable_one(ipa->name_map[IPA_ENDPOINT_AP_MODEM_TX]);
if (ret)
@@ -62,7 +64,7 @@ static int ipa_open(struct net_device *netdev)
err_disable_tx:
ipa_endpoint_disable_one(ipa->name_map[IPA_ENDPOINT_AP_MODEM_TX]);
err_clock_put:
- ipa_clock_put(ipa);
+ (void)ipa_clock_put(ipa);
return ret;
}
@@ -78,7 +80,7 @@ static int ipa_stop(struct net_device *netdev)
ipa_endpoint_disable_one(ipa->name_map[IPA_ENDPOINT_AP_MODEM_RX]);
ipa_endpoint_disable_one(ipa->name_map[IPA_ENDPOINT_AP_MODEM_TX]);
- ipa_clock_put(ipa);
+ (void)ipa_clock_put(ipa);
return 0;
}
@@ -297,7 +299,9 @@ static void ipa_modem_crashed(struct ipa *ipa)
struct device *dev = &ipa->pdev->dev;
int ret;
- ipa_clock_get(ipa);
+ ret = ipa_clock_get(ipa);
+ if (WARN_ON(ret < 0))
+ goto out_clock_put;
ipa_endpoint_modem_pause_all(ipa, true);
@@ -324,7 +328,8 @@ static void ipa_modem_crashed(struct ipa *ipa)
if (ret)
dev_err(dev, "error %d zeroing modem memory regions\n", ret);
- ipa_clock_put(ipa);
+out_clock_put:
+ (void)ipa_clock_put(ipa);
}
static int ipa_modem_notify(struct notifier_block *nb, unsigned long action,