LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [CRIS] driver: i2c - convert ioctl to unlocked_ioctl
@ 2008-03-06 18:09 Cyrill Gorcunov
0 siblings, 0 replies; only message in thread
From: Cyrill Gorcunov @ 2008-03-06 18:09 UTC (permalink / raw)
To: Mikael Starvik, Jesper Nilsson; +Cc: LKML
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 <gorcunov@gmail.com>
---
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(-)
Index: linux-2.6.git/arch/cris/arch-v10/drivers/i2c.c
===================================================================
--- linux-2.6.git.orig/arch/cris/arch-v10/drivers/i2c.c 2008-02-09 12:09:27.000000000 +0300
+++ linux-2.6.git/arch/cris/arch-v10/drivers/i2c.c 2008-03-06 21:05:17.000000000 +0300
@@ -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
Index: linux-2.6.git/arch/cris/arch-v32/drivers/i2c.c
===================================================================
--- linux-2.6.git.orig/arch/cris/arch-v32/drivers/i2c.c 2008-02-09 12:09:27.000000000 +0300
+++ linux-2.6.git/arch/cris/arch-v32/drivers/i2c.c 2008-03-06 21:05:11.000000000 +0300
@@ -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)
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2008-03-06 18:10 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-03-06 18:09 [CRIS] driver: i2c - convert ioctl to unlocked_ioctl Cyrill Gorcunov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).