From: Arnd Bergmann Subject: Re: [PATCH 5/7] omfs: add bitmap routines Date: Fri, 28 Mar 2008 04:51:10 +0100 Message-ID: <200803280451.11216.arnd@arndb.de> References: <1206578760-9050-5-git-send-email-me@bobcopeland.com> Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-15" Content-Transfer-Encoding: 7bit Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org To: Bob Copeland Return-path: In-Reply-To: <1206578760-9050-5-git-send-email-me@bobcopeland.com> Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-Id: linux-fsdevel.vger.kernel.org On Thursday 27 March 2008, Bob Copeland wrote: > +static int nibblemap[] = {4, 3, 3, 2, 3, 2, 2, 1, 3, 2, 2, 1, 2, 1, 1, 0}; > + > +unsigned long omfs_count_free(struct super_block *sb) > +{ > + unsigned int i, j, count = 0; > + unsigned char *map; > + unsigned long sum = 0; > + struct omfs_sb_info *sbi = OMFS_SB(sb); > + > + for (i = 0; i < sbi->s_imap_size; i++) { > + map = (unsigned char *) sbi->s_imap[i]; > + for (j = 0; j < sb->s_blocksize && > + count + j < sbi->s_num_blocks/8; j++) > + sum += nibblemap[map[j] & 0xf] + > + nibblemap[(map[j] >> 4) & 0xf]; > + count += sb->s_blocksize; > + } > + return sum; > +} I think it would be helpful to express this using hweight64.