Skip to content

Commit

Permalink
mtd: spi-nor: replace unnecessary div64_u64() with div_u64()
Browse files Browse the repository at this point in the history
Both occurrences of div64_u64() just have a u8 or u32 divisor. Use
div_u64() instead. Many 32 bit architectures can optimize this variant
better than a full 64 bit divide.

Reported-by: Dan Carpenter <[email protected]>
Link: https://lore.kernel.org/r/[email protected]/
Signed-off-by: Michael Walle <[email protected]>
Reviewed-by: Pratyush Yadav <[email protected]>
[[email protected]: touched up commit message]
Signed-off-by: Pratyush Yadav <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
  • Loading branch information
mwalle authored and Pratyush Yadav committed Apr 29, 2024
1 parent 4cece76 commit c84b392
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions drivers/mtd/spi-nor/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -2893,7 +2893,7 @@ static int spi_nor_late_init_params(struct spi_nor *nor)
spi_nor_init_default_locking_ops(nor);

if (params->n_banks > 1)
params->bank_size = div64_u64(params->size, params->n_banks);
params->bank_size = div_u64(params->size, params->n_banks);

return 0;
}
Expand Down Expand Up @@ -3406,7 +3406,7 @@ static int spi_nor_set_mtd_eraseregions(struct spi_nor *nor)
return -EINVAL;

mtd_region[i].erasesize = erasesize;
mtd_region[i].numblocks = div64_ul(region[i].size, erasesize);
mtd_region[i].numblocks = div_u64(region[i].size, erasesize);
mtd_region[i].offset = region[i].offset;
}

Expand Down

0 comments on commit c84b392

Please sign in to comment.