aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/block/floppy.c
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/floppy.c
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/floppy.c')
-rw-r--r--drivers/block/floppy.c8
1 files changed, 4 insertions, 4 deletions
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);