linux-stable/drivers
Eudean Sun 542134c037 HID: cp2112: Fix I2C_BLOCK_DATA transactions
The existing driver erroneously treats I2C_BLOCK_DATA and BLOCK_DATA
commands the same.

For I2C_BLOCK_DATA reads, the length of the read is provided in
data->block[0], but the length itself should not be sent to the slave. In
contrast, for BLOCK_DATA reads no length is specified since the length
will be the first byte returned from the slave. When copying data back
to the data buffer, for an I2C_BLOCK_DATA read we have to take care not to
overwrite data->block[0] to avoid overwriting the length. A BLOCK_DATA
read doesn't have this concern since the first byte returned by the device
is the length and belongs in data->block[0].

For I2C_BLOCK_DATA writes, the length is also provided in data->block[0],
but the length itself is not sent to the slave (in contrast to BLOCK_DATA
writes where the length prefixes the data sent to the slave).

This was tested on physical hardware using i2cdump with the i and s flags
to test the behavior of I2C_BLOCK_DATA reads and BLOCK_DATA reads,
respectively. Writes were not tested but the I2C_BLOCK_DATA write change
is pretty simple to verify by inspection.

Signed-off-by: Eudean Sun <eudean@arista.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2017-11-21 21:39:45 +01:00
..
accessibility
acpi Merge branch 'i2c/for-4.15' of ssh://gitolite.kernel.org/pub/scm/linux/kernel/git/wsa/linux 2017-11-14 17:52:21 -08:00
amba A couple of dma-mapping updates: 2017-11-14 16:54:12 -08:00
android
ata
atm
auxdisplay
base DeviceTree for 4.15: 2017-11-14 18:25:40 -08:00
bcma This is the bulk of GPIO changes for the v4.15 kernel cycle: 2017-11-14 17:23:44 -08:00
block A couple of dma-mapping updates: 2017-11-14 16:54:12 -08:00
bluetooth
bus
cdrom
char
clk
clocksource
connector
cpufreq
cpuidle
crypto
dax
dca
devfreq
dio
dma dmaengine updates for 4.15-rc1 2017-11-14 16:49:31 -08:00
dma-buf
edac
eisa
extcon
firewire
firmware
fmc
fpga
fsi
gpio Merge branch 'i2c/for-4.15' of ssh://gitolite.kernel.org/pub/scm/linux/kernel/git/wsa/linux 2017-11-14 17:52:21 -08:00
gpu DeviceTree for 4.15: 2017-11-14 18:25:40 -08:00
hid HID: cp2112: Fix I2C_BLOCK_DATA transactions 2017-11-21 21:39:45 +01:00
hsi
hv
hwmon
hwspinlock
hwtracing
i2c Merge branch 'i2c/for-4.15' of ssh://gitolite.kernel.org/pub/scm/linux/kernel/git/wsa/linux 2017-11-14 17:52:21 -08:00
ide
idle
iio
infiniband
input Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input 2017-11-14 18:07:18 -08:00
iommu
ipack
irqchip
isdn
leds LED updates for 4.15rc1 2017-11-14 18:09:31 -08:00
lightnvm
macintosh
mailbox
mcb
md This is the bulk of GPIO changes for the v4.15 kernel cycle: 2017-11-14 17:23:44 -08:00
media Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input 2017-11-14 18:07:18 -08:00
memory
memstick
message
mfd sound updates for 4.15-rc1 2017-11-14 18:01:46 -08:00
misc Merge branch 'i2c/for-4.15' of ssh://gitolite.kernel.org/pub/scm/linux/kernel/git/wsa/linux 2017-11-14 17:52:21 -08:00
mmc
mtd
mux
net
nfc
ntb
nubus
nvdimm
nvme
nvmem
of DeviceTree for 4.15: 2017-11-14 18:25:40 -08:00
opp
oprofile
parisc
parport
pci A couple of dma-mapping updates: 2017-11-14 16:54:12 -08:00
pcmcia
perf
phy
pinctrl This is the bulk of GPIO changes for the v4.15 kernel cycle: 2017-11-14 17:23:44 -08:00
platform This is the bulk of GPIO changes for the v4.15 kernel cycle: 2017-11-14 17:23:44 -08:00
pnp
power Merge branch 'i2c/for-4.15' of ssh://gitolite.kernel.org/pub/scm/linux/kernel/git/wsa/linux 2017-11-14 17:52:21 -08:00
powercap
pps
ps3
ptp
pwm
rapidio
ras
regulator
remoteproc
reset
rpmsg
rtc
s390
sbus
scsi
sfi
sh A couple of dma-mapping updates: 2017-11-14 16:54:12 -08:00
sn
soc
spi
spmi
ssb
staging
target
tc
tee
thermal
thunderbolt
tty
uio
usb sound updates for 4.15-rc1 2017-11-14 18:01:46 -08:00
uwb
vfio
vhost
video
virt
virtio
vlynq
vme
w1
watchdog
xen
zorro
Kconfig
Makefile