diff mbox series

[v2,33/33] qmi: non-premultiplexed MHI devices

Message ID 20240618200231.1129282-33-denkenz@gmail.com (mailing list archive)
State Superseded
Headers show
Series [v2,01/33] qmi: Remove qmi_free() | expand

Commit Message

Denis Kenzior June 18, 2024, 8:02 p.m. UTC
MHI devices by default create a single main interface and support a
single bearer over it.  However, this requires a WDS Bind Data Mux
command to be issued with 'mux_id' 0.  Update the qmi gprs_context
atom driver to support multiple arguments, one of them being the mux_id
and the other being the WDS service lightweight handle.  If mux_id is
-1, then the WDS Bind Data Mux command is skipped.  Update gobi and
qrtrqmi drivers to the new API.
---
 drivers/qmimodem/gprs-context.c | 15 ++++++++-------
 plugins/gobi.c                  |  4 ++--
 plugins/qrtrqmi.c               |  9 ++++++++-
 3 files changed, 18 insertions(+), 10 deletions(-)
diff mbox series

Patch

diff --git a/drivers/qmimodem/gprs-context.c b/drivers/qmimodem/gprs-context.c
index aae058f35a9b..3c18476142ea 100644
--- a/drivers/qmimodem/gprs-context.c
+++ b/drivers/qmimodem/gprs-context.c
@@ -550,16 +550,17 @@  static int qmi_gprs_context_bind_mux(struct ofono_gprs_context *gc,
 	return -EIO;
 }
 
-static int qmi_gprs_context_probe(struct ofono_gprs_context *gc,
-					unsigned int vendor, void *user_data)
+static int qmi_gprs_context_probev(struct ofono_gprs_context *gc,
+					unsigned int vendor, va_list args)
 {
-	struct qmi_service *wds = user_data;
+	int mux_id = va_arg(args, int);
+	struct qmi_service *wds = va_arg(args, struct qmi_service *);
 	struct gprs_context_data *data;
 
 	DBG("");
 
-	if (vendor) {
-		int r = qmi_gprs_context_bind_mux(gc, wds, vendor);
+	if (mux_id != -1) {
+		int r = qmi_gprs_context_bind_mux(gc, wds, mux_id);
 
 		if (r < 0) {
 			qmi_service_free(wds);
@@ -569,7 +570,7 @@  static int qmi_gprs_context_probe(struct ofono_gprs_context *gc,
 
 	data = l_new(struct gprs_context_data, 1);
 	data->wds = wds;
-	data->mux_id = vendor;
+	data->mux_id = mux_id;
 
 	qmi_service_register(data->wds, QMI_WDS_PACKET_SERVICE_STATUS,
 					pkt_status_notify, gc, NULL);
@@ -593,7 +594,7 @@  static void qmi_gprs_context_remove(struct ofono_gprs_context *gc)
 
 static const struct ofono_gprs_context_driver driver = {
 	.flags			= OFONO_ATOM_DRIVER_FLAG_REGISTER_ON_PROBE,
-	.probe			= qmi_gprs_context_probe,
+	.probev			= qmi_gprs_context_probev,
 	.remove			= qmi_gprs_context_remove,
 	.activate_primary	= qmi_activate_primary,
 	.deactivate_primary	= qmi_deactivate_primary,
diff --git a/plugins/gobi.c b/plugins/gobi.c
index d24b95fffc91..7cdab3dda5f5 100644
--- a/plugins/gobi.c
+++ b/plugins/gobi.c
@@ -762,7 +762,7 @@  static void gobi_setup_gprs(struct ofono_modem *modem)
 	if (n_premux == 0) {
 		interface = ofono_modem_get_string(modem, "NetworkInterface");
 
-		gc = ofono_gprs_context_create(modem, 0, "qmimodem",
+		gc = ofono_gprs_context_create(modem, 0, "qmimodem", -1,
 						qmi_service_clone(data->wds));
 		if (!gc) {
 			ofono_warn("Unable to create gprs-context for: %s",
@@ -788,7 +788,7 @@  static void gobi_setup_gprs(struct ofono_modem *modem)
 		sprintf(buf, "PremuxInterface%dMuxId", i + 1);
 		mux_id = ofono_modem_get_integer(modem, buf);
 
-		gc = ofono_gprs_context_create(modem, mux_id, "qmimodem",
+		gc = ofono_gprs_context_create(modem, 0, "qmimodem", mux_id,
 						qmi_service_clone(data->wds));
 
 		if (!gc) {
diff --git a/plugins/qrtrqmi.c b/plugins/qrtrqmi.c
index 51e682f7e87c..cc335546caff 100644
--- a/plugins/qrtrqmi.c
+++ b/plugins/qrtrqmi.c
@@ -315,7 +315,7 @@  static int setup_gprs_context(uint8_t mux_id, const char *interface,
 	struct qmi_qrtr_node *node = data->node;
 	struct ofono_gprs_context *gc;
 
-	gc = ofono_gprs_context_create(modem, 0, "qmimodem",
+	gc = ofono_gprs_context_create(modem, 0, "qmimodem", mux_id,
 			qmi_qrtr_node_get_service(node, QMI_SERVICE_WDS));
 	if (!gc) {
 		ofono_warn("Unable to create gprs-context for: %s, %s[%hhu]",
@@ -347,6 +347,13 @@  static void setup_gprs(struct ofono_modem *modem)
 		return;
 	}
 
+	/* Upstream driver default, single interface, single context */
+	if (!n_premux) {
+		interface = ofono_modem_get_string(modem, "NetworkInterface");
+		setup_gprs_context(0, interface, gprs);
+		return;
+	}
+
 	for (i = 0; i < n_premux; i++) {
 		int mux_id;