diff mbox series

[v2,06/23] qmi: introduce qmi_service_clone

Message ID 20240613214134.1056517-6-denkenz@gmail.com (mailing list archive)
State Accepted
Commit c6226a486eb102b028b49b89bca6d1412e0c9d1d
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
Allows obtaining a new lightweight qmi_service handle from an existing
handle.  All outstanding requests (sent using qmi_service_send) and
registrations (qmi_service_register) will be automatically canceled when
the lightweight handle is freed.
---
 drivers/qmimodem/qmi.c | 8 ++++++++
 drivers/qmimodem/qmi.h | 1 +
 2 files changed, 9 insertions(+)
diff mbox series

Patch

diff --git a/drivers/qmimodem/qmi.c b/drivers/qmimodem/qmi.c
index 1b3fa34f685c..91469dc2e00c 100644
--- a/drivers/qmimodem/qmi.c
+++ b/drivers/qmimodem/qmi.c
@@ -2918,6 +2918,14 @@  static bool qmi_service_unregister_all(struct qmi_service *service)
 	return true;
 }
 
+struct qmi_service *qmi_service_clone(struct qmi_service *service)
+{
+	if (!service)
+		return NULL;
+
+	return service_create(service->family);
+}
+
 void qmi_service_free(struct qmi_service *service)
 {
 	if (!service)
diff --git a/drivers/qmimodem/qmi.h b/drivers/qmimodem/qmi.h
index 227c498ab41d..821e54443658 100644
--- a/drivers/qmimodem/qmi.h
+++ b/drivers/qmimodem/qmi.h
@@ -139,6 +139,7 @@  typedef void (*qmi_create_func_t)(struct qmi_service *service, void *user_data);
 bool qmi_service_create_shared(struct qmi_device *device,
 				uint16_t type, qmi_create_func_t func,
 				void *user_data, qmi_destroy_func_t destroy);
+struct qmi_service *qmi_service_clone(struct qmi_service *service);
 void qmi_service_free(struct qmi_service *service);
 
 const char *qmi_service_get_identifier(struct qmi_service *service);