drivers/block: Use DIV_ROUND_UP
The kernel.h macro DIV_ROUND_UP performs the computation (((n) + (d) - 1) / (d)) but is perhaps more readable. An extract of the semantic patch that makes this change is as follows: (http://www.emn.fr/x-info/coccinelle/) // <smpl> @haskernel@ @@ #include <linux/kernel.h> @depends on haskernel@ expression n,d; @@ ( - (n + d - 1) / d + DIV_ROUND_UP(n,d) | - (n + (d - 1)) / d + DIV_ROUND_UP(n,d) ) @depends on haskernel@ expression n,d; @@ - DIV_ROUND_UP((n),d) + DIV_ROUND_UP(n,d) @depends on haskernel@ expression n,d; @@ - DIV_ROUND_UP(n,(d)) + DIV_ROUND_UP(n,d) // </smpl> Signed-off-by: Julia Lawall <julia@diku.dk> Cc: <mike.miller@hp.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
This commit is contained in:
parent
905bd78f21
commit
061837bc86
@ -3460,8 +3460,8 @@ static int __devinit cciss_init_one(struct pci_dev *pdev,
|
||||
hba[i]->intr[SIMPLE_MODE_INT], dac ? "" : " not");
|
||||
|
||||
hba[i]->cmd_pool_bits =
|
||||
kmalloc(((hba[i]->nr_cmds + BITS_PER_LONG -
|
||||
1) / BITS_PER_LONG) * sizeof(unsigned long), GFP_KERNEL);
|
||||
kmalloc(DIV_ROUND_UP(hba[i]->nr_cmds, BITS_PER_LONG)
|
||||
* sizeof(unsigned long), GFP_KERNEL);
|
||||
hba[i]->cmd_pool = (CommandList_struct *)
|
||||
pci_alloc_consistent(hba[i]->pdev,
|
||||
hba[i]->nr_cmds * sizeof(CommandList_struct),
|
||||
@ -3493,8 +3493,8 @@ static int __devinit cciss_init_one(struct pci_dev *pdev,
|
||||
/* command and error info recs zeroed out before
|
||||
they are used */
|
||||
memset(hba[i]->cmd_pool_bits, 0,
|
||||
((hba[i]->nr_cmds + BITS_PER_LONG -
|
||||
1) / BITS_PER_LONG) * sizeof(unsigned long));
|
||||
DIV_ROUND_UP(hba[i]->nr_cmds, BITS_PER_LONG)
|
||||
* sizeof(unsigned long));
|
||||
|
||||
hba[i]->num_luns = 0;
|
||||
hba[i]->highest_lun = -1;
|
||||
|
@ -424,7 +424,7 @@ static int __init cpqarray_register_ctlr( int i, struct pci_dev *pdev)
|
||||
hba[i]->pci_dev, NR_CMDS * sizeof(cmdlist_t),
|
||||
&(hba[i]->cmd_pool_dhandle));
|
||||
hba[i]->cmd_pool_bits = kcalloc(
|
||||
(NR_CMDS+BITS_PER_LONG-1)/BITS_PER_LONG, sizeof(unsigned long),
|
||||
DIV_ROUND_UP(NR_CMDS, BITS_PER_LONG), sizeof(unsigned long),
|
||||
GFP_KERNEL);
|
||||
|
||||
if (!hba[i]->cmd_pool_bits || !hba[i]->cmd_pool)
|
||||
|
@ -1355,20 +1355,20 @@ static void fdc_specify(void)
|
||||
}
|
||||
|
||||
/* Convert step rate from microseconds to milliseconds and 4 bits */
|
||||
srt = 16 - (DP->srt * scale_dtr / 1000 + NOMINAL_DTR - 1) / NOMINAL_DTR;
|
||||
srt = 16 - DIV_ROUND_UP(DP->srt * scale_dtr / 1000, NOMINAL_DTR);
|
||||
if (slow_floppy) {
|
||||
srt = srt / 4;
|
||||
}
|
||||
SUPBOUND(srt, 0xf);
|
||||
INFBOUND(srt, 0);
|
||||
|
||||
hlt = (DP->hlt * scale_dtr / 2 + NOMINAL_DTR - 1) / NOMINAL_DTR;
|
||||
hlt = DIV_ROUND_UP(DP->hlt * scale_dtr / 2, NOMINAL_DTR);
|
||||
if (hlt < 0x01)
|
||||
hlt = 0x01;
|
||||
else if (hlt > 0x7f)
|
||||
hlt = hlt_max_code;
|
||||
|
||||
hut = (DP->hut * scale_dtr / 16 + NOMINAL_DTR - 1) / NOMINAL_DTR;
|
||||
hut = DIV_ROUND_UP(DP->hut * scale_dtr / 16, NOMINAL_DTR);
|
||||
if (hut < 0x1)
|
||||
hut = 0x1;
|
||||
else if (hut > 0xf)
|
||||
@ -2385,7 +2385,7 @@ static void rw_interrupt(void)
|
||||
|
||||
#ifdef FLOPPY_SANITY_CHECK
|
||||
if (nr_sectors / ssize >
|
||||
(in_sector_offset + current_count_sectors + ssize - 1) / ssize) {
|
||||
DIV_ROUND_UP(in_sector_offset + current_count_sectors, ssize)) {
|
||||
DPRINT("long rw: %x instead of %lx\n",
|
||||
nr_sectors, current_count_sectors);
|
||||
printk("rs=%d s=%d\n", R_SECTOR, SECTOR);
|
||||
|
Loading…
Reference in New Issue
Block a user