Merge git://git.skbuff.net/gitroot/yoshfuji/linux-2.6.14+advapi-fix/
[powerpc.git] / drivers / i2c / chips / pcf8591.c
index db812ad..ce420a6 100644 (file)
 #include <linux/init.h>
 #include <linux/slab.h>
 #include <linux/i2c.h>
-#include <linux/i2c-sensor.h>
 
 /* Addresses to scan */
 static unsigned short normal_i2c[] = { 0x48, 0x49, 0x4a, 0x4b, 0x4c,
                                        0x4d, 0x4e, 0x4f, I2C_CLIENT_END };
-static unsigned int normal_isa[] = { I2C_CLIENT_ISA_END };
 
 /* Insmod parameters */
-SENSORS_INSMOD_1(pcf8591);
+I2C_CLIENT_INSMOD_1(pcf8591);
 
 static int input_mode;
 module_param(input_mode, int, 0);
@@ -164,11 +162,11 @@ static DEVICE_ATTR(out0_enable, S_IWUSR | S_IRUGO,
  */
 static int pcf8591_attach_adapter(struct i2c_adapter *adapter)
 {
-       return i2c_detect(adapter, &addr_data, pcf8591_detect);
+       return i2c_probe(adapter, &addr_data, pcf8591_detect);
 }
 
-/* This function is called by i2c_detect */
-int pcf8591_detect(struct i2c_adapter *adapter, int address, int kind)
+/* This function is called by i2c_probe */
+static int pcf8591_detect(struct i2c_adapter *adapter, int address, int kind)
 {
        struct i2c_client *new_client;
        struct pcf8591_data *data;
@@ -180,11 +178,10 @@ int pcf8591_detect(struct i2c_adapter *adapter, int address, int kind)
 
        /* OK. For now, we presume we have a valid client. We now create the
           client structure, even though we cannot fill it completely yet. */
-       if (!(data = kmalloc(sizeof(struct pcf8591_data), GFP_KERNEL))) {
+       if (!(data = kzalloc(sizeof(struct pcf8591_data), GFP_KERNEL))) {
                err = -ENOMEM;
                goto exit;
        }
-       memset(data, 0, sizeof(struct pcf8591_data));
        
        new_client = &data->client;
        i2c_set_clientdata(new_client, data);
@@ -241,11 +238,8 @@ static int pcf8591_detach_client(struct i2c_client *client)
 {
        int err;
 
-       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(i2c_get_clientdata(client));
        return 0;