[PATCH 09/13] via: Rationalize vt1636 detection

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Jonathan Corbet
Date: Friday, April 23, 2010 - 2:28 pm

The code was ugly and didn't check whether i2c operations were succeeding;
make it a little better.

Signed-off-by: Jonathan Corbet <corbet@lwn.net>
---
 drivers/video/via/vt1636.c |   20 +++++++-------------
 1 files changed, 7 insertions(+), 13 deletions(-)

diff --git a/drivers/video/via/vt1636.c b/drivers/video/via/vt1636.c
index e9f3661..e5f8024 100644
--- a/drivers/video/via/vt1636.c
+++ b/drivers/video/via/vt1636.c
@@ -167,26 +167,20 @@ bool viafb_lvds_identify_vt1636(u8 i2c_adapter)
 
 	/* Sense VT1636 LVDS Transmiter */
 	viaparinfo->chip_info->lvds_chip_info.lvds_chip_slave_addr =
-	VT1636_LVDS_I2C_ADDR;
+		VT1636_LVDS_I2C_ADDR;
 
 	/* Check vendor ID first: */
-	viafb_i2c_readbyte(i2c_adapter,
-			   (u8) viaparinfo->chip_info->lvds_chip_info.lvds_chip_slave_addr,
-			   0x00, &Buffer[0]);
-	viafb_i2c_readbyte(i2c_adapter,
-			   (u8) viaparinfo->chip_info->lvds_chip_info.lvds_chip_slave_addr,
-			   0x01, &Buffer[1]);
+	if (viafb_i2c_readbyte(i2c_adapter, VT1636_LVDS_I2C_ADDR,
+					0x00, &Buffer[0]))
+		return false;
+	viafb_i2c_readbyte(i2c_adapter, VT1636_LVDS_I2C_ADDR, 0x01, &Buffer[1]);
 
 	if (!((Buffer[0] == 0x06) && (Buffer[1] == 0x11)))
 		return false;
 
 	/* Check Chip ID: */
-	viafb_i2c_readbyte(i2c_adapter,
-			   (u8) viaparinfo->chip_info->lvds_chip_info.lvds_chip_slave_addr,
-			   0x02, &Buffer[0]);
-	viafb_i2c_readbyte(i2c_adapter,
-			   (u8) viaparinfo->chip_info->lvds_chip_info.lvds_chip_slave_addr,
-			   0x03, &Buffer[1]);
+	viafb_i2c_readbyte(i2c_adapter, VT1636_LVDS_I2C_ADDR, 0x02, &Buffer[0]);
+	viafb_i2c_readbyte(i2c_adapter, VT1636_LVDS_I2C_ADDR, 0x03, &Buffer[1]);
 	if ((Buffer[0] == 0x45) && (Buffer[1] == 0x33)) {
 		viaparinfo->chip_info->lvds_chip_info.lvds_chip_name =
 			VT1636_LVDS;
-- 
1.7.0.1

--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[RFC] Second OLPC Viafb series, Jonathan Corbet, (Fri Apr 23, 2:28 pm)
[PATCH 01/13] viafb: Move core stuff into via-core.c, Jonathan Corbet, (Fri Apr 23, 2:28 pm)
[PATCH 02/13] viafb: Separate global and fb-specific data, Jonathan Corbet, (Fri Apr 23, 2:28 pm)
[PATCH 03/13] viafb: add a driver for GPIO lines, Jonathan Corbet, (Fri Apr 23, 2:28 pm)
[PATCH 04/13] viafb: package often used basic io functions, Jonathan Corbet, (Fri Apr 23, 2:28 pm)
[PATCH 08/13] viafb: Introduce viafb_find_i2c_adapter(), Jonathan Corbet, (Fri Apr 23, 2:28 pm)
[PATCH 09/13] via: Rationalize vt1636 detection, Jonathan Corbet, (Fri Apr 23, 2:28 pm)
[PATCH 11/13] viafb: Add a simple VX855 DMA engine driver, Jonathan Corbet, (Fri Apr 23, 2:28 pm)
Re: [RFC] Second OLPC Viafb series, Florian Tobias Schan ..., (Sat Apr 24, 8:07 am)