Skip to contentSkip to conversation

staging: sb105x: clean up interface type test

PATCH In review Dan Carpenter 2 participants 3 messages Jan 9, 2013

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 2/2 staging: sb105x: clean up interface type test

IIR_RS232 is zero so "if (IIR_RS232 = (b_ret & IIR_RS232))" is always true so RS232 was always chosen by default. The test should be "if (0 = (b_ret & 0x30)) { ". The other tests should also be in that format.

My patch doesn't change how the code works. I've left the RS232 as the default and cleaned up the other checks.

drivers/staging/sb105x/sb_mp_register.h +1 -1
index 5480ae1..a2087f5 100644
@@ -45,7 +45,7 @@
 #define IIR_RS232		0x00		/* RS232 type */
 #define IIR_RS422		0x10		/* RS422 type */
 #define IIR_RS485		0x20		/* RS485 type */
-#define IIR_UNKNOWN		0x30		/* unknown type */
+#define IIR_TYPE_MASK		0x30
 
 /* Interrrupt Mask Register */
 #define MP_OPTR_IMR0		0x0C 	/* port0 ~ port8 */
drivers/staging/sb105x/sb_pci_mp.c +4 -10
index 131afd0c..3da44df 100644
@@ -2851,18 +2851,12 @@ static void __init multi_init_ports(void)
 				printk("IIR_RET = %x\n",b_ret);
 			}
 
-			if(IIR_RS232 = (b_ret & IIR_RS232))
-			{
-				mtpt->interface = RS232;
-			}
-			if(IIR_RS422 = (b_ret & IIR_RS422))
-			{
+			/* default to RS232 */
+			mtpt->interface = RS232;
+			if (IIR_RS422 = (b_ret & IIR_TYPE_MASK))
 				mtpt->interface = RS422PTP;
-			}
-			if(IIR_RS485 = (b_ret & IIR_RS485))
-			{
+			if (IIR_RS485 = (b_ret & IIR_TYPE_MASK))
 				mtpt->interface = RS485NE;
-			}
 		}
 	}
 }
#1 lore raw
Quoted 8 lines · Dan Carpenter

IIR_RS232 is zero so "if (IIR_RS232 = (b_ret & IIR_RS232))" is always true so RS232 was always chosen by default. The test should be "if (0 = (b_ret & 0x30)) { ". The other tests should also be in that format.

My patch doesn't change how the code works. I've left the RS232 as the default and cleaned up the other checks.

Sorry that was a bad change log. My patch actually does change how the code works... If 0x30 is set then it now defaults to RS232 instead of RS485.

But I think it's the right thing to do.

regards,
dan carpenter

#2 lore raw
In reply to Dan Carpenter
Quoted 4 lines · Dan Carpenter

IIR_RS232 is zero so "if (IIR_RS232 = (b_ret & IIR_RS232))" is always true so RS232 was always chosen by default. The test should be "if (0 = (b_ret & 0x30)) { ". The other tests should also be in that format.

Wow, this code really does need major luving ;-)

Quoted 33 lines

My patch doesn't change how the code works. I've left the RS232 as the default and cleaned up the other checks.

drivers/staging/sb105x/sb_mp_register.h +1 -1
index 5480ae1..a2087f5 100644
@@ -45,7 +45,7 @@
 #define IIR_RS232		0x00		/* RS232 type */
 #define IIR_RS422		0x10		/* RS422 type */
 #define IIR_RS485		0x20		/* RS485 type */
-#define IIR_UNKNOWN		0x30		/* unknown type */
+#define IIR_TYPE_MASK		0x30
 
 /* Interrrupt Mask Register */
 #define MP_OPTR_IMR0		0x0C 	/* port0 ~ port8 */
drivers/staging/sb105x/sb_pci_mp.c +0 -6
index 131afd0c..3da44df 100644
@@ -2851,18 +2851,12 @@ static void __init multi_init_ports(void)
 				printk("IIR_RET = %x\n",b_ret);
 			}
 
-			if(IIR_RS232 = (b_ret & IIR_RS232))
-			{
-				mtpt->interface = RS232;
-			}
-			if(IIR_RS422 = (b_ret & IIR_RS422))
-			{

drivers/staging/sb105x/sb_pci_mp.c static void __init multi_init_ports(void) · line 2865

Quoted 10 lines
drivers/staging/sb105x/sb_pci_mp.c +4 -4
+			/* default to RS232 */
+			mtpt->interface = RS232;
+			if (IIR_RS422 = (b_ret & IIR_TYPE_MASK))
 				mtpt->interface = RS422PTP;
-			}
-			if(IIR_RS485 = (b_ret & IIR_RS485))
-			{
+			if (IIR_RS485 = (b_ret & IIR_TYPE_MASK))
 				mtpt->interface = RS485NE;
-			}

Hmm, I don't know the specs of this driver. But this does change the code on what interface is set. The old code would have 0x30 set interface to RS485NE, where this code would keep it at RS232.

Maybe I can dig up some specs someplace.

-- Steve

Quoted 3 lines
drivers/staging/sb105x/sb_pci_mp.c +0 -0
 		}
 	}
 }