|
@@ -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;
|
|
|
}
|
|
|
|
|
@@ -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;
|
|
|
}
|
|
|
|