Open Source Telephony
 help / color / mirror / Atom feed
* [PATCH v2 1/3] gprs: Check for LTE in gprs_attached_update
@ 2019-08-20 15:56 richard.rojfors
  2019-08-20 15:56 ` [PATCH v2 2/3] Revert "gprs: set driver_attached when activating automatic contexts" richard.rojfors
  2019-08-20 15:56 ` [PATCH v2 3/3] Revert "gprs: _cid_activated is an 'attaching' state" richard.rojfors
  0 siblings, 2 replies; 6+ messages in thread
From: richard.rojfors @ 2019-08-20 15:56 UTC (permalink / raw)
  To: ofono

[-- Attachment #1: Type: text/plain, Size: 3446 bytes --]

From: Richard Röjfors <richard@puffinpack.se>

Since we have a different condition for the attach state
when running on LTE, we should consider it in gprs_attached_update.
Previously it's done in some instances. But for instance if
the driver got detached from GPRS but now running on LTE with a
context up, we would be deattached.
---
 src/gprs.c | 51 ++++++++++++++++++++++++++++-----------------------
 1 file changed, 28 insertions(+), 23 deletions(-)

diff --git a/src/gprs.c b/src/gprs.c
index bba482cb..5829a577 100644
--- a/src/gprs.c
+++ b/src/gprs.c
@@ -1571,13 +1571,34 @@ static void release_active_contexts(struct ofono_gprs *gprs)
 	}
 }
 
+static gboolean on_lte(struct ofono_gprs *gprs)
+{
+	if (ofono_netreg_get_technology(gprs->netreg) ==
+			ACCESS_TECHNOLOGY_EUTRAN && have_read_settings(gprs))
+		return TRUE;
+
+	return FALSE;
+}
+
 static void gprs_attached_update(struct ofono_gprs *gprs)
 {
 	ofono_bool_t attached;
+	int status = gprs->status;
 
-	attached = gprs->driver_attached &&
-		(gprs->status == NETWORK_REGISTRATION_STATUS_REGISTERED ||
-			gprs->status == NETWORK_REGISTRATION_STATUS_ROAMING);
+	if (on_lte(gprs))
+		/*
+		 * For LTE we attached status reflects successful context
+		 * activation.
+		 * Since we in gprs_netreg_update not even try to attach
+		 * to GPRS if we are running on LTE, we can on some modems
+		 * expect the gprs status to be unknown. That must not
+		 * result in detaching...
+		 */
+		attached = have_active_contexts(gprs);
+	else
+		attached = gprs->driver_attached &&
+			(status == NETWORK_REGISTRATION_STATUS_REGISTERED ||
+				status == NETWORK_REGISTRATION_STATUS_ROAMING);
 
 	if (attached == gprs->attached)
 		return;
@@ -1591,11 +1612,13 @@ static void gprs_attached_update(struct ofono_gprs *gprs)
 	if (attached == FALSE) {
 		release_active_contexts(gprs);
 		gprs->bearer = -1;
-	} else if (have_active_contexts(gprs) == TRUE) {
+	} else if (have_active_contexts(gprs) == TRUE && !on_lte(gprs)) {
 		/*
 		 * Some times the context activates after a detach event and
 		 * right before an attach. We close it to avoid unexpected open
 		 * contexts.
+		 * Skip that for LTE since the condition to be attached on LTE
+		 * is that a context gets activated
 		 */
 		release_active_contexts(gprs);
 		gprs->flags |= GPRS_FLAG_ATTACHED_UPDATE;
@@ -1660,15 +1683,6 @@ static void gprs_netreg_removed(struct ofono_gprs *gprs)
 	gprs_attached_update(gprs);
 }
 
-static gboolean on_lte(struct ofono_gprs *gprs)
-{
-	if (ofono_netreg_get_technology(gprs->netreg) ==
-			ACCESS_TECHNOLOGY_EUTRAN && have_read_settings(gprs))
-		return TRUE;
-
-	return FALSE;
-}
-
 static void gprs_netreg_update(struct ofono_gprs *gprs)
 {
 	ofono_bool_t attach;
@@ -2573,16 +2587,7 @@ void ofono_gprs_status_notify(struct ofono_gprs *gprs, int status)
 
 	if (status != NETWORK_REGISTRATION_STATUS_REGISTERED &&
 			status != NETWORK_REGISTRATION_STATUS_ROAMING) {
-		/*
-		 * For LTE we attached status reflects successful context
-		 * activation.
-		 * Since we in gprs_netreg_update not even try to attach
-		 * to GPRS if we are running on LTE, we can on some modems
-		 * expect the gprs status to be unknown. That must not
-		 * result in detaching...
-		 */
-		if (!on_lte(gprs))
-			gprs_attached_update(gprs);
+		gprs_attached_update(gprs);
 		return;
 	}
 
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2019-08-21 18:30 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-08-20 15:56 [PATCH v2 1/3] gprs: Check for LTE in gprs_attached_update richard.rojfors
2019-08-20 15:56 ` [PATCH v2 2/3] Revert "gprs: set driver_attached when activating automatic contexts" richard.rojfors
2019-08-20 15:56 ` [PATCH v2 3/3] Revert "gprs: _cid_activated is an 'attaching' state" richard.rojfors
2019-08-21  6:01   ` Jonas Bonn
2019-08-21 15:55     ` Richard =?unknown-8bit?q?R=C3=B6jfors?=
2019-08-21 18:30     ` Denis Kenzior

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox