Commit 2d36de85 authored by Trilok Soni's avatar Trilok Soni Committed by Tony Lindgren

ARM: OMAP: TWL4030 core misc. cleanups.

- Add pr_err and CodingStyle cleanups.
Signed-off-by: default avatarTrilok Soni <soni.trilok@gmail.com>
Signed-off-by: default avatarTony Lindgren <tony@atomide.com>
parent 56b1853b
...@@ -49,6 +49,10 @@ ...@@ -49,6 +49,10 @@
#include <asm/arch/gpio.h> #include <asm/arch/gpio.h>
#include <asm/arch/mux.h> #include <asm/arch/mux.h>
#define DRIVER_NAME "twl4030"
#define pr_err(fmt, arg...) printk(KERN_ERR DRIVER_NAME ": " fmt, ##arg);
/**** Macro Definitions */ /**** Macro Definitions */
#define TWL_CLIENT_STRING "TWL4030-ID" #define TWL_CLIENT_STRING "TWL4030-ID"
#define TWL_CLIENT_USED 1 #define TWL_CLIENT_USED 1
...@@ -257,16 +261,15 @@ int twl4030_i2c_write(u8 mod_no, u8 * value, u8 reg, u8 num_bytes) ...@@ -257,16 +261,15 @@ int twl4030_i2c_write(u8 mod_no, u8 * value, u8 reg, u8 num_bytes)
struct i2c_msg *msg; struct i2c_msg *msg;
if (unlikely(mod_no > TWL4030_MODULE_LAST)) { if (unlikely(mod_no > TWL4030_MODULE_LAST)) {
printk(KERN_ERR "TWL4030: Invalid module Number\n"); pr_err("Invalid module Number\n");
return -EPERM; return -EPERM;
} }
sid = twl4030_map[mod_no].sid; sid = twl4030_map[mod_no].sid;
client = &(twl4030_modules[sid]); client = &(twl4030_modules[sid]);
if (unlikely(client->inuse != TWL_CLIENT_USED)) { if (unlikely(client->inuse != TWL_CLIENT_USED)) {
printk(KERN_ERR pr_err("I2C Client[%d] is not initialized[%d]\n",
"TWL4030: I2C Client[%d] is not initialized[%d]\n", sid,__LINE__);
sid, __LINE__);
return -EPERM; return -EPERM;
} }
down(&(client->xfer_lock)); down(&(client->xfer_lock));
...@@ -307,17 +310,17 @@ int twl4030_i2c_read(u8 mod_no, u8 * value, u8 reg, u8 num_bytes) ...@@ -307,17 +310,17 @@ int twl4030_i2c_read(u8 mod_no, u8 * value, u8 reg, u8 num_bytes)
int sid; int sid;
struct twl4030_client *client; struct twl4030_client *client;
struct i2c_msg *msg; struct i2c_msg *msg;
if (unlikely(mod_no > TWL4030_MODULE_LAST)) { if (unlikely(mod_no > TWL4030_MODULE_LAST)) {
printk(KERN_ERR "TWL4030: Invalid module Number\n"); pr_err("Invalid module Number\n");
return -EPERM; return -EPERM;
} }
sid = twl4030_map[mod_no].sid; sid = twl4030_map[mod_no].sid;
client = &(twl4030_modules[sid]); client = &(twl4030_modules[sid]);
if (unlikely(client->inuse != TWL_CLIENT_USED)) { if (unlikely(client->inuse != TWL_CLIENT_USED)) {
printk(KERN_ERR pr_err("I2C Client[%d] is not initialized[%d]\n", sid,
"TWL4030: I2C Client[%d] is not initialized[%d]\n", __LINE__);
sid, __LINE__);
return -EPERM; return -EPERM;
} }
down(&(client->xfer_lock)); down(&(client->xfer_lock));
...@@ -355,6 +358,7 @@ int twl4030_i2c_read(u8 mod_no, u8 * value, u8 reg, u8 num_bytes) ...@@ -355,6 +358,7 @@ int twl4030_i2c_read(u8 mod_no, u8 * value, u8 reg, u8 num_bytes)
int twl4030_i2c_write_u8(u8 mod_no, u8 value, u8 reg) int twl4030_i2c_write_u8(u8 mod_no, u8 value, u8 reg)
{ {
int ret; int ret;
/* 2 bytes offset 1 contains the data offset 0 is used by i2c_write */ /* 2 bytes offset 1 contains the data offset 0 is used by i2c_write */
u8 temp_buffer[2] = { 0 }; u8 temp_buffer[2] = { 0 };
/* offset 1 contains the data */ /* offset 1 contains the data */
...@@ -375,6 +379,7 @@ int twl4030_i2c_write_u8(u8 mod_no, u8 value, u8 reg) ...@@ -375,6 +379,7 @@ int twl4030_i2c_write_u8(u8 mod_no, u8 value, u8 reg)
int twl4030_i2c_read_u8(u8 mod_no, u8 * value, u8 reg) int twl4030_i2c_read_u8(u8 mod_no, u8 * value, u8 reg)
{ {
int ret = 0; int ret = 0;
ret = twl4030_i2c_read(mod_no, value, reg, 1); ret = twl4030_i2c_read(mod_no, value, reg, 1);
return ret; return ret;
} }
...@@ -535,24 +540,21 @@ static int twl4030_detect_client(struct i2c_adapter *adapter, unsigned char sid) ...@@ -535,24 +540,21 @@ static int twl4030_detect_client(struct i2c_adapter *adapter, unsigned char sid)
{ {
int err = 0; int err = 0;
struct twl4030_client *client; struct twl4030_client *client;
if (unlikely(sid >= TWL4030_NUM_SLAVES)) { if (unlikely(sid >= TWL4030_NUM_SLAVES)) {
printk(KERN_ERR "TWL4030: sid[%d] >MOD_LAST[%d]\n", sid, pr_err("sid[%d] > MOD_LAST[%d]\n", sid, TWL4030_NUM_SLAVES);
TWL4030_NUM_SLAVES);
return -EPERM; return -EPERM;
} }
/* Check basic functionality */ /* Check basic functionality */
if (!(err = i2c_check_functionality(adapter, I2C_FUNC_SMBUS_WORD_DATA | if (!(err = i2c_check_functionality(adapter, I2C_FUNC_SMBUS_WORD_DATA |
I2C_FUNC_SMBUS_WRITE_BYTE))) { I2C_FUNC_SMBUS_WRITE_BYTE))) {
printk(KERN_WARNING pr_err("SlaveID=%d functionality check failed\n", sid);
"TWL4030: SlaveID=%d functionality check failed\n", sid);
return err; return err;
} }
client = &(twl4030_modules[sid]); client = &(twl4030_modules[sid]);
if (unlikely(client->inuse)) { if (unlikely(client->inuse)) {
printk(KERN_ERR "TWL4030: Client is already in Use.....\n"); pr_err("Client %s is already in use\n", client->client_name);
printk("%s[ID=0x%x] NOT attached to I2c Adapter %s\n",
client->client_name, client->address, adapter->name);
return -EPERM; return -EPERM;
} }
...@@ -564,17 +566,18 @@ static int twl4030_detect_client(struct i2c_adapter *adapter, unsigned char sid) ...@@ -564,17 +566,18 @@ static int twl4030_detect_client(struct i2c_adapter *adapter, unsigned char sid)
memcpy(&(client->client.name), client->client_name, memcpy(&(client->client.name), client->client_name,
sizeof(TWL_CLIENT_STRING) + 1); sizeof(TWL_CLIENT_STRING) + 1);
printk("TWL4030: TRY attach Slave %s on Adapter %s[%d][%x]\n",
client->client_name, adapter->name, err, err); pr_info("TWL4030: TRY attach Slave %s on Adapter %s [%x]\n",
if ((err = i2c_attach_client(&(client->client)))) client->client_name, adapter->name, err);
printk(KERN_WARNING
"TWL4030: Couldn't attach Slave %s on Adapter " if ((err = i2c_attach_client(&(client->client)))) {
"%s[%d][%x]\n", pr_err("Couldn't attach Slave %s on Adapter"
client->client_name, adapter->name, err, err); "%s [%x]\n", client->client_name, adapter->name, err);
else { } else {
client->inuse = TWL_CLIENT_USED; client->inuse = TWL_CLIENT_USED;
init_MUTEX(&client->xfer_lock); init_MUTEX(&client->xfer_lock);
} }
return err; return err;
} }
...@@ -584,6 +587,7 @@ static int twl4030_attach_adapter(struct i2c_adapter *adapter) ...@@ -584,6 +587,7 @@ static int twl4030_attach_adapter(struct i2c_adapter *adapter)
int i; int i;
int ret = 0; int ret = 0;
static int twl_i2c_adapter = 1; static int twl_i2c_adapter = 1;
for (i = 0; i < TWL4030_NUM_SLAVES; i++) { for (i = 0; i < TWL4030_NUM_SLAVES; i++) {
/* Check if I need to hook on to this adapter or not */ /* Check if I need to hook on to this adapter or not */
if (twl4030_modules[i].adapter_index == twl_i2c_adapter) { if (twl4030_modules[i].adapter_index == twl_i2c_adapter) {
...@@ -605,9 +609,7 @@ static int twl4030_attach_adapter(struct i2c_adapter *adapter) ...@@ -605,9 +609,7 @@ static int twl4030_attach_adapter(struct i2c_adapter *adapter)
return 0; return 0;
free_client: free_client:
printk(KERN_ERR pr_err("TWL_CLIENT(Idx=%d] registration failed[0x%x]\n",i,ret);
"TWL4030: TWL_CLIENT(Idx=%d] REGISTRATION FAILED=%d[0x%x]\n", i,
ret, ret);
/* ignore current slave..it never got registered */ /* ignore current slave..it never got registered */
i--; i--;
...@@ -625,8 +627,7 @@ static int twl4030_detach_client(struct i2c_client *iclient) ...@@ -625,8 +627,7 @@ static int twl4030_detach_client(struct i2c_client *iclient)
{ {
int err; int err;
if ((err = i2c_detach_client(iclient))) { if ((err = i2c_detach_client(iclient))) {
printk(KERN_ERR pr_err("Client detach failed\n");
"TWL4030: Client deregistration failed, client not detached.\n");
return err; return err;
} }
return 0; return 0;
...@@ -639,8 +640,8 @@ struct task_struct *start_twl4030_irq_thread(int irq) ...@@ -639,8 +640,8 @@ struct task_struct *start_twl4030_irq_thread(int irq)
thread = kthread_create(twl4030_irq_thread, (void *)irq, thread = kthread_create(twl4030_irq_thread, (void *)irq,
"twl4030 irq %d", irq); "twl4030 irq %d", irq);
if (!thread) if (!thread)
printk(KERN_ERR "%s: could not create twl4030 irq %d thread!\n", pr_err("%s: could not create twl4030 irq %d thread!\n",
__FUNCTION__, irq); __FUNCTION__,irq);
return thread; return thread;
} }
...@@ -652,6 +653,7 @@ struct task_struct *start_twl4030_irq_thread(int irq) ...@@ -652,6 +653,7 @@ struct task_struct *start_twl4030_irq_thread(int irq)
static int protect_pm_master(void) static int protect_pm_master(void)
{ {
int e = 0; int e = 0;
e = twl4030_i2c_write_u8(TWL4030_MODULE_PM_MASTER, KEY_LOCK, e = twl4030_i2c_write_u8(TWL4030_MODULE_PM_MASTER, KEY_LOCK,
R_PROTECT_KEY); R_PROTECT_KEY);
return e; return e;
...@@ -660,6 +662,7 @@ static int protect_pm_master(void) ...@@ -660,6 +662,7 @@ static int protect_pm_master(void)
static int unprotect_pm_master(void) static int unprotect_pm_master(void)
{ {
int e = 0; int e = 0;
e |= twl4030_i2c_write_u8(TWL4030_MODULE_PM_MASTER, KEY_UNLOCK1, e |= twl4030_i2c_write_u8(TWL4030_MODULE_PM_MASTER, KEY_UNLOCK1,
R_PROTECT_KEY); R_PROTECT_KEY);
e |= twl4030_i2c_write_u8(TWL4030_MODULE_PM_MASTER, KEY_UNLOCK2, e |= twl4030_i2c_write_u8(TWL4030_MODULE_PM_MASTER, KEY_UNLOCK2,
...@@ -697,6 +700,7 @@ static void twl_init_irq(void) ...@@ -697,6 +700,7 @@ static void twl_init_irq(void)
int i = 0; int i = 0;
int res = 0; int res = 0;
int line = 0; int line = 0;
/* /*
* We end up with interrupts from other modules before * We end up with interrupts from other modules before
* they get a chance to handle them... * they get a chance to handle them...
...@@ -873,20 +877,22 @@ static void twl_init_irq(void) ...@@ -873,20 +877,22 @@ static void twl_init_irq(void)
irq_exit_path: irq_exit_path:
if (res) if (res)
printk(KERN_ERR pr_err("Unable to register interrupt subsystem[%d][%d]\n",
"TWL4030: Unable to register interrupt " res,line);
"subsystem[%d][%d]\n", res, line);
} }
static int __init twl4030_init(void) static int __init twl4030_init(void)
{ {
int res; int res;
if ((res = i2c_register_driver(THIS_MODULE, &twl4030_driver))) {
if ((res = i2c_add_driver(&twl4030_driver))) {
printk(KERN_ERR "TWL4030: Driver registration failed \n"); printk(KERN_ERR "TWL4030: Driver registration failed \n");
return res; return res;
} }
printk(KERN_INFO "TWL4030: Driver registration complete.\n");
return res; pr_info(KERN_INFO "TWL4030: Driver registration complete.\n");
return 0;
} }
static void __exit twl4030_exit(void) static void __exit twl4030_exit(void)
......
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