]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
drivers/usb/host: refactor min/max with min_t/max_t
authorSabyrzhan Tasbolatov <snovitoll@gmail.com>
Tue, 12 Nov 2024 15:58:12 +0000 (20:58 +0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 13 Nov 2024 14:09:50 +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-4-snovitoll@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/host/ehci-hcd.c
drivers/usb/host/oxu210hp-hcd.c
drivers/usb/host/r8a66597-hcd.c

index cbc0b86fcc365e145852fd9dd9140c0fbb983e4b..6de79ac5e6a44231a15fb26a1696ebf6f2630e47 100644 (file)
@@ -547,7 +547,7 @@ static int ehci_init(struct usb_hcd *hcd)
                 * make problems:  throughput reduction (!), data errors...
                 */
                if (park) {
-                       park = min(park, (unsigned) 3);
+                       park = min_t(unsigned int, park, 3);
                        temp |= CMD_PARK;
                        temp |= park << 8;
                }
index 14195896ad622148f0123387b301c1172f681e79..a6c20facf9450153121001d36547eee68d6c9ca9 100644 (file)
@@ -902,7 +902,7 @@ static int oxu_buf_alloc(struct oxu_hcd *oxu, struct ehci_qtd *qtd, int len)
 
        /* Find a suitable available data buffer */
        for (i = 0; i < BUFFER_NUM;
-                       i += max(a_blocks, (int)oxu->db_used[i])) {
+                       i += max_t(int, a_blocks, oxu->db_used[i])) {
 
                /* Check all the required blocks are available */
                for (j = 0; j < a_blocks; j++)
@@ -3040,7 +3040,7 @@ static int oxu_hcd_init(struct usb_hcd *hcd)
                 * make problems:  throughput reduction (!), data errors...
                 */
                if (park) {
-                       park = min(park, (unsigned) 3);
+                       park = min_t(unsigned int, park, 3);
                        temp |= CMD_PARK;
                        temp |= park << 8;
                }
index af7bf6e6627fa082ce3cb0a502ce6462dd67d756..a44992e2561b06042e51a8517b43dc58eee9cad3 100644 (file)
@@ -1336,7 +1336,7 @@ static void packet_read(struct r8a66597 *r8a66597, u16 pipenum)
                buf = (void *)urb->transfer_buffer + urb->actual_length;
                urb_len = urb->transfer_buffer_length - urb->actual_length;
        }
-       bufsize = min(urb_len, (int) td->maxpacket);
+       bufsize = min_t(int, urb_len, td->maxpacket);
        if (rcv_len <= bufsize) {
                size = rcv_len;
        } else {