#include <linux/export.h>
#include <linux/bug.h>
#include <linux/bitmap.h>

/**
 * memweight - count the total number of bits set in memory area
 * @ptr: pointer to the start of the area
 * @bytes: the size of the area
 */
size_t memweight(const void *ptr, size_t bytes)
{
	size_t ret = 0;
	size_t longs;
	const unsigned char *bitmap = ptr;

	for (; bytes > 0 && ((unsigned long)bitmap) % sizeof(long);
			bytes--, bitmap++)
		ret += hweight8(*bitmap);

	longs = bytes / sizeof(long);
	if (longs) {
		BUG_ON(longs >= INT_MAX / BITS_PER_LONG);
		ret += bitmap_weight((unsigned long *)bitmap,
				longs * BITS_PER_LONG);
		bytes -= longs * sizeof(long);
		bitmap += longs * sizeof(long);
	}
	/*
	 * The reason that this last loop is distinct from the preceding
	 * bitmap_weight() call is to compute 1-bits in the last region smaller
	 * than sizeof(long) properly on big-endian systems.
	 */
	for (; bytes > 0; bytes--, bitmap++)
		ret += hweight8(*bitmap);

	return ret;
}
EXPORT_SYMBOL(memweight);
='emaclite-cleanup'>emaclite-cleanup</option>
<option value='master' selected='selected'>master</option>
<option value='nds-private-remove'>nds-private-remove</option>
<option value='packet-loop-back'>packet-loop-back</option>
<option value='packet-rx-pump-back'>packet-rx-pump-back</option>
</select> <input type='submit' value='switch'/></form></td></tr>
<tr><td class='sub'>net-next plumbings</td><td class='sub right'>Tobias Klauser</td></tr></table>
<table class='tabs'><tr><td>
<a href='/cgit.cgi/linux/net-next.git/'>summary</a><a href='/cgit.cgi/linux/net-next.git/refs/?id=f35581d64e55fc65753a62957b3b98127d560d07'>refs</a><a class='active' href='/cgit.cgi/linux/net-next.git/log/sound/soc/pxa/pxa2xx-i2s.h'>log</a><a href='/cgit.cgi/linux/net-next.git/tree/sound/soc/pxa/pxa2xx-i2s.h?id=f35581d64e55fc65753a62957b3b98127d560d07'>tree</a><a href='/cgit.cgi/linux/net-next.git/commit/sound/soc/pxa/pxa2xx-i2s.h?id=f35581d64e55fc65753a62957b3b98127d560d07'>commit</a><a href='/cgit.cgi/linux/net-next.git/diff/sound/soc/pxa/pxa2xx-i2s.h?id=f35581d64e55fc65753a62957b3b98127d560d07'>diff</a></td><td class='form'><form class='right' method='get' action='/cgit.cgi/linux/net-next.git/log/sound/soc/pxa/pxa2xx-i2s.h'>
<input type='hidden' name='id' value='f35581d64e55fc65753a62957b3b98127d560d07'/><select name='qt'>
<option value='grep'>log msg</option>
<option value='author'>author</option>
<option value='committer'>committer</option>
<option value='range'>range</option>
</select>
<input class='txt' type='search' size='10' name='q' value=''/>
<input type='submit' value='search'/>
</form>
</td></tr></table>
<div class='path'>path: <a href='/cgit.cgi/linux/net-next.git/log/?id=f35581d64e55fc65753a62957b3b98127d560d07'>root</a>/<a href='/cgit.cgi/linux/net-next.git/log/sound?id=f35581d64e55fc65753a62957b3b98127d560d07'>sound</a>/<a href='/cgit.cgi/linux/net-next.git/log/sound/soc?id=f35581d64e55fc65753a62957b3b98127d560d07'>soc</a>/<a href='/cgit.cgi/linux/net-next.git/log/sound/soc/pxa?id=f35581d64e55fc65753a62957b3b98127d560d07'>pxa</a>/<a href='/cgit.cgi/linux/net-next.git/log/sound/soc/pxa/pxa2xx-i2s.h?id=f35581d64e55fc65753a62957b3b98127d560d07'>pxa2xx-i2s.h</a></div><div class='content'><table class='list nowrap'><tr class='nohover'><th class='left'>Age</th><th class='left'>Commit message (<a href='/cgit.cgi/linux/net-next.git/log/sound/soc/pxa/pxa2xx-i2s.h?id=f35581d64e55fc65753a62957b3b98127d560d07&amp;showmsg=1'>Expand</a>)</th><th class='left'>Author</th><th class='left'>Files</th><th class='left'>Lines</th></tr>