fedora core 6 1.2949 + vserver 2.2.0
[linux-2.6.git] / drivers / media / video / ovcamchip / ovcamchip_core.c
index d88956a..3fe9fa0 100644 (file)
@@ -15,6 +15,7 @@
 #include <linux/module.h>
 #include <linux/moduleparam.h>
 #include <linux/slab.h>
+#include <linux/delay.h>
 #include "ovcamchip_priv.h"
 
 #define DRIVER_VERSION "v2.27 for Linux 2.6"
@@ -128,8 +129,7 @@ static int init_camchip(struct i2c_client *c)
        ov_write(c, 0x12, 0x80);
 
        /* Wait for it to initialize */
-       set_current_state(TASK_UNINTERRUPTIBLE);
-       schedule_timeout(1 + 150 * HZ / 1000);
+       msleep(150);
 
        for (i = 0, success = 0; i < I2C_DETECT_RETRIES && !success; i++) {
                if (ov_read(c, GENERIC_REG_ID_HIGH, &high) >= 0) {
@@ -145,8 +145,7 @@ static int init_camchip(struct i2c_client *c)
                ov_write(c, 0x12, 0x80);
 
                /* Wait for it to initialize */
-               set_current_state(TASK_UNINTERRUPTIBLE);
-               schedule_timeout(1 + 150 * HZ / 1000);
+               msleep(150);
 
                /* Dummy read to sync I2C */
                ov_read(c, 0x00, &low);
@@ -267,17 +266,17 @@ static int ovcamchip_detect(struct i2c_client *c)
                PDEBUG(3, "Testing for 0V6xx0");
                c->addr = OV6xx0_SID;
                if (init_camchip(c) < 0) {
-                       return -ENODEV;
+                       return -ENODEV;
                } else {
                        if (ov6xx0_detect(c) < 0) {
                                PERROR("Failed to init OV6xx0");
-                               return -EIO;
+                               return -EIO;
                        }
                }
        } else {
                if (ov7xx0_detect(c) < 0) {
                        PERROR("Failed to init OV7xx0");
-                       return -EIO;
+                       return -EIO;
                }
        }
 
@@ -297,10 +296,10 @@ static int ovcamchip_attach(struct i2c_adapter *adap)
         * attach to adapters that are known to contain OV camera chips. */
 
        switch (adap->id) {
-       case (I2C_ALGO_SMBUS | I2C_HW_SMBUS_OV511):
-       case (I2C_ALGO_SMBUS | I2C_HW_SMBUS_OV518):
-       case (I2C_ALGO_SMBUS | I2C_HW_SMBUS_OVFX2):
-       case (I2C_ALGO_SMBUS | I2C_HW_SMBUS_W9968CF):
+       case I2C_HW_SMBUS_OV511:
+       case I2C_HW_SMBUS_OV518:
+       case I2C_HW_SMBUS_OVFX2:
+       case I2C_HW_SMBUS_W9968CF:
                PDEBUG(1, "Adapter ID 0x%06x accepted", adap->id);
                break;
        default:
@@ -315,21 +314,20 @@ static int ovcamchip_attach(struct i2c_adapter *adap)
        }
        memcpy(c, &client_template, sizeof *c);
        c->adapter = adap;
-       strcpy(i2c_clientname(c), "OV????");
+       strcpy(c->name, "OV????");
 
-       ov = kmalloc(sizeof *ov, GFP_KERNEL);
+       ov = kzalloc(sizeof *ov, GFP_KERNEL);
        if (!ov) {
                rc = -ENOMEM;
                goto no_ov;
        }
-       memset(ov, 0, sizeof *ov);
        i2c_set_clientdata(c, ov);
 
        rc = ovcamchip_detect(c);
        if (rc < 0)
                goto error;
 
-       strcpy(i2c_clientname(c), chip_names[ov->subtype]);
+       strcpy(c->name, chip_names[ov->subtype]);
 
        PDEBUG(1, "Camera chip detection complete");
 
@@ -411,19 +409,18 @@ static int ovcamchip_command(struct i2c_client *c, unsigned int cmd, void *arg)
 /* ----------------------------------------------------------------------- */
 
 static struct i2c_driver driver = {
-       .owner =                THIS_MODULE,
-       .name =                 "ovcamchip",
+       .driver = {
+               .name =         "ovcamchip",
+       },
        .id =                   I2C_DRIVERID_OVCAMCHIP,
        .class =                I2C_CLASS_CAM_DIGITAL,
-       .flags =                I2C_DF_NOTIFY,
        .attach_adapter =       ovcamchip_attach,
        .detach_client =        ovcamchip_detach,
        .command =              ovcamchip_command,
 };
 
 static struct i2c_client client_template = {
-       I2C_DEVNAME("(unset)"),
-       .id =           -1,
+       .name =         "(unset)",
        .driver =       &driver,
 };