aboutsummaryrefslogtreecommitdiff
path: root/drivers/i2c/i2c-dev.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2024-07-19 16:46:26 -0700
committerLinus Torvalds <torvalds@linux-foundation.org>2024-07-19 16:46:26 -0700
commitef035628c326af9aa645af1b91fbb72fdfec874e (patch)
tree31bbda74c95f96d2f20307fd6bc356ec6cc7a3d7 /drivers/i2c/i2c-dev.c
parentacc5965b9ff8a1889f5b51466562896d59c6e1b9 (diff)
parent5d89b5bdbce3937c86f05ffe19455c3068fd94f7 (diff)
Merge tag 'i2c-for-6.11-rc1-try2' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux
Pull i2c fixes from Wolfram Sang: "The I2C core gains documentation updates for the testunit, a cleanup regarding unneeded 'driver_data' and more sanity checks in the char device. For the host drivers, this release includes significant updates, with the primary change being the renaming from "master/slave" to "controller/target" to adhere to I2C v7 and SMBus 3.2 standards. New Support: - Added support for Intel Arrow Lake-H - Added I2C support in the Arioha SoC by linking the Mediatek I2C controller Cleanups: - Added the MODULE_DESCRIPTION() macro, resolving a modpost warning in the ALi 1563 Southbridge driver. - Constified the regmap_config declaration in the i2c-designware driver. - Improved the coding style in the Renesas R-Car driver by removing unnecessary semicolons after brackets. General improvements: - In the OMAP device, replaced NOIRQ_SYSTEM_SLEEP_PM_OPS with RUNTIME_PM_OPS to enable waking up the controller during suspend() before suspend_noirq() kicks in. - Improved logging in the Xilinx driver. - Added a warning (WARN()) in the Renesas R-Car driver for spurious interrupts. DTS Changes: - Removed address-cell and size-cell from the Atmel at91sam, nVidia Tegra 20, and Samsung S3c2410 devices. - Fixed Texas Instruments OMAP4 I2C controller to comply with the i2c-controller.yaml schema. - Improved indentation in DTS examples for several I2C devices. - Converted the NXP LPC1788 binding to the dt-schema. - Added documentation for the compatible string thead,th1520-i2c. - Added the "power-domains" property for the Meson I2C driver. AT24 EEPROM driver changes: - add support for two new Microchip models - document even more new models in DT bindings (those use fallback compatibles so no code changes)" * tag 'i2c-for-6.11-rc1-try2' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux: (87 commits) i2c: document new callbacks in i2c_algorithm dt-bindings: i2c: amlogic,meson6-i2c: add optional power-domains dt-bindings: i2c: at91: Add sama7d65 compatible string i2c: st: reword according to newest specification i2c: cpm: reword according to newest specification i2c: virtio: reword according to newest specification i2c: nvidia-gpu: reword according to newest specification i2c: viai2c: reword according to newest specification i2c: viperboard: reword according to newest specification i2c: uniphier: reword according to newest specification i2c: uniphier-f: reword according to newest specification i2c: tiny-usb: reword according to newest specification i2c: thunderx-pcidrv: reword according to newest specification i2c: tegra-bpmp: reword according to newest specification i2c: taos-evm: reword according to newest specification i2c: sun6i-p2wi: reword according to newest specification i2c: stm32f4: reword according to newest specification i2c: sprd: reword according to newest specification i2c: sis5595: reword according to newest specification i2c: rzv2m: reword according to newest specification ...
Diffstat (limited to 'drivers/i2c/i2c-dev.c')
-rw-r--r--drivers/i2c/i2c-dev.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/drivers/i2c/i2c-dev.c b/drivers/i2c/i2c-dev.c
index 8b7e599f1674..f4fb212b7f39 100644
--- a/drivers/i2c/i2c-dev.c
+++ b/drivers/i2c/i2c-dev.c
@@ -139,6 +139,10 @@ static ssize_t i2cdev_read(struct file *file, char __user *buf, size_t count,
struct i2c_client *client = file->private_data;
+ /* Adapter must support I2C transfers */
+ if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C))
+ return -EOPNOTSUPP;
+
if (count > 8192)
count = 8192;
@@ -163,6 +167,10 @@ static ssize_t i2cdev_write(struct file *file, const char __user *buf,
char *tmp;
struct i2c_client *client = file->private_data;
+ /* Adapter must support I2C transfers */
+ if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C))
+ return -EOPNOTSUPP;
+
if (count > 8192)
count = 8192;
@@ -238,6 +246,10 @@ static noinline int i2cdev_ioctl_rdwr(struct i2c_client *client,
u8 __user **data_ptrs;
int i, res;
+ /* Adapter must support I2C transfers */
+ if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C))
+ return -EOPNOTSUPP;
+
data_ptrs = kmalloc_array(nmsgs, sizeof(u8 __user *), GFP_KERNEL);
if (data_ptrs == NULL) {
kfree(msgs);