Commit 4900bf34 authored by Alex Elder's avatar Alex Elder Committed by David S. Miller

net: ipa: have ipa_endpoint_init_ctrl() return previous state

Change ipa_endpoint_init_ctrl() so it returns the previous state
(whether suspend or delay mode was enabled) rather than indicating
whether the request caused a change in state.  This makes it easier
to understand what's happening where called.
Signed-off-by: default avatarAlex Elder <elder@linaro.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 9c729e74
...@@ -284,11 +284,12 @@ static struct gsi_trans *ipa_endpoint_trans_alloc(struct ipa_endpoint *endpoint, ...@@ -284,11 +284,12 @@ static struct gsi_trans *ipa_endpoint_trans_alloc(struct ipa_endpoint *endpoint,
/* suspend_delay represents suspend for RX, delay for TX endpoints. /* suspend_delay represents suspend for RX, delay for TX endpoints.
* Note that suspend is not supported starting with IPA v4.0. * Note that suspend is not supported starting with IPA v4.0.
*/ */
static int static bool
ipa_endpoint_init_ctrl(struct ipa_endpoint *endpoint, bool suspend_delay) ipa_endpoint_init_ctrl(struct ipa_endpoint *endpoint, bool suspend_delay)
{ {
u32 offset = IPA_REG_ENDP_INIT_CTRL_N_OFFSET(endpoint->endpoint_id); u32 offset = IPA_REG_ENDP_INIT_CTRL_N_OFFSET(endpoint->endpoint_id);
struct ipa *ipa = endpoint->ipa; struct ipa *ipa = endpoint->ipa;
bool state;
u32 mask; u32 mask;
u32 val; u32 val;
...@@ -296,13 +297,14 @@ ipa_endpoint_init_ctrl(struct ipa_endpoint *endpoint, bool suspend_delay) ...@@ -296,13 +297,14 @@ ipa_endpoint_init_ctrl(struct ipa_endpoint *endpoint, bool suspend_delay)
mask = endpoint->toward_ipa ? ENDP_DELAY_FMASK : ENDP_SUSPEND_FMASK; mask = endpoint->toward_ipa ? ENDP_DELAY_FMASK : ENDP_SUSPEND_FMASK;
val = ioread32(ipa->reg_virt + offset); val = ioread32(ipa->reg_virt + offset);
if (suspend_delay == !!(val & mask)) /* Don't bother if it's already in the requested state */
return -EALREADY; /* Already set to desired state */ state = !!(val & mask);
if (suspend_delay != state) {
val ^= mask; val ^= mask;
iowrite32(val, ipa->reg_virt + offset); iowrite32(val, ipa->reg_virt + offset);
}
return 0; return state;
} }
/* Enable or disable delay or suspend mode on all modem endpoints */ /* Enable or disable delay or suspend mode on all modem endpoints */
...@@ -1164,8 +1166,7 @@ static int ipa_endpoint_reset_rx_aggr(struct ipa_endpoint *endpoint) ...@@ -1164,8 +1166,7 @@ static int ipa_endpoint_reset_rx_aggr(struct ipa_endpoint *endpoint)
/* Make sure the channel isn't suspended */ /* Make sure the channel isn't suspended */
if (endpoint->ipa->version == IPA_VERSION_3_5_1) if (endpoint->ipa->version == IPA_VERSION_3_5_1)
if (!ipa_endpoint_init_ctrl(endpoint, false)) endpoint_suspended = ipa_endpoint_init_ctrl(endpoint, false);
endpoint_suspended = true;
/* Start channel and do a 1 byte read */ /* Start channel and do a 1 byte read */
ret = gsi_channel_start(gsi, endpoint->channel_id); ret = gsi_channel_start(gsi, endpoint->channel_id);
...@@ -1318,21 +1319,20 @@ static void ipa_endpoint_program(struct ipa_endpoint *endpoint) ...@@ -1318,21 +1319,20 @@ static void ipa_endpoint_program(struct ipa_endpoint *endpoint)
if (endpoint->toward_ipa) { if (endpoint->toward_ipa) {
bool delay_mode = endpoint->data->tx.delay; bool delay_mode = endpoint->data->tx.delay;
ret = ipa_endpoint_init_ctrl(endpoint, delay_mode);
/* Endpoint is expected to not be in delay mode */ /* Endpoint is expected to not be in delay mode */
if (!ret != delay_mode) { if (ipa_endpoint_init_ctrl(endpoint, delay_mode))
dev_warn(dev, dev_warn(dev,
"TX endpoint %u was %sin delay mode\n", "TX endpoint %u was %sin delay mode\n",
endpoint->endpoint_id, endpoint->endpoint_id,
delay_mode ? "already " : ""); delay_mode ? "already " : "");
}
ipa_endpoint_init_hdr_ext(endpoint); ipa_endpoint_init_hdr_ext(endpoint);
ipa_endpoint_init_aggr(endpoint); ipa_endpoint_init_aggr(endpoint);
ipa_endpoint_init_deaggr(endpoint); ipa_endpoint_init_deaggr(endpoint);
ipa_endpoint_init_seq(endpoint); ipa_endpoint_init_seq(endpoint);
} else { } else {
/* Endpoint is expected to not be suspended */
if (endpoint->ipa->version == IPA_VERSION_3_5_1) { if (endpoint->ipa->version == IPA_VERSION_3_5_1) {
if (!ipa_endpoint_init_ctrl(endpoint, false)) if (ipa_endpoint_init_ctrl(endpoint, false))
dev_warn(dev, dev_warn(dev,
"RX endpoint %u was suspended\n", "RX endpoint %u was suspended\n",
endpoint->endpoint_id); endpoint->endpoint_id);
...@@ -1471,7 +1471,7 @@ void ipa_endpoint_resume_one(struct ipa_endpoint *endpoint) ...@@ -1471,7 +1471,7 @@ void ipa_endpoint_resume_one(struct ipa_endpoint *endpoint)
/* IPA v3.5.1 doesn't use channel start for resume */ /* IPA v3.5.1 doesn't use channel start for resume */
start_channel = endpoint->ipa->version != IPA_VERSION_3_5_1; start_channel = endpoint->ipa->version != IPA_VERSION_3_5_1;
if (!endpoint->toward_ipa && !start_channel) if (!endpoint->toward_ipa && !start_channel)
WARN_ON(ipa_endpoint_init_ctrl(endpoint, false)); WARN_ON(!ipa_endpoint_init_ctrl(endpoint, false));
ret = gsi_channel_resume(gsi, endpoint->channel_id, start_channel); ret = gsi_channel_resume(gsi, endpoint->channel_id, start_channel);
if (ret) if (ret)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment