Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[media] go7007: fix i2c_xfer return codes

The i2c_xfer functions didn't return the proper error codes and (especially
important) on success they returned 0 instead of the number of transferred
messages.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>

authored by

Hans Verkuil and committed by
Mauro Carvalho Chehab
ffb97493 1589037f

+13 -13
+10 -10
drivers/staging/media/go7007/go7007-i2c.c
··· 52 52 static int go7007_i2c_xfer(struct go7007 *go, u16 addr, int read, 53 53 u16 command, int flags, u8 *data) 54 54 { 55 - int i, ret = -1; 55 + int i, ret = -EIO; 56 56 u16 val; 57 57 58 58 if (go->status == STATUS_SHUTDOWN) 59 - return -1; 59 + return -ENODEV; 60 60 61 61 #ifdef GO7007_I2C_DEBUG 62 62 if (read) ··· 146 146 struct go7007 *go = i2c_get_adapdata(adapter); 147 147 148 148 if (size != I2C_SMBUS_BYTE_DATA) 149 - return -1; 149 + return -EIO; 150 150 return go7007_i2c_xfer(go, addr, read_write == I2C_SMBUS_READ, command, 151 151 flags & I2C_CLIENT_SCCB ? 0x10 : 0x00, &data->byte); 152 152 } ··· 170 170 (msgs[i].flags & I2C_M_RD) || 171 171 !(msgs[i + 1].flags & I2C_M_RD) || 172 172 msgs[i + 1].len != 1) 173 - return -1; 173 + return -EIO; 174 174 if (go7007_i2c_xfer(go, msgs[i].addr, 1, 175 175 (msgs[i].buf[0] << 8) | msgs[i].buf[1], 176 176 0x01, &msgs[i + 1].buf[0]) < 0) 177 - return -1; 177 + return -EIO; 178 178 ++i; 179 179 } else if (msgs[i].len == 3) { 180 180 if (msgs[i].flags & I2C_M_RD) 181 - return -1; 181 + return -EIO; 182 182 if (msgs[i].len != 3) 183 - return -1; 183 + return -EIO; 184 184 if (go7007_i2c_xfer(go, msgs[i].addr, 0, 185 185 (msgs[i].buf[0] << 8) | msgs[i].buf[1], 186 186 0x01, &msgs[i].buf[2]) < 0) 187 - return -1; 187 + return -EIO; 188 188 } else 189 - return -1; 189 + return -EIO; 190 190 } 191 191 192 - return 0; 192 + return num; 193 193 } 194 194 195 195 static u32 go7007_functionality(struct i2c_adapter *adapter)
+3 -3
drivers/staging/media/go7007/go7007-usb.c
··· 876 876 struct go7007_usb *usb = go->hpi_context; 877 877 u8 buf[16]; 878 878 int buf_len, i; 879 - int ret = -1; 879 + int ret = -EIO; 880 880 881 881 if (go->status == STATUS_SHUTDOWN) 882 - return -1; 882 + return -ENODEV; 883 883 884 884 mutex_lock(&usb->i2c_lock); 885 885 ··· 936 936 memcpy(msgs[i].buf, buf + 1, msgs[i].len); 937 937 } 938 938 } 939 - ret = 0; 939 + ret = num; 940 940 941 941 i2c_done: 942 942 mutex_unlock(&usb->i2c_lock);