From patchwork Sat May 6 07:14:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 679688 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9EA4FC77B7F for ; Sat, 6 May 2023 07:14:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230475AbjEFHOf (ORCPT ); Sat, 6 May 2023 03:14:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33250 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230136AbjEFHOe (ORCPT ); Sat, 6 May 2023 03:14:34 -0400 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7ACA511601 for ; Sat, 6 May 2023 00:14:33 -0700 (PDT) Received: from pendragon.ideasonboard.com (133-32-181-51.west.xps.vectant.ne.jp [133.32.181.51]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 19CC72D8; Sat, 6 May 2023 09:14:26 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1683357268; bh=NmcFDOPXBhR4UaWRJQVj7riQqYz++2QgtwNLz3ZeosA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=baMwQzS3DOFWf7ahE66AfjSwj2VaSQmpxq848voOSSuw4PlJJGh6XxHstz7Axkhqe TGD62KUq/Yxu/lWINjTUkmGp9YNOCM20Bx2/ol9H18yO91m1IWQfq9XjSS9EGHwRSv JUHB/mEX4FxBcEXBhHurmjI2+JZz0Q6Z6PLqKBus= From: Laurent Pinchart To: linux-media@vger.kernel.org Cc: Kieran Bingham , Ricardo Ribalda Subject: [PATCH v2 3/7] media: uvcvideo: Use clamp() to replace manual implementation Date: Sat, 6 May 2023 10:14:23 +0300 Message-Id: <20230506071427.28108-4-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20230506071427.28108-1-laurent.pinchart@ideasonboard.com> References: <20230506071427.28108-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org The kernel has a nice clamp() macro, use it to replace a manual implementation based on min() and max(). No functional change is intended. Signed-off-by: Laurent Pinchart --- drivers/media/usb/uvc/uvc_driver.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/media/usb/uvc/uvc_driver.c b/drivers/media/usb/uvc/uvc_driver.c index 1539eaf8f7d8..9e597bbbfe07 100644 --- a/drivers/media/usb/uvc/uvc_driver.c +++ b/drivers/media/usb/uvc/uvc_driver.c @@ -437,9 +437,9 @@ static int uvc_parse_format(struct uvc_device *dev, */ n -= frame->bFrameIntervalType ? 1 : 2; frame->dwDefaultFrameInterval = - min(frame->dwFrameInterval[n], - max(frame->dwFrameInterval[0], - frame->dwDefaultFrameInterval)); + clamp(frame->dwDefaultFrameInterval, + frame->dwFrameInterval[0], + frame->dwFrameInterval[n]); if (dev->quirks & UVC_QUIRK_RESTRICT_FRAME_RATE) { frame->bFrameIntervalType = 1;