[PATCH 3/10] drivers/ieee1394: Use DIV_ROUND_UP - Kernel

This is a discussion on [PATCH 3/10] drivers/ieee1394: Use DIV_ROUND_UP - Kernel ; 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@ ...

+ Reply to Thread
Results 1 to 2 of 2

Thread: [PATCH 3/10] drivers/ieee1394: Use DIV_ROUND_UP

  1. [PATCH 3/10] drivers/ieee1394: Use DIV_ROUND_UP

    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

    ---
    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,
    --
    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/

  2. Re: [PATCH 3/10] drivers/ieee1394: Use DIV_ROUND_UP

    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/
    --
    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/

+ Reply to Thread