Blame SOURCES/ccid-1.4.10-voltage.patch

68895e
diff -up ./src/commands.c.voltage ./src/commands.c
68895e
--- ./src/commands.c.voltage	2013-03-16 06:52:33.000000000 -0700
68895e
+++ ./src/commands.c	2013-11-26 15:44:13.533254750 -0800
68895e
@@ -97,6 +97,7 @@ RESPONSECODE CmdPowerOn(unsigned int rea
68895e
 	status_t res;
68895e
 	int length, count = 1;
68895e
 	unsigned int atr_len;
68895e
+	int init_voltage = 0;
68895e
 	RESPONSECODE return_value = IFD_SUCCESS;
68895e
 	_ccid_descriptor *ccid_descriptor = get_ccid_descriptor(reader_index);
68895e
 
68895e
@@ -207,6 +208,7 @@ RESPONSECODE CmdPowerOn(unsigned int rea
68895e
 			voltage = 0;	/* auto */
68895e
 		}
68895e
 	}
68895e
+	init_voltage = voltage;
68895e
 
68895e
 again:
68895e
 	cmd[0] = 0x62; /* IccPowerOn */
68895e
@@ -256,14 +258,19 @@ again:
68895e
 		}
68895e
 
68895e
 		/* continue with 3 volts and 5 volts */
68895e
-		if (voltage > 1)
68895e
+		if (voltage) 
68895e
 		{
68895e
 			const char *voltage_code[] = { "auto", "5V", "3V", "1.8V" };
68895e
 
68895e
 			DEBUG_INFO3("Power up with %s failed. Try with %s.",
68895e
 				voltage_code[voltage], voltage_code[voltage-1]);
68895e
 			voltage--;
68895e
-			goto again;
68895e
+			if (voltage == 0) {
68895e
+			    voltage = 3;
68895e
+			}
68895e
+			if (voltage != init_voltage) {
68895e
+			    goto again;
68895e
+			}
68895e
 		}
68895e
 
68895e
 		return IFD_COMMUNICATION_ERROR;