staging: gpib: agilent_82357a uses completion
authorMichael Rubin <matchstick@neverthere.org>
Tue, 8 Apr 2025 22:56:28 +0000 (22:56 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 15 Apr 2025 14:38:12 +0000 (16:38 +0200)
agilent_82357a_send_bulk_msg is a oneshot event where a semphore is meant for
synchronizing over counting events.

Recommendation is to use a completion instead.

Reported by checkpatch.

WARNING: consider using a completion

Signed-off-by: Michael Rubin <matchstick@neverthere.org>
Link: https://lore.kernel.org/r/20250408225628.187316-2-matchstick@neverthere.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/gpib/agilent_82357a/agilent_82357a.c
drivers/staging/gpib/agilent_82357a/agilent_82357a.h

index 1be21b6c12e230a887e6d257b93ca7deec6affd2..a4870d53725c4fa52b0b9b853ad25881f43ab0a6 100644 (file)
@@ -34,7 +34,7 @@ static void agilent_82357a_bulk_complete(struct urb *urb)
 {
        struct agilent_82357a_urb_ctx *context = urb->context;
 
-       up(&context->complete);
+       complete(&context->complete);
 }
 
 static void agilent_82357a_timeout_handler(struct timer_list *t)
@@ -43,7 +43,7 @@ static void agilent_82357a_timeout_handler(struct timer_list *t)
        struct agilent_82357a_urb_ctx *context = &a_priv->context;
 
        context->timed_out = 1;
-       up(&context->complete);
+       complete(&context->complete);
 }
 
 static int agilent_82357a_send_bulk_msg(struct agilent_82357a_priv *a_priv, void *data,
@@ -74,7 +74,7 @@ static int agilent_82357a_send_bulk_msg(struct agilent_82357a_priv *a_priv, void
        }
        usb_dev = interface_to_usbdev(a_priv->bus_interface);
        out_pipe = usb_sndbulkpipe(usb_dev, a_priv->bulk_out_endpoint);
-       sema_init(&context->complete, 0);
+       init_completion(&context->complete);
        context->timed_out = 0;
        usb_fill_bulk_urb(a_priv->bulk_urb, usb_dev, out_pipe, data, data_length,
                          &agilent_82357a_bulk_complete, context);
@@ -89,7 +89,7 @@ static int agilent_82357a_send_bulk_msg(struct agilent_82357a_priv *a_priv, void
                goto cleanup;
        }
        mutex_unlock(&a_priv->bulk_alloc_lock);
-       if (down_interruptible(&context->complete)) {
+       if (wait_for_completion_interruptible(&context->complete)) {
                retval = -ERESTARTSYS;
                goto cleanup;
        }
@@ -142,7 +142,7 @@ static int agilent_82357a_receive_bulk_msg(struct agilent_82357a_priv *a_priv, v
        }
        usb_dev = interface_to_usbdev(a_priv->bus_interface);
        in_pipe = usb_rcvbulkpipe(usb_dev, AGILENT_82357_BULK_IN_ENDPOINT);
-       sema_init(&context->complete, 0);
+       init_completion(&context->complete);
        context->timed_out = 0;
        usb_fill_bulk_urb(a_priv->bulk_urb, usb_dev, in_pipe, data, data_length,
                          &agilent_82357a_bulk_complete, context);
@@ -157,7 +157,7 @@ static int agilent_82357a_receive_bulk_msg(struct agilent_82357a_priv *a_priv, v
                goto cleanup;
        }
        mutex_unlock(&a_priv->bulk_alloc_lock);
-       if (down_interruptible(&context->complete)) {
+       if (wait_for_completion_interruptible(&context->complete)) {
                retval = -ERESTARTSYS;
                goto cleanup;
        }
index cdbc3ec5d8bd07e7b23ed9388a9c0be590b631f0..23aa4799eb8628fe11e4d76381a4d85eb4dffb3a 100644 (file)
@@ -6,7 +6,7 @@
 
 #include <linux/kernel.h>
 #include <linux/mutex.h>
-#include <linux/semaphore.h>
+#include <linux/completion.h>
 #include <linux/usb.h>
 #include <linux/timer.h>
 #include <linux/compiler_attributes.h>
@@ -115,7 +115,7 @@ enum xfer_abort_type {
 #define INTERRUPT_BUF_LEN 8
 
 struct agilent_82357a_urb_ctx {
-       struct semaphore complete;
+       struct completion complete;
        unsigned timed_out : 1;
 };