[Fwd: Mantis gpio_set_bits() fix]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




--- Begin Message ---

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
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 << bitpos );
 	else
-		reg = 0xffff;
-
-	reg = (value << bitpos);
+	  newVal = currVal & ( ~ ( 1 << 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);
 }
 
 

--- End Message ---
_______________________________________________
linux-dvb mailing list
linux-dvb@xxxxxxxxxxx
http://www.linuxtv.org/cgi-bin/mailman/listinfo/linux-dvb

[Index of Archives]     [Linux Media]     [Video 4 Linux]     [Asterisk]     [Samba]     [Xorg]     [Xfree86]     [Linux USB]

  Powered by Linux