Commit 5de4155b authored by Jean Delvare's avatar Jean Delvare Committed by Takashi Iwai

ALSA: keywest: Convert to new-style i2c driver

The legacy i2c binding model is going away soon, so convert the ppc
keywest sound driver to the new model or it will break.
Signed-off-by: default avatarJean Delvare <khali@linux-fr.org>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent cfbf1eec
...@@ -33,26 +33,25 @@ ...@@ -33,26 +33,25 @@
static struct pmac_keywest *keywest_ctx; static struct pmac_keywest *keywest_ctx;
static int keywest_attach_adapter(struct i2c_adapter *adapter);
static int keywest_detach_client(struct i2c_client *client);
struct i2c_driver keywest_driver = {
.driver = {
.name = "PMac Keywest Audio",
},
.attach_adapter = &keywest_attach_adapter,
.detach_client = &keywest_detach_client,
};
#ifndef i2c_device_name #ifndef i2c_device_name
#define i2c_device_name(x) ((x)->name) #define i2c_device_name(x) ((x)->name)
#endif #endif
static int keywest_probe(struct i2c_client *client,
const struct i2c_device_id *id)
{
i2c_set_clientdata(client, keywest_ctx);
return 0;
}
/*
* This is kind of a hack, best would be to turn powermac to fixed i2c
* bus numbers and declare the sound device as part of platform
* initialization
*/
static int keywest_attach_adapter(struct i2c_adapter *adapter) static int keywest_attach_adapter(struct i2c_adapter *adapter)
{ {
int err; struct i2c_board_info info;
struct i2c_client *new_client;
if (! keywest_ctx) if (! keywest_ctx)
return -EINVAL; return -EINVAL;
...@@ -60,46 +59,47 @@ static int keywest_attach_adapter(struct i2c_adapter *adapter) ...@@ -60,46 +59,47 @@ static int keywest_attach_adapter(struct i2c_adapter *adapter)
if (strncmp(i2c_device_name(adapter), "mac-io", 6)) if (strncmp(i2c_device_name(adapter), "mac-io", 6))
return 0; /* ignored */ return 0; /* ignored */
new_client = kzalloc(sizeof(struct i2c_client), GFP_KERNEL); memset(&info, 0, sizeof(struct i2c_board_info));
if (! new_client) strlcpy(info.type, "keywest", I2C_NAME_SIZE);
return -ENOMEM; info.addr = keywest_ctx->addr;
keywest_ctx->client = i2c_new_device(adapter, &info);
new_client->addr = keywest_ctx->addr;
i2c_set_clientdata(new_client, keywest_ctx);
new_client->adapter = adapter;
new_client->driver = &keywest_driver;
new_client->flags = 0;
strcpy(i2c_device_name(new_client), keywest_ctx->name);
keywest_ctx->client = new_client;
/* Tell the i2c layer a new client has arrived */ /*
if (i2c_attach_client(new_client)) { * Let i2c-core delete that device on driver removal.
snd_printk(KERN_ERR "tumbler: cannot attach i2c client\n"); * This is safe because i2c-core holds the core_lock mutex for us.
err = -ENODEV; */
goto __err; list_add_tail(&keywest_ctx->client->detected,
} &keywest_ctx->client->driver->clients);
return 0; return 0;
__err:
kfree(new_client);
keywest_ctx->client = NULL;
return err;
} }
static int keywest_detach_client(struct i2c_client *client) static int keywest_remove(struct i2c_client *client)
{ {
i2c_set_clientdata(client, NULL);
if (! keywest_ctx) if (! keywest_ctx)
return 0; return 0;
if (client == keywest_ctx->client) if (client == keywest_ctx->client)
keywest_ctx->client = NULL; keywest_ctx->client = NULL;
i2c_detach_client(client);
kfree(client);
return 0; return 0;
} }
static const struct i2c_device_id keywest_i2c_id[] = {
{ "keywest", 0 },
{ }
};
struct i2c_driver keywest_driver = {
.driver = {
.name = "PMac Keywest Audio",
},
.attach_adapter = keywest_attach_adapter,
.probe = keywest_probe,
.remove = keywest_remove,
.id_table = keywest_i2c_id,
};
/* exported */ /* exported */
void snd_pmac_keywest_cleanup(struct pmac_keywest *i2c) void snd_pmac_keywest_cleanup(struct pmac_keywest *i2c)
{ {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment