From: Denis Kenzior <denkenz@gmail.com>
To: ofono@lists.linux.dev
Cc: Denis Kenzior <denkenz@gmail.com>
Subject: [PATCH v2 07/23] gobi: request needed services at .enable()
Date: Thu, 13 Jun 2024 16:41:16 -0500 [thread overview]
Message-ID: <20240613214134.1056517-7-denkenz@gmail.com> (raw)
In-Reply-To: <20240613214134.1056517-1-denkenz@gmail.com>
Request all needed services when the modem is being powered up via
.enable method.
---
plugins/gobi.c | 100 +++++++++++++++++++++++++++++++++++++++++--------
1 file changed, 85 insertions(+), 15 deletions(-)
diff --git a/plugins/gobi.c b/plugins/gobi.c
index 10ce2acc0cca..ea4d633c3406 100644
--- a/plugins/gobi.c
+++ b/plugins/gobi.c
@@ -60,10 +60,24 @@ enum qmi_protocol {
QMI_PROTOCOL_QRTR,
};
+struct service_request {
+ struct qmi_service **member;
+ uint32_t service_type;
+};
+
struct gobi_data {
struct qmi_device *device;
struct qmi_service *dms;
struct qmi_service *wda;
+ struct qmi_service *nas;
+ struct qmi_service *wds;
+ struct qmi_service *wms;
+ struct qmi_service *voice;
+ struct qmi_service *pds;
+ struct qmi_service *uim;
+ struct service_request service_requests[16];
+ int cur_service_request;
+ int num_service_requests;
unsigned long features;
unsigned int discover_attempts;
uint8_t oper_mode;
@@ -161,6 +175,24 @@ static void cleanup_services(struct gobi_data *data)
qmi_service_free(data->wda);
data->wda = NULL;
+
+ qmi_service_free(data->nas);
+ data->nas = NULL;
+
+ qmi_service_free(data->wds);
+ data->wds = NULL;
+
+ qmi_service_free(data->wms);
+ data->wms = NULL;
+
+ qmi_service_free(data->voice);
+ data->voice = NULL;
+
+ qmi_service_free(data->pds);
+ data->pds = NULL;
+
+ qmi_service_free(data->uim);
+ data->uim = NULL;
}
static void gobi_remove(struct ofono_modem *modem)
@@ -183,6 +215,21 @@ static void gobi_remove(struct ofono_modem *modem)
l_free(data);
}
+static void add_service_request(struct gobi_data *data,
+ struct qmi_service **member,
+ uint32_t service_type)
+{
+ struct service_request req = { .member = member,
+ .service_type = service_type };
+
+ if (data->num_service_requests == L_ARRAY_SIZE(data->service_requests)) {
+ ofono_error("No room to add service request");
+ return;
+ }
+
+ data->service_requests[data->num_service_requests++] = req;
+}
+
static void shutdown_cb(void *user_data)
{
struct ofono_modem *modem = user_data;
@@ -376,34 +423,42 @@ error:
shutdown_device(modem);
}
-static void create_dms_cb(struct qmi_service *service, void *user_data)
+static void request_service_cb(struct qmi_service *service, void *user_data)
{
struct ofono_modem *modem = user_data;
struct gobi_data *data = ofono_modem_get_data(modem);
+ struct service_request *req =
+ &data->service_requests[data->cur_service_request];
DBG("");
if (!service)
goto error;
- data->dms = service;
+ *req->member = service;
- if (qmi_service_create_shared(data->device, QMI_SERVICE_WDA,
- create_wda_cb, modem, NULL))
+ data->cur_service_request += 1;
+ if (data->cur_service_request == data->num_service_requests) {
+ DBG("All services requested, proceeding to create WDA");
+
+ if (qmi_service_create_shared(data->device, QMI_SERVICE_WDA,
+ create_wda_cb, modem, NULL))
+ return;
+
+ goto error;
+ }
+
+ req = &data->service_requests[data->cur_service_request];
+ DBG("Requesting: %u", req->service_type);
+
+ if (qmi_service_create_shared(data->device, req->service_type,
+ request_service_cb, modem, NULL))
return;
error:
shutdown_device(modem);
}
-static void create_shared_dms(struct ofono_modem *modem)
-{
- struct gobi_data *data = ofono_modem_get_data(modem);
-
- qmi_service_create_shared(data->device, QMI_SERVICE_DMS,
- create_dms_cb, modem, NULL);
-}
-
static void discover_cb(void *user_data)
{
struct ofono_modem *modem = user_data;
@@ -434,11 +489,26 @@ static void discover_cb(void *user_data)
modem, NULL))
return;
- shutdown_device(modem);
- return;
+ goto error;
}
- create_shared_dms(modem);
+ add_service_request(data, &data->dms, QMI_SERVICE_DMS);
+ if (data->features & GOBI_NAS)
+ add_service_request(data, &data->nas, QMI_SERVICE_NAS);
+ if (data->features & GOBI_WDS)
+ add_service_request(data, &data->wds, QMI_SERVICE_WDS);
+ if (data->features & GOBI_WMS)
+ add_service_request(data, &data->wms, QMI_SERVICE_WMS);
+ if (data->features & GOBI_VOICE)
+ add_service_request(data, &data->voice, QMI_SERVICE_VOICE);
+ if (data->features & GOBI_UIM)
+ add_service_request(data, &data->uim, QMI_SERVICE_UIM);
+
+ if (qmi_service_create_shared(data->device, QMI_SERVICE_DMS,
+ request_service_cb, modem, NULL) > 0)
+ return;
+error:
+ shutdown_device(modem);
}
static int gobi_enable(struct ofono_modem *modem)
--
2.45.0
next prev 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 ` Denis Kenzior [this message]
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 ` [PATCH v2 22/23] qmi: gprs: " Denis Kenzior
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-7-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