kernel_samsung_a53x/drivers/media
Michael Bunk 52f8602521 media: dw2102: Don't translate i2c read into write
[ Upstream commit 0e148a522b8453115038193e19ec7bea71403e4a ]

The code ignored the I2C_M_RD flag on I2C messages.  Instead it assumed
an i2c transaction with a single message must be a write operation and a
transaction with two messages would be a read operation.

Though this works for the driver code, it leads to problems once the i2c
device is exposed to code not knowing this convention.  For example,
I did "insmod i2c-dev" and issued read requests from userspace, which
were translated into write requests and destroyed the EEPROM of my
device.

So, just check and respect the I2C_M_READ flag, which indicates a read
when set on a message.  If it is absent, it is a write message.

Incidentally, changing from the case statement to a while loop allows
the code to lift the limitation to two i2c messages per transaction.

There are 4 more *_i2c_transfer functions affected by the same behaviour
and limitation that should be fixed in the same way.

Link: https://lore.kernel.org/linux-media/20220116112238.74171-2-micha@freedict.org
Signed-off-by: Michael Bunk <micha@freedict.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-19 14:19:40 +01:00
..
cec Revert "media: cec: core: avoid confusing "transmit timed out" message" 2024-11-19 14:03:20 +01:00
common media: v4l2-tpg: fix some memleaks in tpg_alloc 2024-11-19 08:44:51 +01:00
dvb-core media: dvbdev: Initialize sbuf 2024-11-19 14:19:32 +01:00
dvb-frontends media: dvb: as102-fe: Fix as10x_register_addr packing 2024-11-19 14:19:39 +01:00
firewire Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
i2c media: tc358743: register v4l2 async device only after successful setup 2024-11-19 08:44:51 +01:00
mc media: mc: mark the media devnode as registered from the, start 2024-11-19 12:27:17 +01:00
mmc Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
pci media: ngene: Add dvb_ca_en50221_init return value check 2024-11-19 12:26:58 +01:00
platform media: mediatek: vcodec: avoid -Wcast-function-type-strict warning 2024-11-19 08:44:55 +01:00
radio media: radio-shark2: Avoid led_names truncations 2024-11-19 12:26:58 +01:00
rc media: rc: bpf attach/detach requires write permission 2024-11-18 12:13:31 +01:00
spi Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
test-drivers media: vivid: avoid integer overflow 2024-11-18 11:43:15 +01:00
tuners media: xc4000: Fix atomicity violation in xc4000_get_frequency 2024-11-19 09:22:15 +01:00
usb media: dw2102: Don't translate i2c read into write 2024-11-19 14:19:40 +01:00
v4l2-core media: v4l2-core: hold videodev_lock until dev reg, finishes 2024-11-19 12:27:17 +01:00
Kconfig Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
Makefile Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00