mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 3/10] drivers/ieee1394: Use DIV_ROUND_UP
@ 2008-08-02 15:13 Julia Lawall
  2008-08-02 18:16 ` Stefan Richter
  0 siblings, 1 reply; 2+ messages in thread
From: Julia Lawall @ 2008-08-02 15:13 UTC (permalink / raw)
  To: ben.collins, stefanr, linux1394-devel, linux-kernel, kernel-janitors

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.

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>

---
 drivers/ieee1394/csr1212.c |    2 +-
 drivers/ieee1394/eth1394.c |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff -u -p a/drivers/ieee1394/csr1212.c b/drivers/ieee1394/csr1212.c
--- a/drivers/ieee1394/csr1212.c
+++ b/drivers/ieee1394/csr1212.c
@@ -84,7 +84,7 @@ static const u8 csr1212_key_id_type_map[
 
 
 #define quads_to_bytes(_q) ((_q) * sizeof(u32))
-#define bytes_to_quads(_b) (((_b) + sizeof(u32) - 1) / sizeof(u32))
+#define bytes_to_quads(_b) DIV_ROUND_UP(_b, sizeof(u32))
 
 static void free_keyval(struct csr1212_keyval *kv)
 {
diff -u -p a/drivers/ieee1394/eth1394.c b/drivers/ieee1394/eth1394.c
--- a/drivers/ieee1394/eth1394.c
+++ b/drivers/ieee1394/eth1394.c
@@ -1361,7 +1361,7 @@ static unsigned int ether1394_encapsulat
 		hdr->ff.dgl = dgl;
 		adj_max_payload = max_payload - hdr_type_len[ETH1394_HDR_LF_FF];
 	}
-	return (dg_size + adj_max_payload - 1) / adj_max_payload;
+	return DIV_ROUND_UP(dg_size, adj_max_payload);
 }
 
 static unsigned int ether1394_encapsulate(struct sk_buff *skb,

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH 3/10] drivers/ieee1394: Use DIV_ROUND_UP
  2008-08-02 15:13 [PATCH 3/10] drivers/ieee1394: Use DIV_ROUND_UP Julia Lawall
@ 2008-08-02 18:16 ` Stefan Richter
  0 siblings, 0 replies; 2+ messages in thread
From: Stefan Richter @ 2008-08-02 18:16 UTC (permalink / raw)
  To: Julia Lawall; +Cc: ben.collins, linux1394-devel, linux-kernel, kernel-janitors

Julia Lawall wrote:
> -#define bytes_to_quads(_b) (((_b) + sizeof(u32) - 1) / sizeof(u32))
> +#define bytes_to_quads(_b) DIV_ROUND_UP(_b, sizeof(u32))
...
> -	return (dg_size + adj_max_payload - 1) / adj_max_payload;
> +	return DIV_ROUND_UP(dg_size, adj_max_payload);

I cut the changelog down to the necessary and committed it to 
linux1394-2.6.git.  Thanks,
-- 
Stefan Richter
-=====-==--- =--- ---=-
http://arcgraph.de/sr/

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2008-08-02 18:16 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-08-02 15:13 [PATCH 3/10] drivers/ieee1394: Use DIV_ROUND_UP Julia Lawall
2008-08-02 18:16 ` Stefan Richter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®