driver: i2c - convert ioctl to unlocked_ioctl
The I2C driver ioctl handler is protected by spinlock anyway (not in obvious form though) - there is no need to use ioctl so we are able to use unlocked_ioctl instead
Also a bit cleanup is done
Signed-off-by Cyrill Gorcunov <[email protected]>
---
It's an arch I don't have - so test it please ;) Any comments are welcome
arch-v10/drivers/i2c.c | 24 ++++++++++-------------- arch-v32/drivers/i2c.c | 15 ++++++--------- 2 files changed, 16 insertions(+), 23 deletions(-)
arch/cris/arch-v10/drivers/i2c.c +10 -14
@@ -577,19 +577,15 @@ i2c_release(struct inode *inode, struct/* Main device API. ioctl's to write or read to/from i2c registers. */ - -static int -i2c_ioctl (struct inode *inode,struct file *file, -unsigned int cmd,unsigned long arg) +static long i2c_ioctl (struct file *file,unsigned int cmd,unsigned long arg) { -if (_IOC_TYPE (cmd) !=ETRAXI2C_IOCTYPE ) { +if (_IOC_TYPE (cmd) !=ETRAXI2C_IOCTYPE )return -EINVAL ; - }switch (_IOC_NR (cmd)) {case I2C_WRITEREG :/* write to an i2c slave */ -D (printk ("i2cw %d %d %d\n" , +D (printk ("i2cw %d %d %d\n" ,I2C_ARGSLAVE (arg),I2C_ARGREG (arg),I2C_ARGVALUE (arg)));
@@ -601,26 +597,26 @@ i2c_ioctl(struct inode *inode, struct fi {unsigned char val;/* read from an i2c slave */ -D (printk ("i2cr %d %d " , +D (printk ("i2cr %d %d " ,I2C_ARGSLAVE (arg),I2C_ARGREG (arg))); val =i2c_readreg (I2C_ARGSLAVE (arg),I2C_ARGREG (arg));D (printk ("= %d\n" , val));return val; - } + }default :return -EINVAL ; } - +return 0 ; }static const struct file_operations i2c_fops = { - .owner =THIS_MODULE , - .ioctl = i2c_ioctl, - .open = i2c_open, - .release = i2c_release, + .owner =THIS_MODULE , + .unlocked_ioctl = i2c_ioctl, + .open = i2c_open, + .release = i2c_release, };int __init
arch/cris/arch-v32/drivers/i2c.c +6 -9
@@ -648,13 +648,10 @@ i2c_release(struct inode *inode, struct/* Main device API. ioctl's to write or read to/from i2c registers. */ -static int -i2c_ioctl (struct inode *inode,struct file *file, -unsigned int cmd,unsigned long arg) +static long i2c_ioctl (struct file *file,unsigned int cmd,unsigned long arg) { -if (_IOC_TYPE (cmd) !=ETRAXI2C_IOCTYPE ) { +if (_IOC_TYPE (cmd) !=ETRAXI2C_IOCTYPE )return -ENOTTY ; - }switch (_IOC_NR (cmd)) {case I2C_WRITEREG :
@@ -687,10 +684,10 @@ i2c_ioctl(struct inode *inode, struct fi }static const struct file_operations i2c_fops = { - .owner =THIS_MODULE , - .ioctl = i2c_ioctl, - .open = i2c_open, - .release = i2c_release, + .owner =THIS_MODULE , + .unlocked_ioctl = i2c_ioctl, + .open = i2c_open, + .release = i2c_release, };static int __init i2c_init (void )