From: Ivo van Doorn <ivdoorn@gmail.com>
To: "John Linville" <linville@tuxdriver.com>
Cc: wireless <linux-wireless@vger.kernel.org>
Subject: Re: [PATCH 4/4] rt2x00: Fix power of 2 check
Date: Fri, 9 Mar 2007 11:18:39 +0100 [thread overview]
Message-ID: <200703091118.39371.IvDoorn@gmail.com> (raw)
In-Reply-To: <200703082214.52864.IvDoorn@gmail.com>
On Thursday 08 March 2007 22:14, Ivo van Doorn wrote:
> Cleanup code, make gcc happy, make sparse happy. What a happy patch ;)
> This cleans up the code used to check the validity of the register fields,
> this will also reduce the required memory usage while working with sparse.
> This patch was inspired on the codesuggestions from Linus.
Please cancel this 4th patch, the previous 3 were correct but this one is terribly wrong.
> +#define is_power_of_two(x) ( !((x) & ((x)-1)) )
> +#define low_bit_mask(x) ( ((x)-1) & ~(x) )
> +#define is_valid_mask(x) is_power_of_two(1 + (x) + low_bit_mask(x))
> +
> +#define FIELD16(__mask) \
> +({ \
> + BUILD_BUG_ON(!__mask || !is_valid_mask(__mask));\
> + (struct rt2x00_field16) { \
> + (__scanbit((__mask), 16) - 1), (__mask) \
> + }; \
> +})
> +
> +#define FIELD32(__mask) \
> +({ \
> + BUILD_BUG_ON(!__mask || !is_valid_mask(__mask));\
> + (struct rt2x00_field32) { \
> + (__scanbit((__mask), 32) - 1), (__mask) \
> + }; \
> +})
The problem is here, I have used __scanbit to determine the first bit
that is set. __scanbit was used since this doesn't require a pointer to the value
while the other functions do require the pointer (and the macro receives the direct
value hence the reason for the __scanbit choice).
Unfortunately I did not check if __scanbit was available on all arches, and this one
seems to only excist for x86_64.. :S
I'll try to fix this asap and come with a new patch.
Ivo
next prev parent reply other threads:[~2007-03-09 10:18 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-03-08 21:14 [PATCH 4/4] rt2x00: Fix power of 2 check Ivo van Doorn
2007-03-09 10:18 ` Ivo van Doorn [this message]
2007-03-09 10:48 ` [PATCH v2] " Ivo van Doorn
2007-03-09 15:11 ` [PATCH v3] " Ivo van Doorn
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200703091118.39371.IvDoorn@gmail.com \
--to=ivdoorn@gmail.com \
--cc=linux-wireless@vger.kernel.org \
--cc=linville@tuxdriver.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).