Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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 <snovitoll@gmail.com>
Link: https://lore.kernel.org/r/20241112155817.3512577-7-snovitoll@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Sabyrzhan Tasbolatov and committed by
Greg Kroah-Hartman
a05e885d fa3b4b9b

+4 -5
+1 -1
drivers/usb/musb/musb_core.c
··· 1387 1387 1388 1388 /* expect hw_ep has already been zero-initialized */ 1389 1389 1390 - size = ffs(max(maxpacket, (u16) 8)) - 1; 1390 + size = ffs(max_t(u16, maxpacket, 8)) - 1; 1391 1391 maxpacket = 1 << size; 1392 1392 1393 1393 c_size = size - 3;
+1 -1
drivers/usb/musb/musb_gadget_ep0.c
··· 533 533 534 534 /* load the data */ 535 535 fifo_src = (u8 *) request->buf + request->actual; 536 - fifo_count = min((unsigned) MUSB_EP0_FIFOSIZE, 536 + fifo_count = min_t(unsigned, MUSB_EP0_FIFOSIZE, 537 537 request->length - request->actual); 538 538 musb_write_fifo(&musb->endpoints[0], fifo_count, fifo_src); 539 539 request->actual += fifo_count;
+2 -3
drivers/usb/musb/musb_host.c
··· 798 798 } 799 799 800 800 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); 803 802 else 804 - load_count = min((u32) packet_sz, len); 803 + load_count = min_t(u32, packet_sz, len); 805 804 806 805 if (dma_channel && musb_tx_dma_program(dma_controller, 807 806 hw_ep, qh, urb, offset, len))