[Top] [All Lists]

Re: [PATCH] MIPS: rb532: fix bit swapping in rb532_set_bit()

To: Atsushi Nemoto <>
Subject: Re: [PATCH] MIPS: rb532: fix bit swapping in rb532_set_bit()
From: Phil Sutter <>
Date: Mon, 3 Nov 2008 16:05:42 +0100
In-reply-to: <>
Mail-followup-to: Atsushi Nemoto <>,,,
Original-recipient: rfc822;
References: <20081103142942.GA13461@nuty> <> <>
User-agent: Mutt/1.5.11

On Mon, Nov 03, 2008 at 11:48:56PM +0900, Atsushi Nemoto wrote:
> Well, the linux gpio framework uses 0 for low, _nonzero_ for high.
> You should not assume the bitval is 0 or 1.

Good point. I was thinking about this potential problem, too. This is
why the mentioned function contains the following line (sadly too far
off to occur in the patch):

| bitval = !!bitval;              /* map parameter to {0,1} */

I put that separately to not make the below lines even more unreadable.

>       val &= ~(!bitval << offset);   /* unset bit if bitval == 0 */
>       val |= (!!bitval << offset);   /* set bit if bitval != 0 */

But as a boolean inverse has to be used anyway, your solution looks more
elegant than mine.

Greetings, Phil

<Prev in Thread] Current Thread [Next in Thread>