Received: from mail.onstor.com (66.201.51.107) by exch1.onstor.net
 (10.0.0.225) with Microsoft SMTP Server id 8.1.311.2; Tue, 11 Nov 2008
 15:11:01 -0800
Received: from dalesmta2-2.messageone.com ([129.41.169.249]) by
 mail.onstor.com with Microsoft SMTPSVC(6.0.3790.3959);	 Tue, 11 Nov 2008
 15:11:00 -0800
Received: from ftp.linux-mips.org (ftp.linux-mips.org [213.58.128.207])	by
 dalesmta2-2.messageone.com (8.13.8/8.13.8) with ESMTP id mABNAx6C023713	for
 <andy.sharp@onstor.com>; Tue, 11 Nov 2008 17:10:59 -0600
Received: from localhost.localdomain ([127.0.0.1]:34793 "EHLO
	ftp.linux-mips.org") by ftp.linux-mips.org with ESMTP	id S23620711AbYKKXKB
 (ORCPT <rfc822;andy.sharp@onstor.com>);	Tue, 11 Nov 2008 23:10:01 +0000
Received: with ECARTIS (v1.0.0; list linux-mips); Tue, 11 Nov 2008 23:09:45
 +0000 (GMT)
Received: from orbit.nwl.cc ([81.169.176.177]:46493 "EHLO
	mail.ifyouseekate.net") by ftp.linux-mips.org with ESMTP	id S23619944AbYKKXJm
 (ORCPT <rfc822;linux-mips@linux-mips.org>);	Tue, 11 Nov 2008 23:09:42 +0000
Received: from base (localhost [127.0.0.1])	by mail.ifyouseekate.net (Postfix)
 with ESMTP id 2210938F995C;	Wed, 12 Nov 2008 00:09:35 +0100 (CET)
From: Phil Sutter <n0-1@freewrt.org>
To: "ralf@linux-mips.org" <ralf@linux-mips.org>
CC: "linux-mips@linux-mips.org" <linux-mips@linux-mips.org>
Sender: "linux-mips-bounce@linux-mips.org" <linux-mips-bounce@linux-mips.org>
Date: Tue, 11 Nov 2008 15:09:30 -0800
Subject: [PATCH] MIPS: rb532: fix bit swapping in rb532_set_bit()
Thread-Topic: [PATCH] MIPS: rb532: fix bit swapping in rb532_set_bit()
Thread-Index: AclEUsNykWiUZbMdSGiqHPu5/sBR6Q==
Message-ID: <1226444970-29272-1-git-send-email-n0-1@freewrt.org>
References: <20081103150542.GB13461@nuty>
In-Reply-To: <20081103150542.GB13461@nuty>
Accept-Language: en-US
Content-Language: en-US
X-MS-Exchange-Organization-AuthAs: Internal
X-MS-Exchange-Organization-AuthMechanism: 0b
X-MS-Exchange-Organization-AuthSource: exch1.onstor.net
X-MS-Has-Attach:
X-Auto-Response-Suppress: All
X-MS-TNEF-Correlator:
x-originalarrivaltime: 11 Nov 2008 23:11:01.0000 (UTC)
 FILETIME=[C337F080:01C94452]
errors-to: linux-mips-bounce@linux-mips.org
x-ems-proccessed: 2K3Xl1OQTInXD6xxuA8z3Q==
x-ems-stamp: LQejEacRoIqd643uTMj3wA==
x-messageone-virus-version: vendor=fsecure
 engine=4.65.7400:2.4.4,1.2.40,4.0.164
 definitions=2008-11-11_17:2008-11-10,2008-11-11,2008-11-11 signatures=0
x-messageone-virus-scanned: Clean
x-messageone-envelope-sender: linux-mips-bounce@linux-mips.org
x-messageone-spam-details: rule=m773emszm_notspam policy=m773emszm score=0
 spamscore=0 ipscore=0 phishscore=0 bulkscore=0 adultscore=0 classifier=spam
 adjust=0 reason=mlx engine=3.1.0-0810130000 definitions=main-0811110162
x-messageone-spam-score: 0
x-messageone-spam-bar:
x-list: linux-mips
x-archive-position: 21251
x-ecartis-version: Ecartis v1.0.0
x-original-sender: n0-1@freewrt.org
Content-Type: text/plain; charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
MIME-Version: 1.0

This is a simplified version of the original fix, thanks to Atsushi Nemoto =
for
the hint.

Greetings, Phil

---

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.

Signed-off-by: Phil Sutter <n0-1@freewrt.org>
---
 arch/mips/rb532/gpio.c |    6 ++----
 1 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/arch/mips/rb532/gpio.c b/arch/mips/rb532/gpio.c
index 0e84c8a..e35cb75 100644
--- a/arch/mips/rb532/gpio.c
+++ b/arch/mips/rb532/gpio.c
@@ -119,13 +119,11 @@ static inline void rb532_set_bit(unsigned bitval,
 	unsigned long flags;
 	u32 val;
=20
-	bitval =3D !!bitval;              /* map parameter to {0,1} */
-
 	local_irq_save(flags);
=20
 	val =3D readl(ioaddr);
-	val &=3D ~( ~bitval << offset );   /* unset bit if bitval =3D=3D 0 */
-	val |=3D  (  bitval << offset );   /* set bit if bitval =3D=3D 1 */
+	val &=3D ~(!bitval << offset);   /* unset bit if bitval =3D=3D 0 */
+	val |=3D (!!bitval << offset);   /* set bit if bitval =3D=3D 1 */
 	writel(val, ioaddr);
=20
 	local_irq_restore(flags);
--=20
1.5.6.4


