ALSA: usb-audio: add UAC2 sepecific Feature Unit controls
[safe/jmp/linux-2.6] / drivers / i2c / i2c-dev.c
index d34c14c..e0694e4 100644 (file)
@@ -34,7 +34,8 @@
 #include <linux/list.h>
 #include <linux/i2c.h>
 #include <linux/i2c-dev.h>
-#include <asm/uaccess.h>
+#include <linux/jiffies.h>
+#include <linux/uaccess.h>
 
 static struct i2c_driver i2cdev_driver;
 
@@ -131,53 +132,53 @@ static DEVICE_ATTR(name, S_IRUGO, show_adapter_name, NULL);
  * needed by those system calls and by this SMBus interface.
  */
 
-static ssize_t i2cdev_read (struct file *file, char __user *buf, size_t count,
-                            loff_t *offset)
+static ssize_t i2cdev_read(struct file *file, char __user *buf, size_t count,
+               loff_t *offset)
 {
        char *tmp;
        int ret;
 
-       struct i2c_client *client = (struct i2c_client *)file->private_data;
+       struct i2c_client *client = file->private_data;
 
        if (count > 8192)
                count = 8192;
 
-       tmp = kmalloc(count,GFP_KERNEL);
-       if (tmp==NULL)
+       tmp = kmalloc(count, GFP_KERNEL);
+       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);
+       ret = i2c_master_recv(client, tmp, count);
        if (ret >= 0)
-               ret = copy_to_user(buf,tmp,count)?-EFAULT:ret;
+               ret = copy_to_user(buf, tmp, count) ? -EFAULT : ret;
        kfree(tmp);
        return ret;
 }
 
-static ssize_t i2cdev_write (struct file *file, const char __user *buf, size_t count,
-                             loff_t *offset)
+static ssize_t i2cdev_write(struct file *file, const char __user *buf,
+               size_t count, loff_t *offset)
 {
        int ret;
        char *tmp;
-       struct i2c_client *client = (struct i2c_client *)file->private_data;
+       struct i2c_client *client = file->private_data;
 
        if (count > 8192)
                count = 8192;
 
-       tmp = kmalloc(count,GFP_KERNEL);
-       if (tmp==NULL)
+       tmp = kmalloc(count, GFP_KERNEL);
+       if (tmp == NULL)
                return -ENOMEM;
-       if (copy_from_user(tmp,buf,count)) {
+       if (copy_from_user(tmp, buf, count)) {
                kfree(tmp);
                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);
+       ret = i2c_master_send(client, tmp, count);
        kfree(tmp);
        return ret;
 }
@@ -366,16 +367,15 @@ 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;
+       struct i2c_client *client = file->private_data;
        unsigned long funcs;
 
        dev_dbg(&client->adapter->dev, "ioctl, cmd=0x%02x, arg=0x%02lx\n",
                cmd, arg);
 
-       switch ( cmd ) {
+       switch (cmd) {
        case I2C_SLAVE:
        case I2C_SLAVE_FORCE:
                /* NOTE:  devices set up to work with "new style" drivers
@@ -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)
@@ -603,7 +601,7 @@ static void __exit i2c_dev_exit(void)
 {
        i2c_del_driver(&i2cdev_driver);
        class_destroy(i2c_dev_class);
-       unregister_chrdev(I2C_MAJOR,"i2c");
+       unregister_chrdev(I2C_MAJOR, "i2c");
 }
 
 MODULE_AUTHOR("Frodo Looijaard <frodol@dds.nl> and "