From 94e71cd4f08a606131970aff82c023690c608c64 Mon Sep 17 00:00:00 2001 From: Michael Rubin Date: Tue, 8 Apr 2025 22:56:28 +0000 Subject: [PATCH] staging: gpib: agilent_82357a uses completion 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 Link: https://lore.kernel.org/r/20250408225628.187316-2-matchstick@neverthere.org Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gpib/agilent_82357a/agilent_82357a.c | 12 ++++++------ drivers/staging/gpib/agilent_82357a/agilent_82357a.h | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/staging/gpib/agilent_82357a/agilent_82357a.c b/drivers/staging/gpib/agilent_82357a/agilent_82357a.c index 1be21b6c12e23..a4870d53725c4 100644 --- a/drivers/staging/gpib/agilent_82357a/agilent_82357a.c +++ b/drivers/staging/gpib/agilent_82357a/agilent_82357a.c @@ -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; } diff --git a/drivers/staging/gpib/agilent_82357a/agilent_82357a.h b/drivers/staging/gpib/agilent_82357a/agilent_82357a.h index cdbc3ec5d8bd0..23aa4799eb862 100644 --- a/drivers/staging/gpib/agilent_82357a/agilent_82357a.h +++ b/drivers/staging/gpib/agilent_82357a/agilent_82357a.h @@ -6,7 +6,7 @@ #include #include -#include +#include #include #include #include @@ -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; }; -- 2.51.0