* [patch 0/1] s390: claw - More use DIV_ROUND_UP
@ 2008-02-18 13:41 Ursula Braun
2008-02-18 13:41 ` [patch 1/1] claw: make use of DIV_ROUND_UP Ursula Braun
0 siblings, 1 reply; 3+ messages in thread
From: Ursula Braun @ 2008-02-18 13:41 UTC (permalink / raw)
To: jgarzik, netdev, linux-s390, julia
--
Jeff,
this patch is intended for 2.6.25.
It makes use of the DIV_ROUND_UP function as proposed by Julia Lawall.
Regards, Ursula Braun
^ permalink raw reply [flat|nested] 3+ messages in thread
* [patch 1/1] claw: make use of DIV_ROUND_UP
2008-02-18 13:41 [patch 0/1] s390: claw - More use DIV_ROUND_UP Ursula Braun
@ 2008-02-18 13:41 ` Ursula Braun
2008-02-20 16:51 ` Jeff Garzik
0 siblings, 1 reply; 3+ messages in thread
From: Ursula Braun @ 2008-02-18 13:41 UTC (permalink / raw)
To: jgarzik, netdev, linux-s390, julia
[-- Attachment #1: 715-claw-div.diff --]
[-- Type: text/plain, Size: 3391 bytes --]
From: Julia Lawall <julia@diku.dk>
The kernel.h macro DIV_ROUND_UP performs the computation
(((n) + (d) - 1) / (d)) but is perhaps more readable.
Signed-off-by: Ursula Braun <braunu@de.ibm.com>
---
drivers/s390/net/claw.c | 39 ++++++++++++++++++---------------------
1 file changed, 18 insertions(+), 21 deletions(-)
Index: linux-2.6-uschi/drivers/s390/net/claw.c
===================================================================
--- linux-2.6-uschi.orig/drivers/s390/net/claw.c
+++ linux-2.6-uschi/drivers/s390/net/claw.c
@@ -1851,8 +1851,7 @@ claw_hw_tx(struct sk_buff *skb, struct n
}
}
/* See how many write buffers are required to hold this data */
- numBuffers= ( skb->len + privptr->p_env->write_size - 1) /
- ( privptr->p_env->write_size);
+ numBuffers = DIV_ROUND_UP(skb->len, privptr->p_env->write_size);
/* If that number of buffers isn't available, give up for now */
if (privptr->write_free_count < numBuffers ||
@@ -2114,8 +2113,7 @@ init_ccw_bk(struct net_device *dev)
*/
ccw_blocks_perpage= PAGE_SIZE / CCWBK_SIZE;
ccw_pages_required=
- (ccw_blocks_required+ccw_blocks_perpage -1) /
- ccw_blocks_perpage;
+ DIV_ROUND_UP(ccw_blocks_required, ccw_blocks_perpage);
#ifdef DEBUGMSG
printk(KERN_INFO "%s: %s() > ccw_blocks_perpage=%d\n",
@@ -2131,30 +2129,29 @@ init_ccw_bk(struct net_device *dev)
* provide good performance. With packing buffers support 32k
* buffers are used.
*/
- if (privptr->p_env->read_size < PAGE_SIZE) {
- claw_reads_perpage= PAGE_SIZE / privptr->p_env->read_size;
- claw_read_pages= (privptr->p_env->read_buffers +
- claw_reads_perpage -1) / claw_reads_perpage;
+ if (privptr->p_env->read_size < PAGE_SIZE) {
+ claw_reads_perpage = PAGE_SIZE / privptr->p_env->read_size;
+ claw_read_pages = DIV_ROUND_UP(privptr->p_env->read_buffers,
+ claw_reads_perpage);
}
else { /* > or equal */
- privptr->p_buff_pages_perread=
- (privptr->p_env->read_size + PAGE_SIZE - 1) / PAGE_SIZE;
- claw_read_pages=
- privptr->p_env->read_buffers * privptr->p_buff_pages_perread;
+ privptr->p_buff_pages_perread =
+ DIV_ROUND_UP(privptr->p_env->read_size, PAGE_SIZE);
+ claw_read_pages = privptr->p_env->read_buffers *
+ privptr->p_buff_pages_perread;
}
if (privptr->p_env->write_size < PAGE_SIZE) {
- claw_writes_perpage=
- PAGE_SIZE / privptr->p_env->write_size;
- claw_write_pages=
- (privptr->p_env->write_buffers + claw_writes_perpage -1) /
- claw_writes_perpage;
+ claw_writes_perpage =
+ PAGE_SIZE / privptr->p_env->write_size;
+ claw_write_pages = DIV_ROUND_UP(privptr->p_env->write_buffers,
+ claw_writes_perpage);
}
else { /* > or equal */
- privptr->p_buff_pages_perwrite=
- (privptr->p_env->read_size + PAGE_SIZE - 1) / PAGE_SIZE;
- claw_write_pages=
- privptr->p_env->write_buffers * privptr->p_buff_pages_perwrite;
+ privptr->p_buff_pages_perwrite =
+ DIV_ROUND_UP(privptr->p_env->read_size, PAGE_SIZE);
+ claw_write_pages = privptr->p_env->write_buffers *
+ privptr->p_buff_pages_perwrite;
}
#ifdef DEBUGMSG
if (privptr->p_env->read_size < PAGE_SIZE) {
--
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [patch 1/1] claw: make use of DIV_ROUND_UP
2008-02-18 13:41 ` [patch 1/1] claw: make use of DIV_ROUND_UP Ursula Braun
@ 2008-02-20 16:51 ` Jeff Garzik
0 siblings, 0 replies; 3+ messages in thread
From: Jeff Garzik @ 2008-02-20 16:51 UTC (permalink / raw)
To: Ursula Braun; +Cc: netdev, linux-s390, julia
applied
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2008-02-20 16:51 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-02-18 13:41 [patch 0/1] s390: claw - More use DIV_ROUND_UP Ursula Braun
2008-02-18 13:41 ` [patch 1/1] claw: make use of DIV_ROUND_UP Ursula Braun
2008-02-20 16:51 ` Jeff Garzik
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).