diff mbox series

[v2,16/26] media: au0828: Use min macro

Message ID 20240419-fix-cocci-v2-16-2119e692309c@chromium.org
State Superseded
Headers show
Series media: Fix coccinelle warning/errors | expand

Commit Message

Ricardo Ribalda April 19, 2024, 9:48 a.m. UTC
Simplifies the code.

Found by cocci:
drivers/media/usb/au0828/au0828-video.c:605:11-12: WARNING opportunity for min()

Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
---
 drivers/media/usb/au0828/au0828-video.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

Comments

Hans Verkuil April 24, 2024, 11:03 a.m. UTC | #1
nitpick: subject should say "Use umin macro".

	Hans

On 19/04/2024 11:48, Ricardo Ribalda wrote:
> Simplifies the code.
> 
> Found by cocci:
> drivers/media/usb/au0828/au0828-video.c:605:11-12: WARNING opportunity for min()
> 
> Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
> ---
>  drivers/media/usb/au0828/au0828-video.c | 5 +----
>  1 file changed, 1 insertion(+), 4 deletions(-)
> 
> diff --git a/drivers/media/usb/au0828/au0828-video.c b/drivers/media/usb/au0828/au0828-video.c
> index fd9fc43d47e0..2ec49ea479d5 100644
> --- a/drivers/media/usb/au0828/au0828-video.c
> +++ b/drivers/media/usb/au0828/au0828-video.c
> @@ -602,10 +602,7 @@ static inline int au0828_isoc_copy(struct au0828_dev *dev, struct urb *urb)
>  		vbi_field_size = dev->vbi_width * dev->vbi_height * 2;
>  		if (dev->vbi_read < vbi_field_size) {
>  			remain  = vbi_field_size - dev->vbi_read;
> -			if (len < remain)
> -				lencopy = len;
> -			else
> -				lencopy = remain;
> +			lencopy = umin(len, remain);
>  
>  			if (vbi_buf != NULL)
>  				au0828_copy_vbi(dev, vbi_dma_q, vbi_buf, p,
>
diff mbox series

Patch

diff --git a/drivers/media/usb/au0828/au0828-video.c b/drivers/media/usb/au0828/au0828-video.c
index fd9fc43d47e0..2ec49ea479d5 100644
--- a/drivers/media/usb/au0828/au0828-video.c
+++ b/drivers/media/usb/au0828/au0828-video.c
@@ -602,10 +602,7 @@  static inline int au0828_isoc_copy(struct au0828_dev *dev, struct urb *urb)
 		vbi_field_size = dev->vbi_width * dev->vbi_height * 2;
 		if (dev->vbi_read < vbi_field_size) {
 			remain  = vbi_field_size - dev->vbi_read;
-			if (len < remain)
-				lencopy = len;
-			else
-				lencopy = remain;
+			lencopy = umin(len, remain);
 
 			if (vbi_buf != NULL)
 				au0828_copy_vbi(dev, vbi_dma_q, vbi_buf, p,