Open Source Telephony
 help / color / mirror / Atom feed
From: Denis Kenzior <denkenz@gmail.com>
To: ofono@lists.linux.dev
Cc: Denis Kenzior <denkenz@gmail.com>
Subject: [PATCH v2 22/23] qmi: gprs: Drop use of qmi_service_create_shared
Date: Thu, 13 Jun 2024 16:41:31 -0500	[thread overview]
Message-ID: <20240613214134.1056517-22-denkenz@gmail.com> (raw)
In-Reply-To: <20240613214134.1056517-1-denkenz@gmail.com>

---
 drivers/qmimodem/gprs.c | 85 +++++++++--------------------------------
 plugins/gobi.c          |  4 +-
 2 files changed, 22 insertions(+), 67 deletions(-)

diff --git a/drivers/qmimodem/gprs.c b/drivers/qmimodem/gprs.c
index 03ee377e8916..da7ad63c49cb 100644
--- a/drivers/qmimodem/gprs.c
+++ b/drivers/qmimodem/gprs.c
@@ -21,7 +21,6 @@
 #include "util.h"
 
 struct gprs_data {
-	struct qmi_device *dev;
 	struct qmi_service *nas;
 	struct qmi_service *wds;
 	unsigned int default_profile;
@@ -405,9 +404,12 @@ error:
 	ofono_gprs_remove(gprs);
 }
 
