[From nobody Sat Mar 17 10:15:52 2007
Message-ID: &lt;45FBB160.2020909@kolumbus.fi&gt;
Date: Sat, 17 Mar 2007 11:14:08 +0200
From: Marko Ristola &lt;marko.ristola@kolumbus.fi&gt;
User-Agent: Thunderbird 1.5.0.10 (X11/20070302)
MIME-Version: 1.0
To: Manu Abraham &lt;abraham.manu@gmail.com&gt;
Subject: Mantis gpio_set_bits() fix
Content-Type: multipart/mixed; boundary=&quot;------------090109010803020800060200&quot;

This is a multi-part message in MIME format.
--------------090109010803020800060200
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit


Hi Manu,

Here is a bugfix for gpio_set_bits().
What do you think about this bugfix?

The bug is that the function is only able to turn the given
bit on, but it can never turn a bit off.

My patch fixes that issue.

With my patched version gpio_set_bits is able to turn a single bit
on or off.

I haven't verified that it actually does turn the device's power off 
when requested.
I tested only rmmod and insmod. It seems to work with this version:
I haven't seen a lost frontend.

Regards,
Marko Ristola

--------------090109010803020800060200
Content-Type: text/x-patch;
 name=&quot;mantis_gpio_set_bits_fix.patch&quot;
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename=&quot;mantis_gpio_set_bits_fix.patch&quot;

Index: linux/drivers/media/dvb/mantis/mantis_core.c
===================================================================
RCS file: /var/cvs/mantis/linux/drivers/media/dvb/mantis/mantis_core.c,v
retrieving revision 1.2.2.2
retrieving revision 1.2.2.2.2.1
diff -u -p -r1.2.2.2 -r1.2.2.2.2.1
--- linux/drivers/media/dvb/mantis/mantis_core.c	15 Feb 2007 17:25:59 -0000	1.2.2.2
+++ linux/drivers/media/dvb/mantis/mantis_core.c	24 Feb 2007 17:54:25 -0000	1.2.2.2.2.1
@@ -194,22 +194,22 @@ int mantis_core_exit(struct mantis_pci *
 	return 0;
 }
 
+// Turn the given bit on or off.
 void gpio_set_bits(struct mantis_pci *mantis, u32 bitpos, u8 value)
 {
-	u32 reg;
+	u32 currVal;
+	u32 newVal;
 
-	if (value)
-		reg = 0x0000;
+	currVal = mmread(MANTIS_GPIF_ADDR);
+	
+	if ( value )
+	  newVal = currVal | ( 1 &lt;&lt; bitpos );
 	else
-		reg = 0xffff;
-
-	reg = (value &lt;&lt; bitpos);
+	  newVal = currVal &amp; ( ~ ( 1 &lt;&lt; bitpos ) );
 
-	mmwrite(mmread(MANTIS_GPIF_ADDR) | reg, MANTIS_GPIF_ADDR);
+	mmwrite( newVal, MANTIS_GPIF_ADDR);
 	mmwrite(0x00, MANTIS_GPIF_DOUT);
 	udelay(100);
-	mmwrite(mmread(MANTIS_GPIF_ADDR) | reg, MANTIS_GPIF_ADDR);
-	mmwrite(0x00, MANTIS_GPIF_DOUT);
 }
 
 

--------------090109010803020800060200--

]