i2c: Document the message size limit
[safe/jmp/linux-2.6] / drivers / i2c / i2c-dev.c
index d34c14c..f4110aa 100644 (file)
@@ -34,6 +34,7 @@
 #include <linux/list.h>
 #include <linux/i2c.h>
 #include <linux/i2c-dev.h>
+#include <linux/jiffies.h>
 #include <asm/uaccess.h>
 
 static struct i2c_driver i2cdev_driver;
@@ -146,7 +147,7 @@ static ssize_t i2cdev_read (struct file *file, char __user *buf, size_t count,
        if (tmp==NULL)
                return -ENOMEM;
 
-       pr_debug("i2c-dev: i2c-%d reading %zd bytes.\n",
+       pr_debug("i2c-dev: i2c-%d reading %zu bytes.\n",
                iminor(file->f_path.dentry->d_inode), count);
 
        ret = i2c_master_recv(client,tmp,count);
@@ -174,7 +175,7 @@ static ssize_t i2cdev_write (struct file *file, const char __user *buf, size_t c
                return -EFAULT;
        }
 
-       pr_debug("i2c-dev: i2c-%d writing %zd bytes.\n",
+       pr_debug("i2c-dev: i2c-%d writing %zu bytes.\n",
                iminor(file->f_path.dentry->d_inode), count);
 
        ret = i2c_master_send(client,tmp,count);
@@ -366,8 +367,7 @@ static noinline int i2cdev_ioctl_smbus(struct i2c_client *client,
        return res;
 }
 
-static int i2cdev_ioctl(struct inode *inode, struct file *file,
-               unsigned int cmd, unsigned long arg)
+static long i2cdev_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
 {
        struct i2c_client *client = (struct i2c_client *)file->private_data;
        unsigned long funcs;
@@ -422,7 +422,10 @@ static int i2cdev_ioctl(struct inode *inode, struct file *file,
                client->adapter->retries = arg;
                break;
        case I2C_TIMEOUT:
-               client->adapter->timeout = arg;
+               /* For historical reasons, user-space sets the timeout
+                * value in units of 10 ms.
+                */
+               client->adapter->timeout = msecs_to_jiffies(arg * 10);
                break;
        default:
                /* NOTE:  returning a fault code here could cause trouble
@@ -487,7 +490,7 @@ static const struct file_operations i2cdev_fops = {
        .llseek         = no_llseek,
        .read           = i2cdev_read,
        .write          = i2cdev_write,
-       .ioctl          = i2cdev_ioctl,
+       .unlocked_ioctl = i2cdev_ioctl,
        .open           = i2cdev_open,
        .release        = i2cdev_release,
 };
@@ -513,7 +516,7 @@ static int i2cdev_attach_adapter(struct i2c_adapter *adap)
 
        /* register this i2c device with the driver core */
        i2c_dev->dev = device_create(i2c_dev_class, &adap->dev,
-                                    MKDEV(I2C_MAJOR, adap->nr),
+                                    MKDEV(I2C_MAJOR, adap->nr), NULL,
                                     "i2c-%d", adap->nr);
        if (IS_ERR(i2c_dev->dev)) {
                res = PTR_ERR(i2c_dev->dev);
@@ -549,19 +552,12 @@ static int i2cdev_detach_adapter(struct i2c_adapter *adap)
        return 0;
 }
 
-static int i2cdev_detach_client(struct i2c_client *client)
-{
-       return 0;
-}
-
 static struct i2c_driver i2cdev_driver = {
        .driver = {
                .name   = "dev_driver",
        },
-       .id             = I2C_DRIVERID_I2CDEV,
        .attach_adapter = i2cdev_attach_adapter,
        .detach_adapter = i2cdev_detach_adapter,
-       .detach_client  = i2cdev_detach_client,
 };
 
 /* ------------------------------------------------------------------------- */
@@ -581,8 +577,10 @@ static int __init i2c_dev_init(void)
                goto out;
 
        i2c_dev_class = class_create(THIS_MODULE, "i2c-dev");
-       if (IS_ERR(i2c_dev_class))
+       if (IS_ERR(i2c_dev_class)) {
+               res = PTR_ERR(i2c_dev_class);
                goto out_unreg_chrdev;
+       }
 
        res = i2c_add_driver(&i2cdev_driver);
        if (res)