Skip to content

Commit

Permalink
mfd: twl-core: Fix kernel panic on boot
Browse files Browse the repository at this point in the history
Commit 8a6aaa3 (mfd: twl-core: Collect global variables behind one
private structure (global)) removed the variable "inuse" that is used
to determine if the device has been initialised and now use the
twl_priv structure instead. This is causing the kernel to panic on
OMAP3+ devices using the twl driver, because we try to access the
twl_priv->ready member before checking if twl_priv is initialised. Fix
this and move this test to the beginning of the twl_i2c_read/write
function because twl_get_last_module() also uses the twl_priv structure.

Signed-off-by: Jon Hunter <jon-hunter@ti.com>
Acked-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
  • Loading branch information
Jon Hunter authored and Samuel Ortiz committed Feb 13, 2013
1 parent 6ed8b04 commit 1765dbc
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions drivers/mfd/twl-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -316,12 +316,12 @@ int twl_i2c_write(u8 mod_no, u8 *value, u8 reg, unsigned num_bytes)
int sid;
struct twl_client *twl;

if (unlikely(mod_no >= twl_get_last_module())) {
pr_err("%s: invalid module number %d\n", DRIVER_NAME, mod_no);
if (unlikely(!twl_priv || !twl_priv->ready)) {
pr_err("%s: not initialized\n", DRIVER_NAME);
return -EPERM;
}
if (unlikely(!twl_priv->ready)) {
pr_err("%s: not initialized\n", DRIVER_NAME);
if (unlikely(mod_no >= twl_get_last_module())) {
pr_err("%s: invalid module number %d\n", DRIVER_NAME, mod_no);
return -EPERM;
}

Expand Down Expand Up @@ -355,12 +355,12 @@ int twl_i2c_read(u8 mod_no, u8 *value, u8 reg, unsigned num_bytes)
int sid;
struct twl_client *twl;

if (unlikely(mod_no >= twl_get_last_module())) {
pr_err("%s: invalid module number %d\n", DRIVER_NAME, mod_no);
if (unlikely(!twl_priv || !twl_priv->ready)) {
pr_err("%s: not initialized\n", DRIVER_NAME);
return -EPERM;
}
if (unlikely(!twl_priv->ready)) {
pr_err("%s: not initialized\n", DRIVER_NAME);
if (unlikely(mod_no >= twl_get_last_module())) {
pr_err("%s: invalid module number %d\n", DRIVER_NAME, mod_no);
return -EPERM;
}

Expand Down

0 comments on commit 1765dbc

Please sign in to comment.