diff mbox

[0/8] Fix V4L/DVB/RC warnings

Message ID 4D19F809.3010409@redhat.com (mailing list archive)
State Accepted
Headers show

Commit Message

Mauro Carvalho Chehab Dec. 28, 2010, 2:45 p.m. UTC
None
diff mbox

Patch

diff --git a/drivers/staging/lirc/lirc_zilog.c b/drivers/staging/lirc/lirc_zilog.c
index 52be6de..8486b66 100644
--- a/drivers/staging/lirc/lirc_zilog.c
+++ b/drivers/staging/lirc/lirc_zilog.c
@@ -88,6 +88,7 @@  struct IR {
 	struct i2c_client c_tx;
 	int need_boot;
 	int have_tx;
+	bool dont_wait;
 };
 
 /* Minor -> data mapping */
@@ -841,46 +842,43 @@  static int send_code(struct IR *ir, unsigned int code, unsigned int key)
 		return ret < 0 ? ret : -EFAULT;
 	}
 
-#ifdef I2C_HW_B_HDPVR
 	/*
 	 * The sleep bits aren't necessary on the HD PVR, and in fact, the
 	 * last i2c_master_recv always fails with a -5, so for now, we're
 	 * going to skip this whole mess and say we're done on the HD PVR
 	 */
-	if (ir->c_rx.adapter->id == I2C_HW_B_HDPVR)
-		goto done;
-#endif
-
-	/*
-	 * This bit NAKs until the device is ready, so we retry it
-	 * sleeping a bit each time.  This seems to be what the windows
-	 * driver does, approximately.
-	 * Try for up to 1s.
-	 */
-	for (i = 0; i < 20; ++i) {
-		set_current_state(TASK_UNINTERRUPTIBLE);
-		schedule_timeout((50 * HZ + 999) / 1000);
-		ret = i2c_master_send(&ir->c_tx, buf, 1);
-		if (ret == 1)
-			break;
-		dprintk("NAK expected: i2c_master_send "
-			"failed with %d (try %d)\n", ret, i+1);
-	}
-	if (ret != 1) {
-		zilog_error("IR TX chip never got ready: last i2c_master_send "
-			    "failed with %d\n", ret);
-		return ret < 0 ? ret : -EFAULT;
-	}
+	if (!ir->dont_wait) {
+		/*
+		 * This bit NAKs until the device is ready, so we retry it
+		 * sleeping a bit each time.  This seems to be what the
+		 *  windows driver does, approximately.
+		 * Try for up to 1s.
+		 */
+		for (i = 0; i < 20; ++i) {
+			set_current_state(TASK_UNINTERRUPTIBLE);
+			schedule_timeout((50 * HZ + 999) / 1000);
+			ret = i2c_master_send(&ir->c_tx, buf, 1);
+			if (ret == 1)
+				break;
+			dprintk("NAK expected: i2c_master_send "
+				"failed with %d (try %d)\n", ret, i+1);
+		}
+		if (ret != 1) {
+			zilog_error("IR TX chip never got ready: last i2c_master_send "
+				    "failed with %d\n", ret);
+			return ret < 0 ? ret : -EFAULT;
+		}
 
-	/* Seems to be an 'ok' response */
-	i = i2c_master_recv(&ir->c_tx, buf, 1);
-	if (i != 1) {
-		zilog_error("i2c_master_recv failed with %d\n", ret);
-		return -EFAULT;
-	}
-	if (buf[0] != 0x80) {
-		zilog_error("unexpected IR TX response #2: %02x\n", buf[0]);
-		return -EFAULT;
+		/* Seems to be an 'ok' response */
+		i = i2c_master_recv(&ir->c_tx, buf, 1);
+		if (i != 1) {
+			zilog_error("i2c_master_recv failed with %d\n", ret);
+			return -EFAULT;
+		}
+		if (buf[0] != 0x80) {
+			zilog_error("unexpected IR TX response #2: %02x\n", buf[0]);
+			return -EFAULT;
+		}
 	}
 
 	/* Oh good, it worked */
@@ -1278,6 +1276,11 @@  static int ir_probe(struct i2c_client *client, const struct i2c_device_id *id)
 		strlcpy(ir->c_tx.name, ZILOG_HAUPPAUGE_IR_TX_NAME,
 			I2C_NAME_SIZE);
 		ir->have_tx = 1;
+
+#ifdef I2C_HW_B_HDPVR
+		if (ir->c_rx.adapter->id == I2C_HW_B_HDPVR)
+			ir->dont_wait = true;
+#endif
 	}
 
 	/* set lirc_dev stuff */