Create a new helper function that encapsulates issuing a set of
channel stop commands, retrying if appropriate, with a short delay
between attempts.

Signed-off-by: Alex Elder <el...@linaro.org>
---
 drivers/net/ipa/gsi.c | 20 +++++++++++++++-----
 1 file changed, 15 insertions(+), 5 deletions(-)

diff --git a/drivers/net/ipa/gsi.c b/drivers/net/ipa/gsi.c
index 4a3e125e898f6..bd1bf388d9892 100644
--- a/drivers/net/ipa/gsi.c
+++ b/drivers/net/ipa/gsi.c
@@ -892,15 +892,12 @@ int gsi_channel_start(struct gsi *gsi, u32 channel_id)
        return ret;
 }
 
-/* Stop a started channel */
-int gsi_channel_stop(struct gsi *gsi, u32 channel_id)
+static int gsi_channel_stop_retry(struct gsi_channel *channel)
 {
-       struct gsi_channel *channel = &gsi->channel[channel_id];
        u32 retries = GSI_CHANNEL_STOP_RETRIES;
+       struct gsi *gsi = channel->gsi;
        int ret;
 
-       gsi_channel_freeze(channel);
-
        mutex_lock(&gsi->mutex);
 
        do {
@@ -912,6 +909,19 @@ int gsi_channel_stop(struct gsi *gsi, u32 channel_id)
 
        mutex_unlock(&gsi->mutex);
 
+       return ret;
+}
+
+/* Stop a started channel */
+int gsi_channel_stop(struct gsi *gsi, u32 channel_id)
+{
+       struct gsi_channel *channel = &gsi->channel[channel_id];
+       int ret;
+
+       gsi_channel_freeze(channel);
+
+       ret = gsi_channel_stop_retry(channel);
+
        /* Re-thaw the channel if an error occurred while stopping */
        if (ret)
                gsi_channel_thaw(channel);
-- 
2.27.0

Reply via email to