Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755239AbYBNPOy (ORCPT ); Thu, 14 Feb 2008 10:14:54 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1751997AbYBNPOn (ORCPT ); Thu, 14 Feb 2008 10:14:43 -0500 Received: from mgw1.diku.dk ([130.225.96.91]:57910 "EHLO mgw1.diku.dk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755353AbYBNPOm (ORCPT ); Thu, 14 Feb 2008 10:14:42 -0500 Date: Thu, 14 Feb 2008 16:14:33 +0100 (MET) From: Julia Lawall To: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org Subject: [PATCH 2/6] fs/direct-io.c: Use DIV_ROUND_UP Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1729 Lines: 71 From: Julia Lawall 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/) // @haskernel@ @@ #include @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) // Signed-off-by: Julia Lawall --- diff -u -p a/fs/direct-io.c b/fs/direct-io.c --- a/fs/direct-io.c 2008-02-08 08:58:17.000000000 +0100 +++ b/fs/direct-io.c 2008-02-13 20:58:53.000000000 +0100 @@ -976,7 +976,7 @@ direct_io_worker(int rw, struct kiocb *i for (seg = 0; seg < nr_segs; seg++) { user_addr = (unsigned long)iov[seg].iov_base; dio->pages_in_io += - ((user_addr+iov[seg].iov_len +PAGE_SIZE-1)/PAGE_SIZE + (DIV_ROUND_UP(user_addr + iov[seg].iov_len, PAGE_SIZE) - user_addr/PAGE_SIZE); } @@ -998,7 +998,7 @@ direct_io_worker(int rw, struct kiocb *i dio->total_pages++; bytes -= PAGE_SIZE - (user_addr & (PAGE_SIZE - 1)); } - dio->total_pages += (bytes + PAGE_SIZE - 1) / PAGE_SIZE; + dio->total_pages += DIV_ROUND_UP(bytes, PAGE_SIZE); dio->curr_user_address = user_addr; ret = do_direct_IO(dio); -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/