Commit 2a9b5560 authored by Kevin Hilman's avatar Kevin Hilman

ARM: DaVinci: i2c client sem2mutex and cleanup

Signed-off-by: default avatarDavid Brownell <dbrownell@users.sourceforge.net>
parent cc92763c
...@@ -32,8 +32,7 @@ ...@@ -32,8 +32,7 @@
#include <asm/semaphore.h> #include <asm/semaphore.h>
#include <asm/arch/i2c-client.h> #include <asm/arch/i2c-client.h>
static unsigned long initialized; static DEFINE_MUTEX(expander_lock);
static struct semaphore expander_sema;
static struct i2c_client *client_handle; static struct i2c_client *client_handle;
/* This function is used for internal initialization */ /* This function is used for internal initialization */
...@@ -97,7 +96,7 @@ int davinci_i2c_expander_op(u16 client_addr, u35_expander_ops pin, u8 val) ...@@ -97,7 +96,7 @@ int davinci_i2c_expander_op(u16 client_addr, u35_expander_ops pin, u8 val)
if (val > 1) if (val > 1)
return -1; return -1;
down(&expander_sema); mutex_lock(&expander_lock);
err = davinci_i2c_read(1, &data_to_u35, 0x3A); err = davinci_i2c_read(1, &data_to_u35, 0x3A);
...@@ -158,13 +157,13 @@ int davinci_i2c_expander_op(u16 client_addr, u35_expander_ops pin, u8 val) ...@@ -158,13 +157,13 @@ int davinci_i2c_expander_op(u16 client_addr, u35_expander_ops pin, u8 val)
} }
} else { } else {
printk("Only IO Expander at address 0x3A is suuported\n"); printk("Only IO Expander at address 0x3A is suuported\n");
up(&expander_sema); mutex_unlock(&expander_lock);
return -1; return -EINVAL;
} }
err = davinci_i2c_write(1, &data_to_u35, 0x3A); err = davinci_i2c_write(1, &data_to_u35, 0x3A);
up(&expander_sema); mutex_unlock(&expander_lock);
return err; return err;
} }
...@@ -192,7 +191,7 @@ static int davinci_i2c_attach_client(struct i2c_adapter *adap, int addr) ...@@ -192,7 +191,7 @@ static int davinci_i2c_attach_client(struct i2c_adapter *adap, int addr)
client->flags = 0; client->flags = 0;
client->driver = &davinci_i2c_client_driver; client->driver = &davinci_i2c_client_driver;
client->adapter = adap; client->adapter = adap;
strlcpy(client->name, "i2c_davinci_client", I2C_NAME_SIZE); strlcpy(client->name, client->driver->driver.name, I2C_NAME_SIZE);
err = i2c_attach_client(client); err = i2c_attach_client(client);
if (err) { if (err) {
...@@ -230,21 +229,22 @@ static int davinci_i2c_probe_adapter(struct i2c_adapter *adap) ...@@ -230,21 +229,22 @@ static int davinci_i2c_probe_adapter(struct i2c_adapter *adap)
/* This is the driver that will be inserted */ /* This is the driver that will be inserted */
static struct i2c_driver davinci_i2c_client_driver = { static struct i2c_driver davinci_i2c_client_driver = {
.driver = { .driver = {
.name = "davinci_i2c_client", /* there are 3 expanders, one is leds-only ... */
.name = "davinci_evm_expander1",
}, },
.attach_adapter = davinci_i2c_probe_adapter, .attach_adapter = davinci_i2c_probe_adapter,
.detach_client = davinci_i2c_detach_client, .detach_client = davinci_i2c_detach_client,
}; };
static int __init davinci_i2c_client_init(void) static int __init davinci_i2c_client_init(void)
{ {
return i2c_add_driver(&davinci_i2c_client_driver); return i2c_add_driver(&davinci_i2c_client_driver);
} }
static void __exit davinci_i2c_client_exit(void) static void __exit davinci_i2c_client_exit(void)
{ {
i2c_del_driver(&davinci_i2c_client_driver); i2c_del_driver(&davinci_i2c_client_driver);
} }
module_init(davinci_i2c_client_init); module_init(davinci_i2c_client_init);
module_exit(davinci_i2c_client_exit); module_exit(davinci_i2c_client_exit);
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