X-Git-Url: https://git.openpandora.org/cgi-bin/gitweb.cgi?p=pandora-kernel.git;a=blobdiff_plain;f=drivers%2Fstaging%2Fbatman-adv%2Fbitarray.c;h=814274fbaa2fc278efdf1bafdff8673506fc00f1;hp=dd4193c99d4ec3fc81a1e9ea7cffda247dd11a6c;hb=f063a0c0c995d010960efcc1b2ed14b99674f25c;hpb=5e8530810805858892959b8ebbcec1009ea8c12d diff --git a/drivers/staging/batman-adv/bitarray.c b/drivers/staging/batman-adv/bitarray.c index dd4193c99d4e..814274fbaa2f 100644 --- a/drivers/staging/batman-adv/bitarray.c +++ b/drivers/staging/batman-adv/bitarray.c @@ -22,6 +22,8 @@ #include "main.h" #include "bitarray.h" +#include + /* returns true if the corresponding bit in the given seq_bits indicates true * and curr_seqno is within range of last_seqno */ uint8_t get_bit_status(TYPE_OF_WORD *seq_bits, uint32_t last_seqno, @@ -125,11 +127,10 @@ static void bit_reset_window(TYPE_OF_WORD *seq_bits) * 1 if the window was moved (either new or very old) * 0 if the window was not moved/shifted. */ -char bit_get_packet(TYPE_OF_WORD *seq_bits, int32_t seq_num_diff, - int8_t set_mark) +char bit_get_packet(void *priv, TYPE_OF_WORD *seq_bits, + int32_t seq_num_diff, int8_t set_mark) { - /* FIXME: each orig_node->batman_if will be attached to a softif */ - struct bat_priv *bat_priv = netdev_priv(soft_device); + struct bat_priv *bat_priv = (struct bat_priv *)priv; /* sequence number is slightly older. We already got a sequence number * higher than this one, so we just mark it. */ @@ -187,21 +188,14 @@ char bit_get_packet(TYPE_OF_WORD *seq_bits, int32_t seq_num_diff, } /* count the hamming weight, how many good packets did we receive? just count - * the 1's. The inner loop uses the Kernighan algorithm, see - * http://graphics.stanford.edu/~seander/bithacks.html#CountBitsSetKernighan + * the 1's. */ int bit_packet_count(TYPE_OF_WORD *seq_bits) { int i, hamming = 0; - TYPE_OF_WORD word; - for (i = 0; i < NUM_WORDS; i++) { - word = seq_bits[i]; + for (i = 0; i < NUM_WORDS; i++) + hamming += hweight_long(seq_bits[i]); - while (word) { - word &= word-1; - hamming++; - } - } return hamming; }