]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
staging: rtl8192e: Prefer using macro DIV_ROUND_UP
authorBhaktipriya Shridhar <bhaktipriya96@gmail.com>
Tue, 8 Mar 2016 17:59:37 +0000 (23:29 +0530)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 12 Mar 2016 06:09:09 +0000 (22:09 -0800)
The macro DIV_ROUND_UP performs the computation
(((n) + (d) - 1) /(d)). It clarifies the divisor calculations.
This was done using the coccinelle script:
@@
expression e1;
expression e2;
@@
(
- ((e1) + e2 - 1) / (e2)
+ DIV_ROUND_UP(e1,e2)
|
- ((e1) + (e2 - 1)) / (e2)
+ DIV_ROUND_UP(e1,e2)
)

Signed-off-by: Bhaktipriya Shridhar <bhaktipriya96@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/rtl8192e/rtllib_crypt_ccmp.c

index 496de4f6a7bcd333568d9afb37a8dc8d59136dab..bc45cf098b04e26a5c8ba425d255f4381a11c2c0 100644 (file)
@@ -233,7 +233,7 @@ static int rtllib_ccmp_encrypt(struct sk_buff *skb, int hdr_len, void *priv)
                ccmp_init_blocks(key->tfm, hdr, key->tx_pn, data_len,
                                 b0, b, s0);
 
-               blocks = (data_len + AES_BLOCK_LEN - 1) / AES_BLOCK_LEN;
+               blocks = DIV_ROUND_UP(data_len, AES_BLOCK_LEN);
                last = data_len % AES_BLOCK_LEN;
 
                for (i = 1; i <= blocks; i++) {
@@ -319,7 +319,7 @@ static int rtllib_ccmp_decrypt(struct sk_buff *skb, int hdr_len, void *priv)
                ccmp_init_blocks(key->tfm, hdr, pn, data_len, b0, a, b);
                xor_block(mic, b, CCMP_MIC_LEN);
 
-               blocks = (data_len + AES_BLOCK_LEN - 1) / AES_BLOCK_LEN;
+               blocks = DIV_ROUND_UP(data_len, AES_BLOCK_LEN);
                last = data_len % AES_BLOCK_LEN;
 
                for (i = 1; i <= blocks; i++) {