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 6/8] drivers/usb/musb: refactor min/max with min_t/max_t
Date: Tue, 12 Nov 2024 20:58:15 +0500 [thread overview]
Message-ID: <20241112155817.3512577-7-snovitoll@gmail.com> (raw)
In-Reply-To: <20241112155817.3512577-1-snovitoll@gmail.com>
Ensure type safety by using min_t()/max_t() instead of casted min()/max().
Signed-off-by: Sabyrzhan Tasbolatov <snovitoll@gmail.com>
---
drivers/usb/musb/musb_core.c | 2 +-
drivers/usb/musb/musb_gadget_ep0.c | 2 +-
drivers/usb/musb/musb_host.c | 5 ++---
3 files changed, 4 insertions(+), 5 deletions(-)
diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c
index b24adb5b399f..61f3aee7b72e 100644
--- a/drivers/usb/musb/musb_core.c
+++ b/drivers/usb/musb/musb_core.c
@@ -1387,7 +1387,7 @@ fifo_setup(struct musb *musb, struct musb_hw_ep *hw_ep,
/* expect hw_ep has already been zero-initialized */
- size = ffs(max(maxpacket, (u16) 8)) - 1;
+ size = ffs(max_t(u16, maxpacket, 8)) - 1;
maxpacket = 1 << size;
c_size = size - 3;
diff --git a/drivers/usb/musb/musb_gadget_ep0.c b/drivers/usb/musb/musb_gadget_ep0.c
index 6d7336727388..f0786f8fbb25 100644
--- a/drivers/usb/musb/musb_gadget_ep0.c
+++ b/drivers/usb/musb/musb_gadget_ep0.c
@@ -533,7 +533,7 @@ static void ep0_txstate(struct musb *musb)
/* load the data */
fifo_src = (u8 *) request->buf + request->actual;
- fifo_count = min((unsigned) MUSB_EP0_FIFOSIZE,
+ fifo_count = min_t(unsigned, MUSB_EP0_FIFOSIZE,
request->length - request->actual);
musb_write_fifo(&musb->endpoints[0], fifo_count, fifo_src);
request->actual += fifo_count;
diff --git a/drivers/usb/musb/musb_host.c b/drivers/usb/musb/musb_host.c
index bc4507781167..732ba981e607 100644
--- a/drivers/usb/musb/musb_host.c
+++ b/drivers/usb/musb/musb_host.c
@@ -798,10 +798,9 @@ static void musb_ep_program(struct musb *musb, u8 epnum,
}
if (can_bulk_split(musb, qh->type))
- load_count = min((u32) hw_ep->max_packet_sz_tx,
- len);
+ load_count = min_t(u32, hw_ep->max_packet_sz_tx, len);
else
- load_count = min((u32) packet_sz, len);
+ load_count = min_t(u32, packet_sz, len);
if (dma_channel && musb_tx_dma_program(dma_controller,
hw_ep, qh, urb, offset, len))
--
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 ` Sabyrzhan Tasbolatov [this message]
2024-11-12 15:58 ` [PATCH v2 7/8] drivers/usb/serial: " Sabyrzhan Tasbolatov
2024-11-12 15:58 ` [PATCH v2 8/8] drivers/usb/storage: " Sabyrzhan Tasbolatov
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-7-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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®