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 09/23] qmi: sim-legacy: Drop use of qmi_service_create_shared
Date: Fri,  7 Jun 2024 17:47:09 -0500	[thread overview]
Message-ID: <20240607224746.903769-9-denkenz@gmail.com> (raw)
In-Reply-To: <20240607224746.903769-1-denkenz@gmail.com>

While here, also drop tracking of indication registration.  This is not
needed as qmi_service_free will automatically unregister from all
indications for the cloned handle.
---
 drivers/qmimodem/sim-legacy.c | 57 +++++++++--------------------------
 plugins/gobi.c                | 17 ++++-------
 2 files changed, 20 insertions(+), 54 deletions(-)

diff --git a/drivers/qmimodem/sim-legacy.c b/drivers/qmimodem/sim-legacy.c
index aeea5fae22f3..1feaf86976c6 100644
--- a/drivers/qmimodem/sim-legacy.c
+++ b/drivers/qmimodem/sim-legacy.c
@@ -27,7 +27,6 @@
 struct sim_data {
 	struct qmi_service *dms;
 	int retries[OFONO_SIM_PASSWORD_INVALID];
-	uint16_t event_indication_id;
 };
 
 static void qmi_read_file_info(struct ofono_sim *sim, int fileid,
@@ -295,59 +294,37 @@ done:
 	ofono_sim_register(sim);
 }
 
-static void create_dms_cb(struct qmi_service *service, void *user_data)
+static int qmi_sim_probe(struct ofono_sim *sim,
+				unsigned int vendor, void *user_data)
 {
-	struct ofono_sim *sim = user_data;
-	struct sim_data *data = ofono_sim_get_data(sim);
+	struct qmi_service *dms = user_data;
 	struct qmi_param *param;
+	struct sim_data *data;
+	int i;
 
 	DBG("");
 
-	if (!service) {
-		ofono_error("Failed to request DMS service");
-		ofono_sim_remove(sim);
-		return;
-	}
-
-	data->dms = service;
-
-	data->event_indication_id =
-		qmi_service_register(data->dms, QMI_DMS_EVENT,
-					event_notify, sim, NULL);
-
 	param = qmi_param_new();
-
 	qmi_param_append_uint8(param, QMI_DMS_PARAM_REPORT_PIN_STATUS, 0x01);
 	qmi_param_append_uint8(param, QMI_DMS_PARAM_REPORT_OPER_MODE, 0x01);
 	qmi_param_append_uint8(param, QMI_DMS_PARAM_REPORT_UIM_STATE, 0x01);
 
-	if (qmi_service_send(data->dms, QMI_DMS_SET_EVENT, param,
-					set_event_cb, sim, NULL) > 0)
-		return;
-
-	qmi_param_free(param);
-
-	ofono_sim_register(sim);
-}
-
-static int qmi_sim_probe(struct ofono_sim *sim,
-				unsigned int vendor, void *user_data)
-{
-	struct qmi_device *device = user_data;
-	struct sim_data *data;
-	int i;
-
-	DBG("");
+	if (!qmi_service_send(dms, QMI_DMS_SET_EVENT, param,
+					set_event_cb, sim, NULL)) {
+		qmi_param_free(param);
+		qmi_service_free(dms);
+		return -EIO;
+	}
 
 	data = l_new(struct sim_data, 1);
+	data->dms = dms;
 
 	for (i = 0; i < OFONO_SIM_PASSWORD_INVALID; i++)
 		data->retries[i] = -1;
 
-	ofono_sim_set_data(sim, data);
+	qmi_service_register(dms, QMI_DMS_EVENT, event_notify, sim, NULL);
 
-	qmi_service_create_shared(device, QMI_SERVICE_DMS,
-						create_dms_cb, sim, NULL);
+	ofono_sim_set_data(sim, data);
 
 	return 0;
 }
@@ -360,13 +337,7 @@ static void qmi_sim_remove(struct ofono_sim *sim)
 
 	ofono_sim_set_data(sim, NULL);
 
-	if (data->event_indication_id) {
-		qmi_service_unregister(data->dms, data->event_indication_id);
-		data->event_indication_id = 0;
-	}
-
 	qmi_service_free(data->dms);
-
 	l_free(data);
 }
 
diff --git a/plugins/gobi.c b/plugins/gobi.c
index 1a31e7a2b17d..b0f5896808fa 100644
--- a/plugins/gobi.c
+++ b/plugins/gobi.c
@@ -721,22 +721,17 @@ static void gobi_set_online(struct ofono_modem *modem, ofono_bool_t online,
 static void gobi_pre_sim(struct ofono_modem *modem)
 {
 	struct gobi_data *data = ofono_modem_get_data(modem);
-	const char *sim_driver = NULL;
+	bool legacy = ofono_modem_get_boolean(modem, "ForceSimLegacy");
 
 	DBG("%p", modem);
 
 	ofono_devinfo_create(modem, 0, "qmimodem", qmi_service_clone(data->dms));
 
-	if (data->features & GOBI_UIM)
-		sim_driver = "qmimodem";
-	else if (data->features & GOBI_DMS)
-		sim_driver = "qmimodem_legacy";
-
-	if (ofono_modem_get_boolean(modem, "ForceSimLegacy"))
-		sim_driver = "qmimodem_legacy";
-
-	if (sim_driver)
-		ofono_sim_create(modem, 0, sim_driver, data->device);
+	if ((data->features & GOBI_UIM) && !legacy)
+		ofono_sim_create(modem, 0, "qmimodem", data->device);
+	else /* DMS always availalable */
+		ofono_sim_create(modem, 0, "qmimodem_legacy",
+						qmi_service_clone(data->dms));
 
 	if (data->features & GOBI_VOICE)
 		ofono_voicecall_create(modem, 0, "qmimodem", data->device);
-- 
2.45.0


  parent reply	other threads:[~2024-06-07 22:47 UTC|newest]

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

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=20240607224746.903769-9-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