Merge branch 'fix/hda' into for-linus
[safe/jmp/linux-2.6] / sound / ppc / keywest.c
index a5afb26..d06f780 100644 (file)
 static struct pmac_keywest *keywest_ctx;
 
 
-#ifndef i2c_device_name
-#define i2c_device_name(x)     ((x)->name)
-#endif
-
 static int keywest_probe(struct i2c_client *client,
                         const struct i2c_device_id *id)
 {
@@ -56,13 +52,25 @@ static int keywest_attach_adapter(struct i2c_adapter *adapter)
        if (! keywest_ctx)
                return -EINVAL;
 
-       if (strncmp(i2c_device_name(adapter), "mac-io", 6))
+       if (strncmp(adapter->name, "mac-io", 6))
                return 0; /* ignored */
 
        memset(&info, 0, sizeof(struct i2c_board_info));
        strlcpy(info.type, "keywest", I2C_NAME_SIZE);
        info.addr = keywest_ctx->addr;
        keywest_ctx->client = i2c_new_device(adapter, &info);
+       if (!keywest_ctx->client)
+               return -ENODEV;
+       /*
+        * We know the driver is already loaded, so the device should be
+        * already bound. If not it means binding failed, and then there
+        * is no point in keeping the device instantiated.
+        */
+       if (!keywest_ctx->client->driver) {
+               i2c_unregister_device(keywest_ctx->client);
+               keywest_ctx->client = NULL;
+               return -ENODEV;
+       }
        
        /*
         * Let i2c-core delete that device on driver removal.
@@ -90,7 +98,7 @@ static const struct i2c_device_id keywest_i2c_id[] = {
        { }
 };
 
-struct i2c_driver keywest_driver = {
+static struct i2c_driver keywest_driver = {
        .driver = {
                .name = "PMac Keywest Audio",
        },
@@ -109,7 +117,7 @@ void snd_pmac_keywest_cleanup(struct pmac_keywest *i2c)
        }
 }
 
-int __init snd_pmac_tumbler_post_init(void)
+int __devinit snd_pmac_tumbler_post_init(void)
 {
        int err;
        
@@ -124,7 +132,7 @@ int __init snd_pmac_tumbler_post_init(void)
 }
 
 /* exported */
-int __init snd_pmac_keywest_init(struct pmac_keywest *i2c)
+int __devinit snd_pmac_keywest_init(struct pmac_keywest *i2c)
 {
        int err;