diff mbox series

[2/8] qmi: Eliminate atomic ref counting

Message ID 20240419164458.36078-2-steve.schrock@getcruise.com (mailing list archive)
State Accepted
Commit 39b7437a004461f104f9e28372a6e73e126239ec
Headers show
Series [1/8] qmi unit: Link to dl | expand

Commit Message

Steve Schrock April 19, 2024, 4:44 p.m. UTC
This code is single-threaded so there is no need to use atomics.
While here simplify qmi_service_ref.
---
 drivers/qmimodem/qmi.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)
diff mbox series

Patch

diff --git a/drivers/qmimodem/qmi.c b/drivers/qmimodem/qmi.c
index 7f91b57d15be..0811eaf2faec 100644
--- a/drivers/qmimodem/qmi.c
+++ b/drivers/qmimodem/qmi.c
@@ -2660,10 +2660,8 @@  bool qmi_service_create(struct qmi_device *device,
 
 struct qmi_service *qmi_service_ref(struct qmi_service *service)
 {
-	if (!service)
-		return NULL;
-
-	__sync_fetch_and_add(&service->ref_count, 1);
+	if (service)
+		service->ref_count++;
 
 	return service;
 }
@@ -2676,7 +2674,7 @@  void qmi_service_unref(struct qmi_service *service)
 	if (!service)
 		return;
 
-	if (__sync_sub_and_fetch(&service->ref_count, 1))
+	if (--service->ref_count)
 		return;
 
 	device = service->device;