Skip to content

Commit 528ea1a

Browse files
novitollgregkh
authored andcommitted
drivers/usb/storage: refactor min with min_t
Ensure type safety by using min_t() instead of casted min(). 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 6d8a67e commit 528ea1a

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

drivers/usb/storage/sddr09.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -752,7 +752,7 @@ sddr09_read_data(struct us_data *us,
752752
// a bounce buffer and move the data a piece at a time between the
753753
// bounce buffer and the actual transfer buffer.
754754

755-
len = min(sectors, (unsigned int) info->blocksize) * info->pagesize;
755+
len = min_t(unsigned int, sectors, info->blocksize) * info->pagesize;
756756
buffer = kmalloc(len, GFP_NOIO);
757757
if (!buffer)
758758
return -ENOMEM;
@@ -997,7 +997,7 @@ sddr09_write_data(struct us_data *us,
997997
* at a time between the bounce buffer and the actual transfer buffer.
998998
*/
999999

1000-
len = min(sectors, (unsigned int) info->blocksize) * info->pagesize;
1000+
len = min_t(unsigned int, sectors, info->blocksize) * info->pagesize;
10011001
buffer = kmalloc(len, GFP_NOIO);
10021002
if (!buffer) {
10031003
kfree(blockbuffer);

drivers/usb/storage/sddr55.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ static int sddr55_read_data(struct us_data *us,
206206
// a bounce buffer and move the data a piece at a time between the
207207
// bounce buffer and the actual transfer buffer.
208208

209-
len = min((unsigned int) sectors, (unsigned int) info->blocksize >>
209+
len = min_t(unsigned int, sectors, info->blocksize >>
210210
info->smallpageshift) * PAGESIZE;
211211
buffer = kmalloc(len, GFP_NOIO);
212212
if (buffer == NULL)
@@ -224,7 +224,7 @@ static int sddr55_read_data(struct us_data *us,
224224

225225
// Read as many sectors as possible in this block
226226

227-
pages = min((unsigned int) sectors << info->smallpageshift,
227+
pages = min_t(unsigned int, sectors << info->smallpageshift,
228228
info->blocksize - page);
229229
len = pages << info->pageshift;
230230

@@ -333,7 +333,7 @@ static int sddr55_write_data(struct us_data *us,
333333
// a bounce buffer and move the data a piece at a time between the
334334
// bounce buffer and the actual transfer buffer.
335335

336-
len = min((unsigned int) sectors, (unsigned int) info->blocksize >>
336+
len = min_t(unsigned int, sectors, info->blocksize >>
337337
info->smallpageshift) * PAGESIZE;
338338
buffer = kmalloc(len, GFP_NOIO);
339339
if (buffer == NULL)
@@ -351,7 +351,7 @@ static int sddr55_write_data(struct us_data *us,
351351

352352
// Write as many sectors as possible in this block
353353

354-
pages = min((unsigned int) sectors << info->smallpageshift,
354+
pages = min_t(unsigned int, sectors << info->smallpageshift,
355355
info->blocksize - page);
356356
len = pages << info->pageshift;
357357

0 commit comments

Comments
 (0)