diff mbox series

[v2,2/2] qmimodem: Default embedded modems endpoint ID

Message ID 20240408213453.53910-2-steve.schrock@getcruise.com (mailing list archive)
State Accepted
Commit 6d7edaf5bc5a17f1c7974024b9c139a3fea6ac93
Headers show
Series [v2,1/2] udevng: Detect embedded qmi QRTR modems | expand

Commit Message

Steve Schrock April 8, 2024, 9:34 p.m. UTC
Embedded QMI QRTR modems use an endpoint ID of 1. This will not be set
by udevng, so gprs-context must handle this case.
---
 drivers/qmimodem/gprs-context.c | 32 +++++++++++++++++---------------
 1 file changed, 17 insertions(+), 15 deletions(-)
diff mbox series

Patch

diff --git a/drivers/qmimodem/gprs-context.c b/drivers/qmimodem/gprs-context.c
index fb2069020833..33565252028c 100644
--- a/drivers/qmimodem/gprs-context.c
+++ b/drivers/qmimodem/gprs-context.c
@@ -376,21 +376,6 @@  static void qmi_gprs_context_bind_mux(struct ofono_gprs_context *gc)
 	} __attribute__((packed)) endpoint_info;
 	uint8_t u8;
 
-	interface_number = ofono_modem_get_string(modem, "InterfaceNumber");
-	if (!interface_number) {
-		ofono_error("%s: Missing 'InterfaceNumber'",
-					ofono_modem_get_path(modem));
-		goto error;
-	}
-
-	if (l_safe_atox8(interface_number, &u8) < 0) {
-		ofono_error("%s: Invalid InterfaceNumber",
-					ofono_modem_get_path(modem));
-		goto error;
-	}
-
-	endpoint_info.interface_number = u8;
-
 	bus = ofono_modem_get_string(modem, "Bus");
 	if (!bus) {
 		ofono_error("%s: Missing 'Bus'", ofono_modem_get_path(modem));
@@ -409,6 +394,23 @@  static void qmi_gprs_context_bind_mux(struct ofono_gprs_context *gc)
 		goto error;
 	}
 
+	interface_number = ofono_modem_get_string(modem, "InterfaceNumber");
+	if (!interface_number && endpoint_info.endpoint_type !=
+					QMI_DATA_ENDPOINT_TYPE_EMBEDDED) {
+		ofono_error("%s: Missing 'InterfaceNumber'",
+					ofono_modem_get_path(modem));
+		goto error;
+	} else if (!interface_number)
+		u8 = 1;	/* Default for embedded modems */
+	else if (l_safe_atox8(interface_number, &u8) < 0) {
+		ofono_error("%s: Invalid InterfaceNumber",
+					ofono_modem_get_path(modem));
+		goto error;
+	}
+
+	endpoint_info.interface_number = u8;
+
+	DBG("interface_number: %d", u8);
 	DBG("mux_id: %hhx", data->mux_id);
 
 	param = qmi_param_new();