projects
/
yaffs2.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
yaffs : Change bitmap counting function to use hweight8()
[yaffs2.git]
/
yaffs_bitmap.c
diff --git
a/yaffs_bitmap.c
b/yaffs_bitmap.c
index 85c8c1d83c032dfcb834a29c3a0ab54765ad5d7e..b2542660b22a5ee12c86a662cedbe45c7abec3af 100644
(file)
--- a/
yaffs_bitmap.c
+++ b/
yaffs_bitmap.c
@@
-17,65
+17,65
@@
* Chunk bitmap manipulations
*/
* Chunk bitmap manipulations
*/
-static Y_INLINE
__u8 *yaffs_block_bits(yaffs_dev_t
*dev, int blk)
+static Y_INLINE
u8 *yaffs_block_bits(struct yaffs_dev
*dev, int blk)
{
if (blk < dev->internal_start_block || blk > dev->internal_end_block) {
T(YAFFS_TRACE_ERROR,
{
if (blk < dev->internal_start_block || blk > dev->internal_end_block) {
T(YAFFS_TRACE_ERROR,
-
(TSTR("**>> yaffs: BlockBits block %d is not valid" TENDSTR),
-
blk));
+ (TSTR("**>> yaffs: BlockBits block %d is not valid" TENDSTR),
+ blk));
YBUG();
}
return dev->chunk_bits +
YBUG();
}
return dev->chunk_bits +
-
(dev->chunk_bit_stride * (blk - dev->internal_start_block));
+ (dev->chunk_bit_stride * (blk - dev->internal_start_block));
}
}
-void yaffs_verify_chunk_bit_id(
yaffs_dev_t
*dev, int blk, int chunk)
+void yaffs_verify_chunk_bit_id(
struct yaffs_dev
*dev, int blk, int chunk)
{
if (blk < dev->internal_start_block || blk > dev->internal_end_block ||
{
if (blk < dev->internal_start_block || blk > dev->internal_end_block ||
-
chunk < 0 || chunk >= dev->param.chunks_per_block) {
+ chunk < 0 || chunk >= dev->param.chunks_per_block) {
T(YAFFS_TRACE_ERROR,
T(YAFFS_TRACE_ERROR,
-
(TSTR("**>> yaffs: Chunk Id (%d:%d) invalid"
TENDSTR),
-
blk, chunk));
+
(TSTR("**>> yaffs: Chunk Id (%d:%d) invalid"
TENDSTR),
+ blk, chunk));
YBUG();
}
}
YBUG();
}
}
-void yaffs_clear_chunk_bits(
yaffs_dev_t
*dev, int blk)
+void yaffs_clear_chunk_bits(
struct yaffs_dev
*dev, int blk)
{
{
-
__
u8 *blk_bits = yaffs_block_bits(dev, blk);
+ u8 *blk_bits = yaffs_block_bits(dev, blk);
memset(blk_bits, 0, dev->chunk_bit_stride);
}
memset(blk_bits, 0, dev->chunk_bit_stride);
}
-void yaffs_clear_chunk_bit(
yaffs_dev_t
*dev, int blk, int chunk)
+void yaffs_clear_chunk_bit(
struct yaffs_dev
*dev, int blk, int chunk)
{
{
-
__
u8 *blk_bits = yaffs_block_bits(dev, blk);
+ u8 *blk_bits = yaffs_block_bits(dev, blk);
yaffs_verify_chunk_bit_id(dev, blk, chunk);
blk_bits[chunk / 8] &= ~(1 << (chunk & 7));
}
yaffs_verify_chunk_bit_id(dev, blk, chunk);
blk_bits[chunk / 8] &= ~(1 << (chunk & 7));
}
-void yaffs_set_chunk_bit(
yaffs_dev_t
*dev, int blk, int chunk)
+void yaffs_set_chunk_bit(
struct yaffs_dev
*dev, int blk, int chunk)
{
{
-
__
u8 *blk_bits = yaffs_block_bits(dev, blk);
+ u8 *blk_bits = yaffs_block_bits(dev, blk);
yaffs_verify_chunk_bit_id(dev, blk, chunk);
blk_bits[chunk / 8] |= (1 << (chunk & 7));
}
yaffs_verify_chunk_bit_id(dev, blk, chunk);
blk_bits[chunk / 8] |= (1 << (chunk & 7));
}
-int yaffs_check_chunk_bit(
yaffs_dev_t
*dev, int blk, int chunk)
+int yaffs_check_chunk_bit(
struct yaffs_dev
*dev, int blk, int chunk)
{
{
-
__
u8 *blk_bits = yaffs_block_bits(dev, blk);
+ u8 *blk_bits = yaffs_block_bits(dev, blk);
yaffs_verify_chunk_bit_id(dev, blk, chunk);
return (blk_bits[chunk / 8] & (1 << (chunk & 7))) ? 1 : 0;
}
yaffs_verify_chunk_bit_id(dev, blk, chunk);
return (blk_bits[chunk / 8] & (1 << (chunk & 7))) ? 1 : 0;
}
-int yaffs_still_some_chunks(
yaffs_dev_t
*dev, int blk)
+int yaffs_still_some_chunks(
struct yaffs_dev
*dev, int blk)
{
{
-
__
u8 *blk_bits = yaffs_block_bits(dev, blk);
+ u8 *blk_bits = yaffs_block_bits(dev, blk);
int i;
for (i = 0; i < dev->chunk_bit_stride; i++) {
if (*blk_bits)
int i;
for (i = 0; i < dev->chunk_bit_stride; i++) {
if (*blk_bits)
@@
-85,21
+85,14
@@
int yaffs_still_some_chunks(yaffs_dev_t *dev, int blk)
return 0;
}
return 0;
}
-int yaffs_count_chunk_bits(
yaffs_dev_t
*dev, int blk)
+int yaffs_count_chunk_bits(
struct yaffs_dev
*dev, int blk)
{
{
-
__
u8 *blk_bits = yaffs_block_bits(dev, blk);
+ u8 *blk_bits = yaffs_block_bits(dev, blk);
int i;
int n = 0;
int i;
int n = 0;
- for (i = 0; i < dev->chunk_bit_stride; i++) {
- __u8 x = *blk_bits;
- while (x) {
- if (x & 1)
- n++;
- x >>= 1;
- }
- blk_bits++;
- }
+ for (i = 0; i < dev->chunk_bit_stride; i++, blk_bits++)
+ n += hweight8(*blk_bits);
+
return n;
}
return n;
}
-