V4L/DVB (3488): Snd_cx88_create: don't dereference NULL core
[safe/jmp/linux-2.6] / drivers / hwmon / ds1621.c
index 4a316a7..203f9c7 100644 (file)
@@ -26,7 +26,6 @@
 #include <linux/slab.h>
 #include <linux/jiffies.h>
 #include <linux/i2c.h>
-#include <linux/i2c-sensor.h>
 #include <linux/hwmon.h>
 #include <linux/err.h>
 #include "lm75.h"
@@ -36,7 +35,7 @@ static unsigned short normal_i2c[] = { 0x48, 0x49, 0x4a, 0x4b, 0x4c,
                                        0x4d, 0x4e, 0x4f, I2C_CLIENT_END };
 
 /* Insmod parameters */
-SENSORS_INSMOD_1(ds1621);
+I2C_CLIENT_INSMOD_1(ds1621);
 static int polarity = -1;
 module_param(polarity, int, 0);
 MODULE_PARM_DESC(polarity, "Output's polarity: 0 = active high, 1 = active low");
@@ -90,10 +89,10 @@ static struct ds1621_data *ds1621_update_client(struct device *dev);
 
 /* This is the driver that will be inserted */
 static struct i2c_driver ds1621_driver = {
-       .owner          = THIS_MODULE,
-       .name           = "ds1621",
+       .driver = {
+               .name   = "ds1621",
+       },
        .id             = I2C_DRIVERID_DS1621,
-       .flags          = I2C_DF_NOTIFY,
        .attach_adapter = ds1621_attach_adapter,
        .detach_client  = ds1621_detach_client,
 };
@@ -181,12 +180,14 @@ static DEVICE_ATTR(temp1_max, S_IWUSR | S_IRUGO, show_temp_max, set_temp_max);
 
 static int ds1621_attach_adapter(struct i2c_adapter *adapter)
 {
-       return i2c_detect(adapter, &addr_data, ds1621_detect);
+       if (!(adapter->class & I2C_CLASS_HWMON))
+               return 0;
+       return i2c_probe(adapter, &addr_data, ds1621_detect);
 }
 
-/* This function is called by i2c_detect */
-int ds1621_detect(struct i2c_adapter *adapter, int address,
-                  int kind)
+/* This function is called by i2c_probe */
+static int ds1621_detect(struct i2c_adapter *adapter, int address,
+                        int kind)
 {
        int conf, temp;
        struct i2c_client *new_client;
@@ -201,11 +202,10 @@ int ds1621_detect(struct i2c_adapter *adapter, int address,
        /* OK. For now, we presume we have a valid client. We now create the
           client structure, even though we cannot fill it completely yet.
           But it allows us to access ds1621_{read,write}_value. */
-       if (!(data = kmalloc(sizeof(struct ds1621_data), GFP_KERNEL))) {
+       if (!(data = kzalloc(sizeof(struct ds1621_data), GFP_KERNEL))) {
                err = -ENOMEM;
                goto exit;
        }
-       memset(data, 0, sizeof(struct ds1621_data));
        
        new_client = &data->client;
        i2c_set_clientdata(new_client, data);
@@ -282,11 +282,8 @@ static int ds1621_detach_client(struct i2c_client *client)
 
        hwmon_device_unregister(data->class_dev);
 
-       if ((err = i2c_detach_client(client))) {
-               dev_err(&client->dev, "Client deregistration failed, "
-                       "client not detached.\n");
+       if ((err = i2c_detach_client(client)))
                return err;
-       }
 
        kfree(data);