diff mbox series

[v2,14/23] qmi: ussd: Drop use of qmi_service_create_shared

Message ID 20240613214134.1056517-14-denkenz@gmail.com (mailing list archive)
State Accepted
Commit d627f3d6b991572547b929074cc9361a2cb36835
Headers show
Series [v2,01/23] gobi: Remove phonebook and stk atom creation | expand

Commit Message

Denis Kenzior June 13, 2024, 9:41 p.m. UTC
---
 drivers/qmimodem/ussd.c | 41 ++++++++---------------------------------
 plugins/gobi.c          |  3 ++-
 2 files changed, 10 insertions(+), 34 deletions(-)
diff mbox series

Patch

diff --git a/drivers/qmimodem/ussd.c b/drivers/qmimodem/ussd.c
index ec9b60ff1222..6637ae759c55 100644
--- a/drivers/qmimodem/ussd.c
+++ b/drivers/qmimodem/ussd.c
@@ -145,51 +145,26 @@  error:
 	ofono_ussd_notify(ussd, OFONO_USSD_STATUS_TERMINATED, 0, NULL, 0);
 }
 
-static void create_voice_cb(struct qmi_service *service, void *user_data)
+static int qmi_ussd_probe(struct ofono_ussd *ussd,
+				unsigned int vendor, void *user_data)
 {
-	struct ofono_ussd *ussd = user_data;
-	struct ussd_data *data = ofono_ussd_get_data(ussd);
+	struct qmi_service *voice = user_data;
+	struct ussd_data *data;
 
 	DBG("");
 
-	if (service == NULL) {
-		ofono_error("Failed to request Voice service");
-		ofono_ussd_remove(ussd);
-		return;
-	}
-
-	if (!qmi_service_get_version(service, &data->major, &data->minor)) {
-		ofono_error("Failed to get Voice service version");
-		ofono_ussd_remove(ussd);
-		return;
-	}
-
-	data->voice = service;
+	data = l_new(struct ussd_data, 1);
+	data->voice = voice;
 
+	qmi_service_get_version(data->voice, &data->major, &data->minor);
 	qmi_service_register(data->voice, QMI_VOICE_USSD_IND,
 					async_ind, ussd, NULL);
-
 	qmi_service_register(data->voice, QMI_VOICE_ASYNC_ORIG_USSD,
 					async_orig_ind, ussd, NULL);
 
-	ofono_ussd_register(ussd);
-}
-
-static int qmi_ussd_probe(struct ofono_ussd *ussd,
-				unsigned int vendor, void *user_data)
-{
-	struct qmi_device *device = user_data;
-	struct ussd_data *data;
-
-	DBG("");
-
-	data = l_new(struct ussd_data, 1);
 
 	ofono_ussd_set_data(ussd, data);
 
-	qmi_service_create_shared(device, QMI_SERVICE_VOICE,
-						create_voice_cb, ussd, NULL);
-
 	return 0;
 }
 
@@ -202,7 +177,6 @@  static void qmi_ussd_remove(struct ofono_ussd *ussd)
 	ofono_ussd_set_data(ussd, NULL);
 
 	qmi_service_free(data->voice);
-
 	l_free(data);
 }
 
@@ -298,6 +272,7 @@  error:
 }
 
 static const struct ofono_ussd_driver driver = {
+	.flags		= OFONO_ATOM_DRIVER_FLAG_REGISTER_ON_PROBE,
 	.probe		= qmi_ussd_probe,
 	.remove		= qmi_ussd_remove,
 	.request	= qmi_ussd_request,
diff --git a/plugins/gobi.c b/plugins/gobi.c
index 17160354c273..456a5d2363eb 100644
--- a/plugins/gobi.c
+++ b/plugins/gobi.c
@@ -833,7 +833,8 @@  static void gobi_post_online(struct ofono_modem *modem)
 	}
 
 	if (data->features & GOBI_VOICE) {
-		ofono_ussd_create(modem, 0, "qmimodem", data->device);
+		ofono_ussd_create(modem, 0, "qmimodem",
+						qmi_service_clone(data->voice));
 		ofono_call_settings_create(modem, 0, "qmimodem",
 						qmi_service_clone(data->voice));
 		ofono_call_barring_create(modem, 0, "qmimodem",