go7007: Convert to the new i2c device binding model
[safe/jmp/linux-2.6] / drivers / staging / go7007 / wis-uda1342.c
index 555645c..739c7ae 100644 (file)
@@ -59,73 +59,51 @@ static int wis_uda1342_command(struct i2c_client *client,
        return 0;
 }
 
-static struct i2c_driver wis_uda1342_driver;
-
-static struct i2c_client wis_uda1342_client_templ = {
-       .name           = "UDA1342 (WIS)",
-       .driver         = &wis_uda1342_driver,
-};
-
-static int wis_uda1342_detect(struct i2c_adapter *adapter, int addr, int kind)
+static int wis_uda1342_probe(struct i2c_client *client,
+                            const struct i2c_device_id *id)
 {
-       struct i2c_client *client;
+       struct i2c_adapter *adapter = client->adapter;
 
        if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_WORD_DATA))
-               return 0;
-
-       client = kmalloc(sizeof(struct i2c_client), GFP_KERNEL);
-       if (client == NULL)
-               return -ENOMEM;
-       memcpy(client, &wis_uda1342_client_templ,
-                       sizeof(wis_uda1342_client_templ));
-       client->adapter = adapter;
-       client->addr = addr;
+               return -ENODEV;
 
        printk(KERN_DEBUG
                "wis-uda1342: initializing UDA1342 at address %d on %s\n",
-               addr, adapter->name);
+               client->addr, adapter->name);
 
        write_reg(client, 0x00, 0x8000); /* reset registers */
        write_reg(client, 0x00, 0x1241); /* select input 1 */
 
-       i2c_attach_client(client);
        return 0;
 }
 
-static int wis_uda1342_detach(struct i2c_client *client)
+static int wis_uda1342_remove(struct i2c_client *client)
 {
-       int r;
-
-       r = i2c_detach_client(client);
-       if (r < 0)
-               return r;
-
-       kfree(client);
        return 0;
 }
 
+static struct i2c_device_id wis_uda1342_id[] = {
+       { "wis_uda1342", 0 },
+       { }
+};
+
 static struct i2c_driver wis_uda1342_driver = {
        .driver = {
                .name   = "WIS UDA1342 I2C driver",
        },
-       .id             = I2C_DRIVERID_WIS_UDA1342,
-       .detach_client  = wis_uda1342_detach,
+       .probe          = wis_uda1342_probe,
+       .remove         = wis_uda1342_remove,
        .command        = wis_uda1342_command,
+       .id_table       = wis_uda1342_id,
 };
 
 static int __init wis_uda1342_init(void)
 {
-       int r;
-
-       r = i2c_add_driver(&wis_uda1342_driver);
-       if (r < 0)
-               return r;
-       return wis_i2c_add_driver(wis_uda1342_driver.id, wis_uda1342_detect);
+       return i2c_add_driver(&wis_uda1342_driver);
 }
 
 static void __exit wis_uda1342_cleanup(void)
 {
-       wis_i2c_del_driver(wis_uda1342_detect);
        i2c_del_driver(&wis_uda1342_driver);
 }