From: Sabyrzhan Tasbolatov <snovitoll@gmail.com>
To: gregkh@linuxfoundation.org, andreyknvl@gmail.com, b-liu@ti.com,
johan@kernel.org, oneukum@suse.com, stern@rowland.harvard.edu
Cc: linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org,
snovitoll@gmail.com, usb-storage@lists.one-eyed-alien.net
Subject: [PATCH v2 8/8] drivers/usb/storage: refactor min with min_t
Date: Tue, 12 Nov 2024 20:58:17 +0500 [thread overview]
Message-ID: <20241112155817.3512577-9-snovitoll@gmail.com> (raw)
In-Reply-To: <20241112155817.3512577-1-snovitoll@gmail.com>
Ensure type safety by using min_t() instead of casted min().
Signed-off-by: Sabyrzhan Tasbolatov <snovitoll@gmail.com>
---
drivers/usb/storage/sddr09.c | 4 ++--
drivers/usb/storage/sddr55.c | 8 ++++----
2 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/drivers/usb/storage/sddr09.c b/drivers/usb/storage/sddr09.c
index 03d1b9c69ea1..30ee76cfef05 100644
--- a/drivers/usb/storage/sddr09.c
+++ b/drivers/usb/storage/sddr09.c
@@ -752,7 +752,7 @@ sddr09_read_data(struct us_data *us,
// a bounce buffer and move the data a piece at a time between the
// bounce buffer and the actual transfer buffer.
- len = min(sectors, (unsigned int) info->blocksize) * info->pagesize;
+ len = min_t(unsigned int, sectors, info->blocksize) * info->pagesize;
buffer = kmalloc(len, GFP_NOIO);
if (!buffer)
return -ENOMEM;
@@ -997,7 +997,7 @@ sddr09_write_data(struct us_data *us,
* at a time between the bounce buffer and the actual transfer buffer.
*/
- len = min(sectors, (unsigned int) info->blocksize) * info->pagesize;
+ len = min_t(unsigned int, sectors, info->blocksize) * info->pagesize;
buffer = kmalloc(len, GFP_NOIO);
if (!buffer) {
kfree(blockbuffer);
diff --git a/drivers/usb/storage/sddr55.c b/drivers/usb/storage/sddr55.c
index b8227478a7ad..a37fc505c57f 100644
--- a/drivers/usb/storage/sddr55.c
+++ b/drivers/usb/storage/sddr55.c
@@ -206,7 +206,7 @@ static int sddr55_read_data(struct us_data *us,
// a bounce buffer and move the data a piece at a time between the
// bounce buffer and the actual transfer buffer.
- len = min((unsigned int) sectors, (unsigned int) info->blocksize >>
+ len = min_t(unsigned int, sectors, info->blocksize >>
info->smallpageshift) * PAGESIZE;
buffer = kmalloc(len, GFP_NOIO);
if (buffer == NULL)
@@ -224,7 +224,7 @@ static int sddr55_read_data(struct us_data *us,
// Read as many sectors as possible in this block
- pages = min((unsigned int) sectors << info->smallpageshift,
+ pages = min_t(unsigned int, sectors << info->smallpageshift,
info->blocksize - page);
len = pages << info->pageshift;
@@ -333,7 +333,7 @@ static int sddr55_write_data(struct us_data *us,
// a bounce buffer and move the data a piece at a time between the
// bounce buffer and the actual transfer buffer.
- len = min((unsigned int) sectors, (unsigned int) info->blocksize >>
+ len = min_t(unsigned int, sectors, info->blocksize >>
info->smallpageshift) * PAGESIZE;
buffer = kmalloc(len, GFP_NOIO);
if (buffer == NULL)
@@ -351,7 +351,7 @@ static int sddr55_write_data(struct us_data *us,
// Write as many sectors as possible in this block
- pages = min((unsigned int) sectors << info->smallpageshift,
+ pages = min_t(unsigned int, sectors << info->smallpageshift,
info->blocksize - page);
len = pages << info->pageshift;
--
2.34.1
next prev parent reply other threads:[~2024-11-12 15:58 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-12 15:04 [PATCH] drivers/usb: refactor min(), max() with min_t(), max_t() Sabyrzhan Tasbolatov
2024-11-12 15:14 ` Greg KH
2024-11-12 15:58 ` [PATCH v2 0/8] drivers/usb: refactor min/max with min_t/max_t Sabyrzhan Tasbolatov
2024-11-12 15:58 ` [PATCH v2 1/8] drivers/usb/gadget: refactor min with min_t Sabyrzhan Tasbolatov
2024-11-12 15:58 ` [PATCH v2 2/8] drivers/usb/core: refactor max with max_t Sabyrzhan Tasbolatov
2024-11-12 15:58 ` [PATCH v2 3/8] drivers/usb/host: refactor min/max with min_t/max_t Sabyrzhan Tasbolatov
2024-11-12 15:58 ` [PATCH v2 4/8] drivers/usb/misc: refactor min with min_t Sabyrzhan Tasbolatov
2024-11-12 15:58 ` [PATCH v2 5/8] drivers/usb/mon: " Sabyrzhan Tasbolatov
2024-11-12 15:58 ` [PATCH v2 6/8] drivers/usb/musb: refactor min/max with min_t/max_t Sabyrzhan Tasbolatov
2024-11-12 15:58 ` [PATCH v2 7/8] drivers/usb/serial: refactor min with min_t Sabyrzhan Tasbolatov
2024-11-12 15:58 ` Sabyrzhan Tasbolatov [this message]
2024-11-17 19:55 ` [PATCH v2 0/8] drivers/usb: refactor min/max with min_t/max_t Andy Shevchenko
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=20241112155817.3512577-9-snovitoll@gmail.com \
--to=snovitoll@gmail.com \
--cc=andreyknvl@gmail.com \
--cc=b-liu@ti.com \
--cc=gregkh@linuxfoundation.org \
--cc=johan@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=oneukum@suse.com \
--cc=stern@rowland.harvard.edu \
--cc=usb-storage@lists.one-eyed-alien.net \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.