-static int get_default_profile_number_request(struct ofono_gprs *gprs)
+static int qmi_gprs_probev(struct ofono_gprs *gprs,
+				unsigned int vendor, va_list args)
 {
-	struct gprs_data *data = ofono_gprs_get_data(gprs);
+	struct qmi_service *wds = va_arg(args, struct qmi_service *);
+	struct qmi_service *nas = va_arg(args, struct qmi_service *);
+	struct gprs_data *data;
 	struct {
 		uint8_t type;
 		uint8_t family;
@@ -423,77 +425,29 @@ static int get_default_profile_number_request(struct ofono_gprs *gprs)
 	 */
 	qmi_param_append(param, QMI_WDS_PARAM_PROFILE_TYPE, sizeof(p), &p);
 
-	if (qmi_service_send(data->wds, QMI_WDS_GET_DEFAULT_PROFILE_NUMBER,
+	if (!qmi_service_send(wds, QMI_WDS_GET_DEFAULT_PROFILE_NUMBER,
 				param, get_default_profile_number_cb,
-				gprs, NULL) > 0)
-		return 0;
-
-	qmi_param_free(param);
-	return -EIO;
-}
-
-static void create_wds_cb(struct qmi_service *service, void *user_data)
-{
-	struct ofono_gprs *gprs = user_data;
-	struct gprs_data *data = ofono_gprs_get_data(gprs);
+				gprs, NULL)) {
+		qmi_param_free(param);
+		qmi_service_free(nas);
+		qmi_service_free(wds);
 
-	DBG("");
-
-	if (!service) {
-		ofono_error("Failed to request WDS service");
-		goto error;
+		return -EIO;
 	}
 
-	data->wds = service;
-	qmi_service_register(data->wds, QMI_WDS_EVENT_REPORT,
-				event_report_notify, gprs, NULL);
-	qmi_service_register(data->wds, QMI_WDS_PROFILE_CHANGED,
-				profile_changed_notify, gprs, NULL);
-
-	if (get_default_profile_number_request(gprs) >= 0)
-		return;
-error:
-	ofono_gprs_remove(gprs);
-}
-
-static void create_nas_cb(struct qmi_service *service, void *user_data)
-{
-	struct ofono_gprs *gprs = user_data;
-	struct gprs_data *data = ofono_gprs_get_data(gprs);
-
-	DBG("");
-
-	if (!service) {
-		ofono_error("Failed to request NAS service");
-		ofono_gprs_remove(gprs);
-		return;
-	}
+	data = l_new(struct gprs_data, 1);
+	data->wds = wds;
+	data->nas = nas;
 
-	data->nas = service;
 	qmi_service_register(data->nas, QMI_NAS_SERVING_SYSTEM_INDICATION,
 					ss_info_notify, gprs, NULL);
-
-	qmi_service_create_shared(data->dev, QMI_SERVICE_WDS,
-						create_wds_cb, gprs, NULL);
-}
-
-static int qmi_gprs_probe(struct ofono_gprs *gprs,
-				unsigned int vendor, void *user_data)
-{
-	struct qmi_device *device = user_data;
-	struct gprs_data *data;
-
-	DBG("");
-
-	data = l_new(struct gprs_data, 1);
+	qmi_service_register(data->wds, QMI_WDS_EVENT_REPORT,
+					event_report_notify, gprs, NULL);
+	qmi_service_register(data->wds, QMI_WDS_PROFILE_CHANGED,
+					profile_changed_notify, gprs, NULL);
 
 	ofono_gprs_set_data(gprs, data);
 
-	data->dev = device;
-
-	qmi_service_create_shared(device, QMI_SERVICE_NAS,
-						create_nas_cb, gprs, NULL);
-
 	return 0;
 }
 
@@ -507,12 +461,11 @@ static void qmi_gprs_remove(struct ofono_gprs *gprs)
 
 	qmi_service_free(data->wds);
 	qmi_service_free(data->nas);
-
 	l_free(data);
 }
 
 static const struct ofono_gprs_driver driver = {
-	.probe			= qmi_gprs_probe,
+	.probev			= qmi_gprs_probev,
 	.remove			= qmi_gprs_remove,
 	.set_attached		= qmi_set_attached,
 	.attached_status	= qmi_attached_status,
diff --git a/plugins/gobi.c b/plugins/gobi.c
index 7ded86c52b96..1a866490d41c 100644
--- a/plugins/gobi.c
+++ b/plugins/gobi.c
@@ -742,7 +742,9 @@ static void gobi_setup_gprs(struct ofono_modem *modem)
 	char buf[256];
 	int i;
 
-	gprs = ofono_gprs_create(modem, 0, "qmimodem", data->device);
+	gprs = ofono_gprs_create(modem, 0, "qmimodem",
+					qmi_service_clone(data->wds),
+					qmi_service_clone(data->nas));
 	if (!gprs) {
 		ofono_warn("Unable to create gprs for: %s",
 					ofono_modem_get_path(modem));
-- 
2.45.0


  parent reply	other threads:[~2024-06-13 21:41 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-13 21:41 [PATCH v2 01/23] gobi: Remove phonebook and stk atom creation Denis Kenzior
2024-06-13 21:41 ` [PATCH v2 02/23] qmi: lookup shared family directly by type Denis Kenzior
2024-06-13 21:41 ` [PATCH v2 03/23] core: allow multiple args in atom constructors Denis Kenzior
2024-06-13 21:41 ` [PATCH v2 04/23] unit: Update unit tests to the new API Denis Kenzior
2024-06-13 21:41 ` [PATCH v2 05/23] core: Support register on probe flag Denis Kenzior
2024-06-13 21:41 ` [PATCH v2 06/23] qmi: introduce qmi_service_clone Denis Kenzior
2024-06-13 21:41 ` [PATCH v2 07/23] gobi: request needed services at .enable() Denis Kenzior
2024-06-13 21:41 ` [PATCH v2 08/23] qmi: devinfo: Drop use of qmi_service_create_shared Denis Kenzior
2024-06-13 21:41 ` [PATCH v2 09/23] qmi: sim-legacy: " Denis Kenzior
2024-06-13 21:41 ` [PATCH v2 10/23] qmi: voicecall: " Denis Kenzior
2024-06-13 21:41 ` [PATCH v2 11/23] qmi: call-barring: " Denis Kenzior
2024-06-13 21:41 ` [PATCH v2 12/23] qmi: call-forwarding: " Denis Kenzior
2024-06-13 21:41 ` [PATCH v2 13/23] qmi: call-settings: " Denis Kenzior
2024-06-13 21:41 ` [PATCH v2 14/23] qmi: ussd: " Denis Kenzior
2024-06-13 21:41 ` [PATCH v2 15/23] qmi: location-reporting: " Denis Kenzior
2024-06-13 21:41 ` [PATCH v2 16/23] qmi: sms: " Denis Kenzior
2024-06-13 21:41 ` [PATCH v2 17/23] qmi: netreg: " Denis Kenzior
2024-06-13 21:41 ` [PATCH v2 18/23] qmi: netmon: " Denis Kenzior
2024-06-13 21:41 ` [PATCH v2 19/23] qmi: lte: " Denis Kenzior
2024-06-13 21:41 ` [PATCH v2 20/23] qmi: gprs-context: " Denis Kenzior
2024-06-13 21:41 ` [PATCH v2 21/23] qmi: sim: " Denis Kenzior
2024-06-13 21:41 ` Denis Kenzior [this message]
2024-06-13 21:41 ` [PATCH v2 23/23] qmi: radio-settings: " Denis Kenzior
2024-06-14 15:10 ` [PATCH v2 01/23] gobi: Remove phonebook and stk atom creation patchwork-bot+ofono

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240613214134.1056517-22-denkenz@gmail.com \
    --to=denkenz@gmail.com \
    --cc=ofono@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox