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

i2c: Remove i2c_algorithm.algo_control()

This removes:

- An effectively unused hook: i2c_algorithm.algo_control.

- The i2c_control() call, used only by i2c-dev to call that
unused hook or set two barely supported adapter params.

(That param setting moves into i2c-dev.c ... still iffy
due to lack of locking, but no other changes.)

As shown by diffstat, this is a net code shrink. It also reduces the
complexity of the I2C adapter and /dev interfaces.

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: Jean Delvare <khali@linux-fr.org>

authored by

David Brownell and committed by
Jean Delvare
53be7959 cdeec3cc

+12 -31
-22
drivers/i2c/i2c-core.c
··· 931 931 } 932 932 EXPORT_SYMBOL(i2c_master_recv); 933 933 934 - int i2c_control(struct i2c_client *client, 935 - unsigned int cmd, unsigned long arg) 936 - { 937 - int ret = 0; 938 - struct i2c_adapter *adap = client->adapter; 939 - 940 - dev_dbg(&client->adapter->dev, "i2c ioctl, cmd: 0x%x, arg: %#lx\n", cmd, arg); 941 - switch (cmd) { 942 - case I2C_RETRIES: 943 - adap->retries = arg; 944 - break; 945 - case I2C_TIMEOUT: 946 - adap->timeout = arg; 947 - break; 948 - default: 949 - if (adap->algo->algo_control!=NULL) 950 - ret = adap->algo->algo_control(adap,cmd,arg); 951 - } 952 - return ret; 953 - } 954 - EXPORT_SYMBOL(i2c_control); 955 - 956 934 /* ---------------------------------------------------- 957 935 * the i2c address scanning function 958 936 * Will not work for 10-bit addresses!
+12 -2
drivers/i2c/i2c-dev.c
··· 354 354 return -EFAULT; 355 355 } 356 356 return res; 357 - 357 + case I2C_RETRIES: 358 + client->adapter->retries = arg; 359 + break; 360 + case I2C_TIMEOUT: 361 + client->adapter->timeout = arg; 362 + break; 358 363 default: 359 - return i2c_control(client,cmd,arg); 364 + /* NOTE: returning a fault code here could cause trouble 365 + * in buggy userspace code. Some old kernel bugs returned 366 + * zero in this case, and userspace code might accidentally 367 + * have depended on that bug. 368 + */ 369 + return -ENOTTY; 360 370 } 361 371 return 0; 362 372 }
-7
include/linux/i2c.h
··· 290 290 unsigned short flags, char read_write, 291 291 u8 command, int size, union i2c_smbus_data * data); 292 292 293 - /* --- ioctl like call to set div. parameters. */ 294 - int (*algo_control)(struct i2c_adapter *, unsigned int, unsigned long); 295 - 296 293 /* To determine what the adapter supports */ 297 294 u32 (*functionality) (struct i2c_adapter *); 298 295 }; ··· 412 415 extern int i2c_probe(struct i2c_adapter *adapter, 413 416 struct i2c_client_address_data *address_data, 414 417 int (*found_proc) (struct i2c_adapter *, int, int)); 415 - 416 - /* An ioctl like call to set div. parameters of the adapter. 417 - */ 418 - extern int i2c_control(struct i2c_client *,unsigned int, unsigned long); 419 418 420 419 extern struct i2c_adapter* i2c_get_adapter(int id); 421 420 extern void i2c_put_adapter(struct i2c_adapter *adap);