From patchwork Fri Jun 16 14:26:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 13282857 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 471F7EB64D7 for ; Fri, 16 Jun 2023 14:26:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229722AbjFPO0N (ORCPT ); Fri, 16 Jun 2023 10:26:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39342 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345434AbjFPO0N (ORCPT ); Fri, 16 Jun 2023 10:26:13 -0400 Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 02BC230E3; Fri, 16 Jun 2023 07:26:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1686925571; x=1718461571; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=jbvx+fzCk6wuoZXDOskZS3VFaadcPZdfZkhrwY1ULLc=; b=lPYbMMdPn16dDXSSud8doBGuw+4pB1fxXcWMrTmIYmPVIIasgccFYdRN W2r0LAgibmZvQ9eZar0E0RSFBn+4oipgbfXsLppaLJpzL5DPiG4EGbKrK krZ2nlO1UXjMxJ2mpyHRc3mQKrydzAuz6p46Eb4xBfWaElBfJbYBqIwdl wefvLozWVDvAgFNd3m0tKYxZ1TyiGXrz7AEp/0FYDnD/0DZAn+y0vxknq dT3sIiOu3Nv1wL/gGP7i/LCnblQvka8B92UDiqYKiG5GF+DKRwCZdAOqm S1Xvg/apXfCKdUI0ELZ9fPhbmCMwENnYZuoiTARIkESOB96Q+fPVNOvQT Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10742"; a="348934347" X-IronPort-AV: E=Sophos;i="6.00,247,1681196400"; d="scan'208";a="348934347" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Jun 2023 07:26:10 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10742"; a="716043859" X-IronPort-AV: E=Sophos;i="6.00,247,1681196400"; d="scan'208";a="716043859" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga007.fm.intel.com with ESMTP; 16 Jun 2023 07:26:08 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id BC90E379; Fri, 16 Jun 2023 17:26:17 +0300 (EEST) From: Andy Shevchenko To: Jens Axboe , Greg Kroah-Hartman , linux-block@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Andy Shevchenko Subject: [PATCH v1 1/1] pktcdvd: Use clamp_val() instead of min()+max() Date: Fri, 16 Jun 2023 17:26:14 +0300 Message-Id: <20230616142614.36206-1-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.40.0.1.gaa8946217a0b MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org In a couple of places replace min()+max() pair by clamp_val(). Signed-off-by: Andy Shevchenko --- drivers/block/pktcdvd.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/drivers/block/pktcdvd.c b/drivers/block/pktcdvd.c index a1428538bda5..18a960bb6165 100644 --- a/drivers/block/pktcdvd.c +++ b/drivers/block/pktcdvd.c @@ -208,14 +208,11 @@ static DEVICE_ATTR_RO(size); static void init_write_congestion_marks(int* lo, int* hi) { if (*hi > 0) { - *hi = max(*hi, 500); - *hi = min(*hi, 1000000); + *hi = clamp_val(*hi, 500, 1000000); if (*lo <= 0) *lo = *hi - 100; - else { - *lo = min(*lo, *hi - 100); - *lo = max(*lo, 100); - } + else + *lo = clamp_val(*lo, 100, *hi - 100); } else { *hi = -1; *lo = -1;