From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Jens Axboe <axboe@kernel.dk>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
linux-block@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Subject: [PATCH v2 1/1] pktcdvd: Use clamp() instead of min()+max()
Date: Tue, 20 Jun 2023 18:01:59 +0300 [thread overview]
Message-ID: <20230620150159.63886-1-andriy.shevchenko@linux.intel.com> (raw)
In a couple of places replace min()+max() pair by clamp().
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
v2: Switched to clamp() for strict type checking (David)
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..2fe56afc53d4 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(*hi, 500, 1000000);
if (*lo <= 0)
*lo = *hi - 100;
- else {
- *lo = min(*lo, *hi - 100);
- *lo = max(*lo, 100);
- }
+ else
+ *lo = clamp(*lo, 100, *hi - 100);
} else {
*hi = -1;
*lo = -1;
--
2.40.0.1.gaa8946217a0b
reply other threads:[~2023-06-20 15:04 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230620150159.63886-1-andriy.shevchenko@linux.intel.com \
--to=andriy.shevchenko@linux.intel.com \
--cc=axboe@kernel.dk \
--cc=gregkh@linuxfoundation.org \
--cc=linux-block@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).