lkml.org 
[lkml]   [2012]   [Jun]   [2]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH v2 04/10] dm: use memweight()
    Date
    Use memweight() to count the total number of bits set in memory area.

    Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
    Cc: Alasdair Kergon <agk@redhat.com>
    Cc: dm-devel@redhat.com
    ---

    v2: change patch title s/dm-log:/dm:/

    drivers/md/dm-log.c | 13 ++-----------
    1 files changed, 2 insertions(+), 11 deletions(-)

    diff --git a/drivers/md/dm-log.c b/drivers/md/dm-log.c
    index 65ebaeb..627d191 100644
    --- a/drivers/md/dm-log.c
    +++ b/drivers/md/dm-log.c
    @@ -571,16 +571,6 @@ static void disk_dtr(struct dm_dirty_log *log)
    destroy_log_context(lc);
    }

    -static int count_bits32(uint32_t *addr, unsigned size)
    -{
    - int count = 0, i;
    -
    - for (i = 0; i < size; i++) {
    - count += hweight32(*(addr+i));
    - }
    - return count;
    -}
    -
    static void fail_log_device(struct log_c *lc)
    {
    if (lc->log_dev_failed)
    @@ -629,7 +619,8 @@ static int disk_resume(struct dm_dirty_log *log)

    /* copy clean across to sync */
    memcpy(lc->sync_bits, lc->clean_bits, size);
    - lc->sync_count = count_bits32(lc->clean_bits, lc->bitset_uint32_count);
    + lc->sync_count = memweight(lc->clean_bits,
    + lc->bitset_uint32_count * sizeof(uint32_t));
    lc->sync_search = 0;

    /* set the correct number of regions in the header */
    --
    1.7.7.6


    \
     
     \ /
      Last update: 2012-06-02 16:01    [W:0.022 / U:1.696 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site