]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
drivers/usb/storage: refactor min with min_t
authorSabyrzhan Tasbolatov <snovitoll@gmail.com>
Tue, 12 Nov 2024 15:58:17 +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() instead of casted min().

Signed-off-by: Sabyrzhan Tasbolatov <snovitoll@gmail.com>
Link: https://lore.kernel.org/r/20241112155817.3512577-9-snovitoll@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/storage/sddr09.c
drivers/usb/storage/sddr55.c

index 03d1b9c69ea18f0747f49ac59a67be2a87a563ea..30ee76cfef05f380e01620a95f58ae6bd6378f57 100644 (file)
@@ -752,7 +752,7 @@ sddr09_read_data(struct us_data *us,
        // a bounce buffer and move the data a piece at a time between the
        // bounce buffer and the actual transfer buffer.
 
-       len = min(sectors, (unsigned int) info->blocksize) * info->pagesize;
+       len = min_t(unsigned int, sectors, info->blocksize) * info->pagesize;
        buffer = kmalloc(len, GFP_NOIO);
        if (!buffer)
                return -ENOMEM;
@@ -997,7 +997,7 @@ sddr09_write_data(struct us_data *us,
         * at a time between the bounce buffer and the actual transfer buffer.
         */
 
-       len = min(sectors, (unsigned int) info->blocksize) * info->pagesize;
+       len = min_t(unsigned int, sectors, info->blocksize) * info->pagesize;
        buffer = kmalloc(len, GFP_NOIO);
        if (!buffer) {
                kfree(blockbuffer);
index b8227478a7add21e48dbe0573f49efb9639f5aa3..a37fc505c57fe0e2423db78134253f88072196ed 100644 (file)
@@ -206,7 +206,7 @@ static int sddr55_read_data(struct us_data *us,
        // a bounce buffer and move the data a piece at a time between the
        // bounce buffer and the actual transfer buffer.
 
-       len = min((unsigned int) sectors, (unsigned int) info->blocksize >>
+       len = min_t(unsigned int, sectors, info->blocksize >>
                        info->smallpageshift) * PAGESIZE;
        buffer = kmalloc(len, GFP_NOIO);
        if (buffer == NULL)
@@ -224,7 +224,7 @@ static int sddr55_read_data(struct us_data *us,
 
                // Read as many sectors as possible in this block
 
-               pages = min((unsigned int) sectors << info->smallpageshift,
+               pages = min_t(unsigned int, sectors << info->smallpageshift,
                                info->blocksize - page);
                len = pages << info->pageshift;
 
@@ -333,7 +333,7 @@ static int sddr55_write_data(struct us_data *us,
        // a bounce buffer and move the data a piece at a time between the
        // bounce buffer and the actual transfer buffer.
 
-       len = min((unsigned int) sectors, (unsigned int) info->blocksize >>
+       len = min_t(unsigned int, sectors, info->blocksize >>
                        info->smallpageshift) * PAGESIZE;
        buffer = kmalloc(len, GFP_NOIO);
        if (buffer == NULL)
@@ -351,7 +351,7 @@ static int sddr55_write_data(struct us_data *us,
 
                // Write as many sectors as possible in this block
 
-               pages = min((unsigned int) sectors << info->smallpageshift,
+               pages = min_t(unsigned int, sectors << info->smallpageshift,
                                info->blocksize - page);
                len = pages << info->pageshift;