drm/i2c: tda998x: clean up error chip version checking
authorRussell King <rmk+kernel@arm.linux.org.uk>
Sun, 2 Feb 2014 16:18:24 +0000 (16:18 +0000)
committerRussell King <rmk+kernel@arm.linux.org.uk>
Thu, 13 Feb 2014 19:41:37 +0000 (19:41 +0000)
This is a nicer way, and results in proper return codes should the
read of the MSB version register fail.

Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
drivers/gpu/drm/i2c/tda998x_drv.c

index 9bd336cdb7347a67f4ac7fdf3d1f62268b3eecf2..19f418246e7b775d287147b1f704282cc0b5be2c 100644 (file)
@@ -1169,7 +1169,7 @@ tda998x_encoder_init(struct i2c_client *client,
                    struct drm_encoder_slave *encoder_slave)
 {
        struct tda998x_priv *priv;
-       int ret;
+       int rev_lo, rev_hi, ret;
 
        priv = kzalloc(sizeof(*priv), GFP_KERNEL);
        if (!priv)
@@ -1198,11 +1198,14 @@ tda998x_encoder_init(struct i2c_client *client,
        tda998x_reset(priv);
 
        /* read version: */
-       ret = reg_read(priv, REG_VERSION_LSB) |
-               (reg_read(priv, REG_VERSION_MSB) << 8);
-       if (ret < 0)
+       rev_lo = reg_read(priv, REG_VERSION_LSB);
+       rev_hi = reg_read(priv, REG_VERSION_MSB);
+       if (rev_lo < 0 || rev_hi < 0) {
+               ret = rev_lo < 0 ? rev_lo : rev_hi;
                goto fail;
-       priv->rev = ret;
+       }
+
+       priv->rev = rev_lo | rev_hi << 8;
 
        /* mask off feature bits: */
        priv->rev &= ~0x30; /* not-hdcp and not-scalar bit */