Commit 0c6602a8 authored by Felipe Balbi's avatar Felipe Balbi Committed by Tony Lindgren

I2C: TWL4030: Misc cleanups in twl4030_core.c

Making code more compliant to CodingStyle, also remove
unneeded goto clauses in twl_init_irq.

goto's will generate extra branch instructions before exiting
from the function; instead, exits earlier to avoid such branch
instructions.
Signed-off-by: default avatarFelipe Balbi <felipe.lima@indt.org.br>
Signed-off-by: default avatarTony Lindgren <tony@atomide.com>
parent c749a36a
...@@ -51,7 +51,7 @@ ...@@ -51,7 +51,7 @@
#define DRIVER_NAME "twl4030" #define DRIVER_NAME "twl4030"
/**** 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
#define TWL_CLIENT_FREE 0 #define TWL_CLIENT_FREE 0
...@@ -60,9 +60,9 @@ ...@@ -60,9 +60,9 @@
#define FREE 0 #define FREE 0
#define USED 1 #define USED 1
/** Primary Interrupt Handler on TWL4030 Registers */ /* Primary Interrupt Handler on TWL4030 Registers */
/**** Register Definitions */ /* Register Definitions */
#define REG_PIH_ISR_P1 (0x1) #define REG_PIH_ISR_P1 (0x1)
#define REG_PIH_ISR_P2 (0x2) #define REG_PIH_ISR_P2 (0x2)
...@@ -132,7 +132,7 @@ ...@@ -132,7 +132,7 @@
/* on I2C-1 for 2430SDP */ /* on I2C-1 for 2430SDP */
#define CONFIG_I2C_TWL4030_ID 1 #define CONFIG_I2C_TWL4030_ID 1
/**** Helper functions */ /* Helper functions */
static int static int
twl4030_detect_client(struct i2c_adapter *adapter, unsigned char sid); twl4030_detect_client(struct i2c_adapter *adapter, unsigned char sid);
static int twl4030_attach_adapter(struct i2c_adapter *adapter); static int twl4030_attach_adapter(struct i2c_adapter *adapter);
...@@ -141,7 +141,7 @@ static void do_twl4030_irq(unsigned int irq, irq_desc_t *desc); ...@@ -141,7 +141,7 @@ static void do_twl4030_irq(unsigned int irq, irq_desc_t *desc);
static void twl_init_irq(void); static void twl_init_irq(void);
/**** Data Structures */ /* Data Structures */
/* To have info on T2 IRQ substem activated or not */ /* To have info on T2 IRQ substem activated or not */
static unsigned char twl_irq_used = FREE; static unsigned char twl_irq_used = FREE;
static struct completion irq_event; static struct completion irq_event;
...@@ -268,7 +268,7 @@ int twl4030_i2c_write(u8 mod_no, u8 * value, u8 reg, u8 num_bytes) ...@@ -268,7 +268,7 @@ int twl4030_i2c_write(u8 mod_no, u8 * value, u8 reg, u8 num_bytes)
if (unlikely(client->inuse != TWL_CLIENT_USED)) { if (unlikely(client->inuse != TWL_CLIENT_USED)) {
pr_err("I2C Client[%d] is not initialized[%d]\n", pr_err("I2C Client[%d] is not initialized[%d]\n",
sid,__LINE__); sid, __LINE__);
return -EPERM; return -EPERM;
} }
down(&(client->xfer_lock)); down(&(client->xfer_lock));
...@@ -383,7 +383,7 @@ int twl4030_i2c_read_u8(u8 mod_no, u8 * value, u8 reg) ...@@ -383,7 +383,7 @@ int twl4030_i2c_read_u8(u8 mod_no, u8 * value, u8 reg)
return ret; return ret;
} }
/**** Helper Functions */ /* Helper Functions */
/* /*
* do_twl4030_module_irq() is the desc->handle method for each of the twl4030 * do_twl4030_module_irq() is the desc->handle method for each of the twl4030
...@@ -638,7 +638,7 @@ struct task_struct *start_twl4030_irq_thread(int irq) ...@@ -638,7 +638,7 @@ struct task_struct *start_twl4030_irq_thread(int irq)
"twl4030 irq %d", irq); "twl4030 irq %d", irq);
if (!thread) if (!thread)
pr_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;
} }
...@@ -694,9 +694,9 @@ static int power_companion_init(void) ...@@ -694,9 +694,9 @@ static int power_companion_init(void)
static void twl_init_irq(void) static void twl_init_irq(void)
{ {
int i = 0; int i = 0;
int res = 0; int res = 0;
int line = 0; char *msg = "Unable to register interrupt subsystem";
/* /*
* We end up with interrupts from other modules before * We end up with interrupts from other modules before
...@@ -705,44 +705,44 @@ static void twl_init_irq(void) ...@@ -705,44 +705,44 @@ static void twl_init_irq(void)
/* PWR_ISR1 */ /* PWR_ISR1 */
res = twl4030_i2c_write_u8(TWL4030_MODULE_INT, 0xFF, 0x00); res = twl4030_i2c_write_u8(TWL4030_MODULE_INT, 0xFF, 0x00);
if (res < 0) { if (res < 0) {
line = __LINE__; pr_err("%s[%d][%d]\n", msg, res, __LINE__);
goto irq_exit_path; return;
} }
/* PWR_ISR2 */ /* PWR_ISR2 */
res = twl4030_i2c_write_u8(TWL4030_MODULE_INT, 0xFF, 0x02); res = twl4030_i2c_write_u8(TWL4030_MODULE_INT, 0xFF, 0x02);
if (res < 0) { if (res < 0) {
line = __LINE__; pr_err("%s[%d][%d]\n", msg, res, __LINE__);
goto irq_exit_path; return;
} }
/* PWR_IMR1 */ /* PWR_IMR1 */
res = twl4030_i2c_write_u8(TWL4030_MODULE_INT, 0xFF, 0x1); res = twl4030_i2c_write_u8(TWL4030_MODULE_INT, 0xFF, 0x1);
if (res < 0) { if (res < 0) {
line = __LINE__; pr_err("%s[%d][%d]\n", msg, res, __LINE__);
goto irq_exit_path; return;
} }
/* PWR_IMR2 */ /* PWR_IMR2 */
res = twl4030_i2c_write_u8(TWL4030_MODULE_INT, 0xFF, 0x3); res = twl4030_i2c_write_u8(TWL4030_MODULE_INT, 0xFF, 0x3);
if (res < 0) { if (res < 0) {
line = __LINE__; pr_err("%s[%d][%d]\n", msg, res, __LINE__);
goto irq_exit_path; return;
} }
/* Clear off any other pending interrupts on power */ /* Clear off any other pending interrupts on power */
/* PWR_ISR1 */ /* PWR_ISR1 */
res = twl4030_i2c_write_u8(TWL4030_MODULE_INT, 0xFF, 0x00); res = twl4030_i2c_write_u8(TWL4030_MODULE_INT, 0xFF, 0x00);
if (res < 0) { if (res < 0) {
line = __LINE__; pr_err("%s[%d][%d]\n", msg, res, __LINE__);
goto irq_exit_path; return;
} }
/* PWR_ISR2 */ /* PWR_ISR2 */
res = twl4030_i2c_write_u8(TWL4030_MODULE_INT, 0xFF, 0x02); res = twl4030_i2c_write_u8(TWL4030_MODULE_INT, 0xFF, 0x02);
if (res < 0) { if (res < 0) {
line = __LINE__; pr_err("%s[%d][%d]\n", msg, res, __LINE__);
goto irq_exit_path; return;
} }
/* POWER HACK (END) */ /* POWER HACK (END) */
/* Slave address 0x4A */ /* Slave address 0x4A */
...@@ -750,52 +750,52 @@ static void twl_init_irq(void) ...@@ -750,52 +750,52 @@ static void twl_init_irq(void)
/* BCIIMR1_1 */ /* BCIIMR1_1 */
res = twl4030_i2c_write_u8(TWL4030_MODULE_INTERRUPTS, 0xFF, 0x3); res = twl4030_i2c_write_u8(TWL4030_MODULE_INTERRUPTS, 0xFF, 0x3);
if (res < 0) { if (res < 0) {
line = __LINE__; pr_err("%s[%d][%d]\n", msg, res, __LINE__);
goto irq_exit_path; return;
} }
/* BCIIMR1_2 */ /* BCIIMR1_2 */
res = twl4030_i2c_write_u8(TWL4030_MODULE_INTERRUPTS, 0xFF, 0x4); res = twl4030_i2c_write_u8(TWL4030_MODULE_INTERRUPTS, 0xFF, 0x4);
if (res < 0) { if (res < 0) {
line = __LINE__; pr_err("%s[%d][%d]\n", msg, res, __LINE__);
goto irq_exit_path; return;
} }
/* BCIIMR2_1 */ /* BCIIMR2_1 */
res = twl4030_i2c_write_u8(TWL4030_MODULE_INTERRUPTS, 0xFF, 0x7); res = twl4030_i2c_write_u8(TWL4030_MODULE_INTERRUPTS, 0xFF, 0x7);
if (res < 0) { if (res < 0) {
line = __LINE__; pr_err("%s[%d][%d]\n", msg, res, __LINE__);
goto irq_exit_path; return;
} }
/* BCIIMR2_2 */ /* BCIIMR2_2 */
res = twl4030_i2c_write_u8(TWL4030_MODULE_INTERRUPTS, 0xFF, 0x8); res = twl4030_i2c_write_u8(TWL4030_MODULE_INTERRUPTS, 0xFF, 0x8);
if (res < 0) { if (res < 0) {
line = __LINE__; pr_err("%s[%d][%d]\n", msg, res, __LINE__);
goto irq_exit_path; return;
} }
/* MAD C */ /* MAD C */
/* MADC_IMR1 */ /* MADC_IMR1 */
res = twl4030_i2c_write_u8(TWL4030_MODULE_MADC, 0xFF, 0x62); res = twl4030_i2c_write_u8(TWL4030_MODULE_MADC, 0xFF, 0x62);
if (res < 0) { if (res < 0) {
line = __LINE__; pr_err("%s[%d][%d]\n", msg, res, __LINE__);
goto irq_exit_path; return;
} }
/* MADC_IMR2 */ /* MADC_IMR2 */
res = twl4030_i2c_write_u8(TWL4030_MODULE_MADC, 0xFF, 0x64); res = twl4030_i2c_write_u8(TWL4030_MODULE_MADC, 0xFF, 0x64);
if (res < 0) { if (res < 0) {
line = __LINE__; pr_err("%s[%d][%d]\n", msg, res, __LINE__);
goto irq_exit_path; return;
} }
/* key Pad */ /* key Pad */
/* KEYPAD - IMR1 */ /* KEYPAD - IMR1 */
res = twl4030_i2c_write_u8(TWL4030_MODULE_KEYPAD, 0xFF, (0x12)); res = twl4030_i2c_write_u8(TWL4030_MODULE_KEYPAD, 0xFF, (0x12));
if (res < 0) { if (res < 0) {
line = __LINE__; pr_err("%s[%d][%d]\n", msg, res, __LINE__);
goto irq_exit_path; return;
} }
{ {
u8 clear; u8 clear;
...@@ -807,51 +807,51 @@ static void twl_init_irq(void) ...@@ -807,51 +807,51 @@ static void twl_init_irq(void)
/* KEYPAD - IMR2 */ /* KEYPAD - IMR2 */
res = twl4030_i2c_write_u8(TWL4030_MODULE_KEYPAD, 0xFF, (0x14)); res = twl4030_i2c_write_u8(TWL4030_MODULE_KEYPAD, 0xFF, (0x14));
if (res < 0) { if (res < 0) {
line = __LINE__; pr_err("%s[%d][%d]\n", msg, res, __LINE__);
goto irq_exit_path; return;
} }
/* Slave address 0x49 */ /* Slave address 0x49 */
/* GPIO_IMR1A */ /* GPIO_IMR1A */
res = twl4030_i2c_write_u8(TWL4030_MODULE_GPIO, 0xFF, (0x1C)); res = twl4030_i2c_write_u8(TWL4030_MODULE_GPIO, 0xFF, (0x1C));
if (res < 0) { if (res < 0) {
line = __LINE__; pr_err("%s[%d][%d]\n", msg, res, __LINE__);
goto irq_exit_path; return;
} }
/* GPIO_IMR2A */ /* GPIO_IMR2A */
res = twl4030_i2c_write_u8(TWL4030_MODULE_GPIO, 0xFF, (0x1D)); res = twl4030_i2c_write_u8(TWL4030_MODULE_GPIO, 0xFF, (0x1D));
if (res < 0) { if (res < 0) {
line = __LINE__; pr_err("%s[%d][%d]\n", msg, res, __LINE__);
goto irq_exit_path; return;
} }
/* GPIO_IMR3A */ /* GPIO_IMR3A */
res = twl4030_i2c_write_u8(TWL4030_MODULE_GPIO, 0xFF, (0x1E)); res = twl4030_i2c_write_u8(TWL4030_MODULE_GPIO, 0xFF, (0x1E));
if (res < 0) { if (res < 0) {
line = __LINE__; pr_err("%s[%d][%d]\n", msg, res, __LINE__);
goto irq_exit_path; return;
} }
/* GPIO_IMR1B */ /* GPIO_IMR1B */
res = twl4030_i2c_write_u8(TWL4030_MODULE_GPIO, 0xFF, (0x22)); res = twl4030_i2c_write_u8(TWL4030_MODULE_GPIO, 0xFF, (0x22));
if (res < 0) { if (res < 0) {
line = __LINE__; pr_err("%s[%d][%d]\n", msg, res, __LINE__);
goto irq_exit_path; return;
} }
/* GPIO_IMR2B */ /* GPIO_IMR2B */
res = twl4030_i2c_write_u8(TWL4030_MODULE_GPIO, 0xFF, (0x23)); res = twl4030_i2c_write_u8(TWL4030_MODULE_GPIO, 0xFF, (0x23));
if (res < 0) { if (res < 0) {
line = __LINE__; pr_err("%s[%d][%d]\n", msg, res, __LINE__);
goto irq_exit_path; return;
} }
/* GPIO_IMR3B */ /* GPIO_IMR3B */
res = twl4030_i2c_write_u8(TWL4030_MODULE_GPIO, 0xFF, (0x24)); res = twl4030_i2c_write_u8(TWL4030_MODULE_GPIO, 0xFF, (0x24));
if (res < 0) { if (res < 0) {
line = __LINE__; pr_err("%s[%d][%d]\n", msg, res, __LINE__);
goto irq_exit_path; return;
} }
/* install an irq handler for each of the PIH modules */ /* install an irq handler for each of the PIH modules */
...@@ -868,14 +868,8 @@ static void twl_init_irq(void) ...@@ -868,14 +868,8 @@ static void twl_init_irq(void)
res = power_companion_init(); res = power_companion_init();
if (res < 0) { if (res < 0) {
line = __LINE__; pr_err("%s[%d][%d]\n", msg, res, __LINE__);
goto irq_exit_path;
} }
irq_exit_path:
if (res)
pr_err("Unable to register interrupt subsystem[%d][%d]\n",
res,line);
} }
static int __init twl4030_init(void) static int __init twl4030_init(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