Merge master.kernel.org:/pub/scm/linux/kernel/git/mchehab/v4l-dvb
[powerpc.git] / drivers / i2c / chips / pca9539.c
index 225577f..cb22280 100644 (file)
@@ -38,9 +38,9 @@ static int pca9539_detach_client(struct i2c_client *client);
 
 /* This is the driver that will be inserted */
 static struct i2c_driver pca9539_driver = {
-       .owner          = THIS_MODULE,
-       .name           = "pca9539",
-       .flags          = I2C_DF_NOTIFY,
+       .driver = {
+               .name   = "pca9539",
+       },
        .attach_adapter = pca9539_attach_adapter,
        .detach_client  = pca9539_detach_client,
 };
@@ -122,11 +122,10 @@ static int pca9539_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 pca9539_data), GFP_KERNEL))) {
+       if (!(data = kzalloc(sizeof(struct pca9539_data), GFP_KERNEL))) {
                err = -ENOMEM;
                goto exit;
        }
-       memset(data, 0, sizeof(struct pca9539_data));
 
        new_client = &data->client;
        i2c_set_clientdata(new_client, data);
@@ -135,11 +134,13 @@ static int pca9539_detect(struct i2c_adapter *adapter, int address, int kind)
        new_client->driver = &pca9539_driver;
        new_client->flags = 0;
 
-       /* Detection: the pca9539 only has 8 registers (0-7).
-          A read of 7 should succeed, but a read of 8 should fail. */
-       if ((i2c_smbus_read_byte_data(new_client, 7) < 0) ||
-           (i2c_smbus_read_byte_data(new_client, 8) >= 0))
-               goto exit_kfree;
+       if (kind < 0) {
+               /* Detection: the pca9539 only has 8 registers (0-7).
+                  A read of 7 should succeed, but a read of 8 should fail. */
+               if ((i2c_smbus_read_byte_data(new_client, 7) < 0) ||
+                   (i2c_smbus_read_byte_data(new_client, 8) >= 0))
+                       goto exit_kfree;
+       }
 
        strlcpy(new_client->name, "pca9539", I2C_NAME_SIZE);