[PATCH] hwmon: Discard bogus comment about init setting limits
[safe/jmp/linux-2.6] / drivers / hwmon / w83792d.c
index fa43b6f..7bbd188 100644 (file)
 #include <linux/init.h>
 #include <linux/slab.h>
 #include <linux/i2c.h>
-#include <linux/i2c-sensor.h>
-#include <linux/i2c-vid.h>
+#include <linux/hwmon.h>
 #include <linux/hwmon-sysfs.h>
+#include <linux/err.h>
 
 /* Addresses to scan */
 static unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, 0x2f, I2C_CLIENT_END };
 
 /* Insmod parameters */
-SENSORS_INSMOD_1(w83792d);
+I2C_CLIENT_INSMOD_1(w83792d);
 I2C_CLIENT_MODULE_PARM(force_subclients, "List of subclient addresses: "
                        "{bus, clientaddr, subclientaddr1, subclientaddr2}");
 
@@ -267,6 +267,7 @@ DIV_TO_REG(long val)
 
 struct w83792d_data {
        struct i2c_client client;
+       struct class_device *class_dev;
        struct semaphore lock;
        enum chips type;
 
@@ -1073,7 +1074,7 @@ w83792d_attach_adapter(struct i2c_adapter *adapter)
 {
        if (!(adapter->class & I2C_CLASS_HWMON))
                return 0;
-       return i2c_detect(adapter, &addr_data, w83792d_detect);
+       return i2c_probe(adapter, &addr_data, w83792d_detect);
 }
 
 
@@ -1289,6 +1290,11 @@ w83792d_detect(struct i2c_adapter *adapter, int address, int kind)
        }
 
        /* Register sysfs hooks */
+       data->class_dev = hwmon_device_register(&new_client->dev);
+       if (IS_ERR(data->class_dev)) {
+               err = PTR_ERR(data->class_dev);
+               goto ERROR3;
+       }
        device_create_file_in(new_client, 0);
        device_create_file_in(new_client, 1);
        device_create_file_in(new_client, 2);
@@ -1361,6 +1367,15 @@ w83792d_detect(struct i2c_adapter *adapter, int address, int kind)
 
        return 0;
 
+ERROR3:
+       if (data->lm75[0] != NULL) {
+               i2c_detach_client(data->lm75[0]);
+               kfree(data->lm75[0]);
+       }
+       if (data->lm75[1] != NULL) {
+               i2c_detach_client(data->lm75[1]);
+               kfree(data->lm75[1]);
+       }
 ERROR2:
        i2c_detach_client(new_client);
 ERROR1:
@@ -1372,21 +1387,22 @@ ERROR0:
 static int
 w83792d_detach_client(struct i2c_client *client)
 {
+       struct w83792d_data *data = i2c_get_clientdata(client);
        int err;
 
-       if ((err = i2c_detach_client(client))) {
-               dev_err(&client->dev,
-                       "Client deregistration failed, client not detached.\n");
+       /* main client */
+       if (data)
+               hwmon_device_unregister(data->class_dev);
+
+       if ((err = i2c_detach_client(client)))
                return err;
-       }
 
-       if (i2c_get_clientdata(client)==NULL) {
-               /* subclients */
+       /* main client */
+       if (data)
+               kfree(data);
+       /* subclient */
+       else
                kfree(client);
-       } else {
-               /* main client */
-               kfree(i2c_get_clientdata(client));
-       }
 
        return 0;
 }
@@ -1413,7 +1429,6 @@ w83792d_write_value(struct i2c_client *client, u8 reg, u8 value)
        return 0;
 }
 
-/* Called when we have found a new W83792D. It should set limits, etc. */
 static void
 w83792d_init_client(struct i2c_client *client)
 {