| To: | n0-1@freewrt.org |
|---|---|
| Subject: | Re: [PATCH] MIPS: rb532: fix bit swapping in rb532_set_bit() |
| From: | Atsushi Nemoto <anemo@mba.ocn.ne.jp> |
| Date: | Mon, 03 Nov 2008 23:48:56 +0900 (JST) |
| Cc: | ralf@linux-mips.org, sshtylyov@ru.mvista.com, linux-mips@linux-mips.org |
| In-reply-to: | <1225722625-19750-1-git-send-email-n0-1@freewrt.org> |
| Original-recipient: | rfc822;linux-mips@linux-mips.org |
| References: | <20081103142942.GA13461@nuty> <1225722625-19750-1-git-send-email-n0-1@freewrt.org> |
| Sender: | linux-mips-bounce@linux-mips.org |
On Mon, 3 Nov 2008 15:30:25 +0100, Phil Sutter <n0-1@freewrt.org> wrote:
> The algorithm works unconditionally. If bitval is one, the first line is
> a no op and the second line sets the bit at offset position. Vice versa,
> if bitval is zero, the first line clears the bit at offset position and
> the second line is a no op.
Well, the linux gpio framework uses 0 for low, _nonzero_ for high.
You should not assume the bitval is 0 or 1.
val &= ~(!bitval << offset); /* unset bit if bitval == 0 */
val |= (!!bitval << offset); /* set bit if bitval != 0 */
would be safe here. Or you should ensure the bitval is 0 or 1
somewhere.
---
Atsushi Nemoto
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| ||
| Previous by Date: | [PATCH] MIPS: rb532: fix bit swapping in rb532_set_bit(), Phil Sutter |
|---|---|
| Next by Date: | Re: [PATCH] MIPS: rb532: fix bit swapping in rb532_set_bit(), Phil Sutter |
| Previous by Thread: | [PATCH] MIPS: rb532: fix bit swapping in rb532_set_bit(), Phil Sutter |
| Next by Thread: | Re: [PATCH] MIPS: rb532: fix bit swapping in rb532_set_bit(), Phil Sutter |
| Indexes: | [Date] [Thread] [Top] [All Lists] |