diff mbox series

[15/23] qmi: location-reporting: Drop use of qmi_service_create_shared

Message ID 20240607224746.903769-15-denkenz@gmail.com (mailing list archive)
State Superseded
Headers show
Series [01/23] gobi: Remove phonebook and stk atom creation | expand

Commit Message

Denis Kenzior June 7, 2024, 10:47 p.m. UTC
---
 drivers/qmimodem/location-reporting.c | 50 ++++++++-------------------
 plugins/gobi.c                        |  5 ++-
 2 files changed, 16 insertions(+), 39 deletions(-)
diff mbox series

Patch

diff --git a/drivers/qmimodem/location-reporting.c b/drivers/qmimodem/location-reporting.c
index 669e9e6fdd41..1c9b9c9c3663 100644
--- a/drivers/qmimodem/location-reporting.c
+++ b/drivers/qmimodem/location-reporting.c
@@ -172,67 +172,46 @@  static void qmi_location_reporting_disable(struct ofono_location_reporting *lr,
 }
 
 static void set_event_cb(struct qmi_result *result, void *user_data)
-{
-	struct ofono_location_reporting *lr = user_data;
-
-	DBG("");
-
-	ofono_location_reporting_register(lr);
-}
-
-static void create_pds_cb(struct qmi_service *service, void *user_data)
 {
 	struct ofono_location_reporting *lr = user_data;
 	struct location_data *data = ofono_location_reporting_get_data(lr);
-	struct qmi_param *param;
 
 	DBG("");
 
-	if (!service) {
-		ofono_error("Failed to request PDS service");
-		ofono_location_reporting_remove(lr);
-		return;
-	}
-
-	data->pds = service;
-
 	qmi_service_register(data->pds, QMI_PDS_EVENT,
 					event_notify, lr, NULL);
-
 	qmi_service_register(data->pds, QMI_PDS_STATE_IND,
 					state_notify, lr, NULL);
 
-	param = qmi_param_new();
-
-	qmi_param_append_uint8(param, QMI_PDS_PARAM_REPORT_NMEA, 0x01);
-	qmi_param_append_uint8(param, QMI_PDS_PARAM_REPORT_NMEA_DEBUG, 0x00);
-
-	if (qmi_service_send(data->pds, QMI_PDS_SET_EVENT, param,
-					set_event_cb, lr, NULL) > 0)
-		return;
-
-	qmi_param_free(param);
-
 	ofono_location_reporting_register(lr);
 }
 
 static int qmi_location_reporting_probe(struct ofono_location_reporting *lr,
 					unsigned int vendor, void *user_data)
 {
-	struct qmi_device *device = user_data;
+	struct qmi_service *pds = user_data;
 	struct location_data *data;
+	struct qmi_param *param;
 
 	DBG("");
 
-	data = l_new(struct location_data, 1);
+	param = qmi_param_new();
+	qmi_param_append_uint8(param, QMI_PDS_PARAM_REPORT_NMEA, 0x01);
+	qmi_param_append_uint8(param, QMI_PDS_PARAM_REPORT_NMEA_DEBUG, 0x00);
+
+	if (!qmi_service_send(pds, QMI_PDS_SET_EVENT, param,
+					set_event_cb, lr, NULL)) {
+		qmi_param_free(param);
+		qmi_service_free(pds);
+		return -EIO;
+	}
 
+	data = l_new(struct location_data, 1);
+	data->pds = pds;
 	data->fd = -1;
 
 	ofono_location_reporting_set_data(lr, data);
 
-	qmi_service_create_shared(device, QMI_SERVICE_PDS, create_pds_cb, lr,
-					NULL);
-
 	return 0;
 }
 
@@ -245,7 +224,6 @@  static void qmi_location_reporting_remove(struct ofono_location_reporting *lr)
 	ofono_location_reporting_set_data(lr, NULL);
 
 	qmi_service_free(data->pds);
-
 	l_free(data);
 }
 
diff --git a/plugins/gobi.c b/plugins/gobi.c
index 6dee928acdea..f27d6c23e34a 100644
--- a/plugins/gobi.c
+++ b/plugins/gobi.c
@@ -737,9 +737,8 @@  static void gobi_pre_sim(struct ofono_modem *modem)
 		ofono_voicecall_create(modem, 0, "qmimodem",
 					qmi_service_clone(data->voice));
 
-	if (data->features & GOBI_PDS)
-		ofono_location_reporting_create(modem, 0, "qmimodem",
-							data->device);
+	if (data->features & GOBI_PDS) /* exclusive use, no need to clone */
+		ofono_location_reporting_create(modem, 0, "qmimodem", data->pds);
 }
 
 static void gobi_setup_gprs(struct ofono_modem *modem)