Skip to content

Commit a05e885

Browse files
novitollgregkh
authored andcommitted
drivers/usb/musb: refactor min/max with min_t/max_t
Ensure type safety by using min_t()/max_t() instead of casted min()/max(). Signed-off-by: Sabyrzhan Tasbolatov <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent fa3b4b9 commit a05e885

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
@@ -1387,7 +1387,7 @@ fifo_setup(struct musb *musb, struct musb_hw_ep *hw_ep,
13871387

13881388
/* expect hw_ep has already been zero-initialized */
13891389

1390-
size = ffs(max(maxpacket, (u16) 8)) - 1;
1390+
size = ffs(max_t(u16, maxpacket, 8)) - 1;
13911391
maxpacket = 1 << size;
13921392

13931393
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
@@ -798,10 +798,9 @@ static void musb_ep_program(struct musb *musb, u8 epnum,
798798
}
799799

800800
if (can_bulk_split(musb, qh->type))
801-
load_count = min((u32) hw_ep->max_packet_sz_tx,
802-
len);
801+
load_count = min_t(u32, hw_ep->max_packet_sz_tx, len);
803802
else
804-
load_count = min((u32) packet_sz, len);
803+
load_count = min_t(u32, packet_sz, len);
805804

806805
if (dma_channel && musb_tx_dma_program(dma_controller,
807806
hw_ep, qh, urb, offset, len))

0 commit comments

Comments
 (0)