aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/block
diff options
context:
space:
mode:
authorJulia Lawall <julia@diku.dk>2008-09-22 17:57:16 -0400
committerJens Axboe <jens.axboe@oracle.com>2008-10-09 02:56:19 -0400
commit061837bc8687edc2739ef02f721b7ae0b8076390 (patch)
treee1c59ea7212949a91b2cf19ed125c0db24052b29 /drivers/block
parent905bd78f2188da69e74966918e3d71df3dff382b (diff)
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>
Diffstat (limited to 'drivers/block')
-rw-r--r--drivers/block/cciss.c8
-rw-r--r--drivers/block/cpqarray.c2
-rw-r--r--drivers/block/floppy.c8
3 files changed, 9 insertions, 9 deletions
diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c
index b73116ef9236..1e1f9153000c 100644
--- a/drivers/block/cciss.c
+++ b/drivers/block/cciss.c
@@ -3460,8 +3460,8 @@ static int __devinit cciss_init_one(struct pci_dev *pdev,
3460 hba[i]->intr[SIMPLE_MODE_INT], dac ? "" : " not"); 3460 hba[i]->intr[SIMPLE_MODE_INT], dac ? "" : " not");
3461 3461
3462 hba[i]->cmd_pool_bits = 3462 hba[i]->cmd_pool_bits =
3463 kmalloc(((hba[i]->nr_cmds + BITS_PER_LONG - 3463 kmalloc(DIV_ROUND_UP(hba[i]->nr_cmds, BITS_PER_LONG)
3464 1) / BITS_PER_LONG) * sizeof(unsigned long), GFP_KERNEL); 3464 * sizeof(unsigned long), GFP_KERNEL);
3465 hba[i]->cmd_pool = (CommandList_struct *) 3465 hba[i]->cmd_pool = (CommandList_struct *)
3466 pci_alloc_consistent(hba[i]->pdev, 3466 pci_alloc_consistent(hba[i]->pdev,
3467 hba[i]->nr_cmds * sizeof(CommandList_struct), 3467 hba[i]->nr_cmds * sizeof(CommandList_struct),
@@ -3493,8 +3493,8 @@ static int __devinit cciss_init_one(struct pci_dev *pdev,
3493 /* command and error info recs zeroed out before 3493 /* command and error info recs zeroed out before
3494 they are used */ 3494 they are used */
3495 memset(hba[i]->cmd_pool_bits, 0, 3495 memset(hba[i]->cmd_pool_bits, 0,
3496 ((hba[i]->nr_cmds + BITS_PER_LONG - 3496 DIV_ROUND_UP(hba[i]->nr_cmds, BITS_PER_LONG)
3497 1) / BITS_PER_LONG) * sizeof(unsigned long)); 3497 * sizeof(unsigned long));
3498 3498
3499 hba[i]->num_luns = 0; 3499 hba[i]->num_luns = 0;
3500 hba[i]->highest_lun = -1; 3500 hba[i]->highest_lun = -1;
diff --git a/drivers/block/cpqarray.c b/drivers/block/cpqarray.c
index 09c14341e6e3..3d967525e9a9 100644
--- a/drivers/block/cpqarray.c
+++ b/drivers/block/cpqarray.c
@@ -424,7 +424,7 @@ static int __init cpqarray_register_ctlr( int i, struct pci_dev *pdev)
424 hba[i]->pci_dev, NR_CMDS * sizeof(cmdlist_t), 424 hba[i]->pci_dev, NR_CMDS * sizeof(cmdlist_t),
425 &(hba[i]->cmd_pool_dhandle)); 425 &(hba[i]->cmd_pool_dhandle));
426 hba[i]->cmd_pool_bits = kcalloc( 426 hba[i]->cmd_pool_bits = kcalloc(
427 (NR_CMDS+BITS_PER_LONG-1)/BITS_PER_LONG, sizeof(unsigned long), 427 DIV_ROUND_UP(NR_CMDS, BITS_PER_LONG), sizeof(unsigned long),
428 GFP_KERNEL); 428 GFP_KERNEL);
429 429
430 if (!hba[i]->cmd_pool_bits || !hba[i]->cmd_pool) 430 if (!hba[i]->cmd_pool_bits || !hba[i]->cmd_pool)
diff --git a/drivers/block/floppy.c b/drivers/block/floppy.c
index 395f8ea7981c..9c0b494f5e87 100644
--- a/drivers/block/floppy.c
+++ b/drivers/block/floppy.c
@@ -1355,20 +1355,20 @@ static void fdc_specify(void)
1355 } 1355 }
1356 1356
1357 /* Convert step rate from microseconds to milliseconds and 4 bits */ 1357 /* Convert step rate from microseconds to milliseconds and 4 bits */
1358 srt = 16 - (DP->srt * scale_dtr / 1000 + NOMINAL_DTR - 1) / NOMINAL_DTR; 1358 srt = 16 - DIV_ROUND_UP(DP->srt * scale_dtr / 1000, NOMINAL_DTR);
1359 if (slow_floppy) { 1359 if (slow_floppy) {
1360 srt = srt / 4; 1360 srt = srt / 4;
1361 } 1361 }
1362 SUPBOUND(srt, 0xf); 1362 SUPBOUND(srt, 0xf);
1363 INFBOUND(srt, 0); 1363 INFBOUND(srt, 0);
1364 1364
1365 hlt = (DP->hlt * scale_dtr / 2 + NOMINAL_DTR - 1) / NOMINAL_DTR; 1365 hlt = DIV_ROUND_UP(DP->hlt * scale_dtr / 2, NOMINAL_DTR);
1366 if (hlt < 0x01) 1366 if (hlt < 0x01)
1367 hlt = 0x01; 1367 hlt = 0x01;
1368 else if (hlt > 0x7f) 1368 else if (hlt > 0x7f)
1369 hlt = hlt_max_code; 1369 hlt = hlt_max_code;
1370 1370
1371 hut = (DP->hut * scale_dtr / 16 + NOMINAL_DTR - 1) / NOMINAL_DTR; 1371 hut = DIV_ROUND_UP(DP->hut * scale_dtr / 16, NOMINAL_DTR);
1372 if (hut < 0x1) 1372 if (hut < 0x1)
1373 hut = 0x1; 1373 hut = 0x1;
1374 else if (hut > 0xf) 1374 else if (hut > 0xf)
@@ -2385,7 +2385,7 @@ static void rw_interrupt(void)
2385 2385
2386#ifdef FLOPPY_SANITY_CHECK 2386#ifdef FLOPPY_SANITY_CHECK
2387 if (nr_sectors / ssize > 2387 if (nr_sectors / ssize >
2388 (in_sector_offset + current_count_sectors + ssize - 1) / ssize) { 2388 DIV_ROUND_UP(in_sector_offset + current_count_sectors, ssize)) {
2389 DPRINT("long rw: %x instead of %lx\n", 2389 DPRINT("long rw: %x instead of %lx\n",
2390 nr_sectors, current_count_sectors); 2390 nr_sectors, current_count_sectors);
2391 printk("rs=%d s=%d\n", R_SECTOR, SECTOR); 2391 printk("rs=%d s=%d\n", R_SECTOR, SECTOR);