Merge remote-tracking branch 'lsk/v3.10/topic/gator' into linux-linaro-lsk
[firefly-linux-kernel-4.4.55.git] / drivers / media / usb / dvb-usb / cxusb.c
index 20e345d9fe8f3aca89a913f79f3ccb813b7d5ab4..a1c641e18362ad288ebd1972c389831d2abb1db3 100644 (file)
@@ -149,6 +149,7 @@ static int cxusb_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msg[],
                          int num)
 {
        struct dvb_usb_device *d = i2c_get_adapdata(adap);
+       int ret;
        int i;
 
        if (mutex_lock_interruptible(&d->i2c_mutex) < 0)
@@ -173,7 +174,8 @@ static int cxusb_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msg[],
                        if (1 + msg[i].len > sizeof(ibuf)) {
                                warn("i2c rd: len=%d is too big!\n",
                                     msg[i].len);
-                               return -EOPNOTSUPP;
+                               ret = -EOPNOTSUPP;
+                               goto unlock;
                        }
                        obuf[0] = 0;
                        obuf[1] = msg[i].len;
@@ -193,12 +195,14 @@ static int cxusb_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msg[],
                        if (3 + msg[i].len > sizeof(obuf)) {
                                warn("i2c wr: len=%d is too big!\n",
                                     msg[i].len);
-                               return -EOPNOTSUPP;
+                               ret = -EOPNOTSUPP;
+                               goto unlock;
                        }
                        if (1 + msg[i + 1].len > sizeof(ibuf)) {
                                warn("i2c rd: len=%d is too big!\n",
                                     msg[i + 1].len);
-                               return -EOPNOTSUPP;
+                               ret = -EOPNOTSUPP;
+                               goto unlock;
                        }
                        obuf[0] = msg[i].len;
                        obuf[1] = msg[i+1].len;
@@ -223,7 +227,8 @@ static int cxusb_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msg[],
                        if (2 + msg[i].len > sizeof(obuf)) {
                                warn("i2c wr: len=%d is too big!\n",
                                     msg[i].len);
-                               return -EOPNOTSUPP;
+                               ret = -EOPNOTSUPP;
+                               goto unlock;
                        }
                        obuf[0] = msg[i].addr;
                        obuf[1] = msg[i].len;
@@ -237,8 +242,14 @@ static int cxusb_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msg[],
                }
        }
 
+       if (i == num)
+               ret = num;
+       else
+               ret = -EREMOTEIO;
+
+unlock:
        mutex_unlock(&d->i2c_mutex);
-       return i == num ? num : -EREMOTEIO;
+       return ret;
 }
 
 static u32 cxusb_i2c_func(struct i2c_adapter *adapter)