]> www.infradead.org Git - users/willy/linux.git/commitdiff
drivers/usb/musb: refactor min/max with min_t/max_t
authorSabyrzhan Tasbolatov <snovitoll@gmail.com>
Tue, 12 Nov 2024 15:58:15 +0000 (20:58 +0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 13 Nov 2024 14:09:51 +0000 (15:09 +0100)
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>
drivers/usb/musb/musb_core.c
drivers/usb/musb/musb_gadget_ep0.c
drivers/usb/musb/musb_host.c

index 25fafde6003cda1c2ce2b0b56da2cb39ad145847..03b1154a6014ab27b8cca916af3a724b58046c53 100644 (file)
@@ -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;
index 6d7336727388b663dce6aa49095f54ab66b7e41c..f0786f8fbb25c2a956f5b408cc9e126f82222457 100644 (file)
@@ -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;
index bc45077811679698388ff6366a2af8c276c56a99..732ba981e607e750995db0b7cca2bb270e9793e6 100644 (file)
@@ -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))