Skip to content

Commit 35bddff

Browse files
author
Desnes Nunes
committed
drivers/usb/musb: refactor min/max with min_t/max_t
JIRA: https://issues.redhat.com/browse/RHEL-78828 commit a05e885 Author: Sabyrzhan Tasbolatov <snovitoll@gmail.com> Date: Tue, 12 Nov 2024 20:58:15 +0500 Ensure type safety by using min_t()/max_t() instead of casted min()/max(). Signed-off-by: Sabyrzhan Tasbolatov <snovitoll@gmail.com> Link: https://lore.kernel.org/r/20241112155817.3512577-7-snovitoll@gmail.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Desnes Nunes <desnesn@redhat.com>
1 parent 3191469 commit 35bddff

File tree

3 files changed

+4
-5
lines changed

3 files changed

+4
-5
lines changed

drivers/usb/musb/musb_core.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1392,7 +1392,7 @@ fifo_setup(struct musb *musb, struct musb_hw_ep *hw_ep,
13921392

13931393
/* expect hw_ep has already been zero-initialized */
13941394

1395-
size = ffs(max(maxpacket, (u16) 8)) - 1;
1395+
size = ffs(max_t(u16, maxpacket, 8)) - 1;
13961396
maxpacket = 1 << size;
13971397

13981398
c_size = size - 3;

drivers/usb/musb/musb_gadget_ep0.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -533,7 +533,7 @@ static void ep0_txstate(struct musb *musb)
533533

534534
/* load the data */
535535
fifo_src = (u8 *) request->buf + request->actual;
536-
fifo_count = min((unsigned) MUSB_EP0_FIFOSIZE,
536+
fifo_count = min_t(unsigned, MUSB_EP0_FIFOSIZE,
537537
request->length - request->actual);
538538
musb_write_fifo(&musb->endpoints[0], fifo_count, fifo_src);
539539
request->actual += fifo_count;

drivers/usb/musb/musb_host.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -792,10 +792,9 @@ static void musb_ep_program(struct musb *musb, u8 epnum,
792792
}
793793

794794
if (can_bulk_split(musb, qh->type))
795-
load_count = min((u32) hw_ep->max_packet_sz_tx,
796-
len);
795+
load_count = min_t(u32, hw_ep->max_packet_sz_tx, len);
797796
else
798-
load_count = min((u32) packet_sz, len);
797+
load_count = min_t(u32, packet_sz, len);
799798

800799
if (dma_channel && musb_tx_dma_program(dma_controller,
801800
hw_ep, qh, urb, offset, len))

0 commit comments

Comments
 (0)