input: atmel_mxt_ts: Don't set mode on unsettable regulators
Currently during boot, and every suspend/resume, we call
regulator_set_optimum_mode on every touchsdcreen regulator. However,
some regulators don't support this function, and this will cause
set_optimum_mode to print an error when this occures. Correct this by
checking if it is valid to call set_optimum_mode on a given regulator
before doing so.
Change-Id: I8dbd9d8281cb144b31c59d86fcf4e8a8133cd6a7
Signed-off-by: Amy Maloche <amaloche@codeaurora.org>
diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c b/drivers/input/touchscreen/atmel_mxt_ts.c
index 4e81567..d2a8879 100644
--- a/drivers/input/touchscreen/atmel_mxt_ts.c
+++ b/drivers/input/touchscreen/atmel_mxt_ts.c
@@ -1364,6 +1364,12 @@
}
+static int reg_set_optimum_mode_check(struct regulator *reg, int load_uA)
+{
+ return (regulator_count_voltages(reg) > 0) ?
+ regulator_set_optimum_mode(reg, load_uA) : 0;
+}
+
static int mxt_power_on(struct mxt_data *data, bool on)
{
int rc;
@@ -1371,7 +1377,7 @@
if (on == false)
goto power_off;
- rc = regulator_set_optimum_mode(data->vcc_ana, MXT_ACTIVE_LOAD_UA);
+ rc = reg_set_optimum_mode_check(data->vcc_ana, MXT_ACTIVE_LOAD_UA);
if (rc < 0) {
dev_err(&data->client->dev,
"Regulator vcc_ana set_opt failed rc=%d\n", rc);
@@ -1386,8 +1392,8 @@
}
if (data->pdata->digital_pwr_regulator) {
- rc = regulator_set_optimum_mode(data->vcc_dig,
- MXT_ACTIVE_LOAD_DIG_UA);
+ rc = reg_set_optimum_mode_check(data->vcc_dig,
+ MXT_ACTIVE_LOAD_DIG_UA);
if (rc < 0) {
dev_err(&data->client->dev,
"Regulator vcc_dig set_opt failed rc=%d\n",
@@ -1404,7 +1410,7 @@
}
if (data->pdata->i2c_pull_up) {
- rc = regulator_set_optimum_mode(data->vcc_i2c, MXT_I2C_LOAD_UA);
+ rc = reg_set_optimum_mode_check(data->vcc_i2c, MXT_I2C_LOAD_UA);
if (rc < 0) {
dev_err(&data->client->dev,
"Regulator vcc_i2c set_opt failed rc=%d\n", rc);
@@ -1425,28 +1431,28 @@
error_reg_en_vcc_i2c:
if (data->pdata->i2c_pull_up)
- regulator_set_optimum_mode(data->vcc_i2c, 0);
+ reg_set_optimum_mode_check(data->vcc_i2c, 0);
error_reg_opt_i2c:
if (data->pdata->digital_pwr_regulator)
regulator_disable(data->vcc_dig);
error_reg_en_vcc_dig:
if (data->pdata->digital_pwr_regulator)
- regulator_set_optimum_mode(data->vcc_dig, 0);
+ reg_set_optimum_mode_check(data->vcc_dig, 0);
error_reg_opt_vcc_dig:
regulator_disable(data->vcc_ana);
error_reg_en_vcc_ana:
- regulator_set_optimum_mode(data->vcc_ana, 0);
+ reg_set_optimum_mode_check(data->vcc_ana, 0);
return rc;
power_off:
- regulator_set_optimum_mode(data->vcc_ana, 0);
+ reg_set_optimum_mode_check(data->vcc_ana, 0);
regulator_disable(data->vcc_ana);
if (data->pdata->digital_pwr_regulator) {
- regulator_set_optimum_mode(data->vcc_dig, 0);
+ reg_set_optimum_mode_check(data->vcc_dig, 0);
regulator_disable(data->vcc_dig);
}
if (data->pdata->i2c_pull_up) {
- regulator_set_optimum_mode(data->vcc_i2c, 0);
+ reg_set_optimum_mode_check(data->vcc_i2c, 0);
regulator_disable(data->vcc_i2c);
}
msleep(50);
@@ -1562,7 +1568,7 @@
if (on == false)
goto regulator_hpm;
- rc = regulator_set_optimum_mode(data->vcc_ana, MXT_LPM_LOAD_UA);
+ rc = reg_set_optimum_mode_check(data->vcc_ana, MXT_LPM_LOAD_UA);
if (rc < 0) {
dev_err(&data->client->dev,
"Regulator vcc_ana set_opt failed rc=%d\n", rc);
@@ -1570,7 +1576,7 @@
}
if (data->pdata->digital_pwr_regulator) {
- rc = regulator_set_optimum_mode(data->vcc_dig,
+ rc = reg_set_optimum_mode_check(data->vcc_dig,
MXT_LPM_LOAD_DIG_UA);
if (rc < 0) {
dev_err(&data->client->dev,
@@ -1580,7 +1586,7 @@
}
if (data->pdata->i2c_pull_up) {
- rc = regulator_set_optimum_mode(data->vcc_i2c,
+ rc = reg_set_optimum_mode_check(data->vcc_i2c,
MXT_I2C_LPM_LOAD_UA);
if (rc < 0) {
dev_err(&data->client->dev,
@@ -1593,7 +1599,7 @@
regulator_hpm:
- rc = regulator_set_optimum_mode(data->vcc_ana, MXT_ACTIVE_LOAD_UA);
+ rc = reg_set_optimum_mode_check(data->vcc_ana, MXT_ACTIVE_LOAD_UA);
if (rc < 0) {
dev_err(&data->client->dev,
"Regulator vcc_ana set_opt failed rc=%d\n", rc);
@@ -1601,7 +1607,7 @@
}
if (data->pdata->digital_pwr_regulator) {
- rc = regulator_set_optimum_mode(data->vcc_dig,
+ rc = reg_set_optimum_mode_check(data->vcc_dig,
MXT_ACTIVE_LOAD_DIG_UA);
if (rc < 0) {
dev_err(&data->client->dev,
@@ -1611,7 +1617,7 @@
}
if (data->pdata->i2c_pull_up) {
- rc = regulator_set_optimum_mode(data->vcc_i2c, MXT_I2C_LOAD_UA);
+ rc = reg_set_optimum_mode_check(data->vcc_i2c, MXT_I2C_LOAD_UA);
if (rc < 0) {
dev_err(&data->client->dev,
"Regulator vcc_i2c set_opt failed rc=%d\n", rc);
@@ -1622,21 +1628,21 @@
return 0;
fail_regulator_lpm:
- regulator_set_optimum_mode(data->vcc_ana, MXT_ACTIVE_LOAD_UA);
+ reg_set_optimum_mode_check(data->vcc_ana, MXT_ACTIVE_LOAD_UA);
if (data->pdata->digital_pwr_regulator)
- regulator_set_optimum_mode(data->vcc_dig,
- MXT_ACTIVE_LOAD_DIG_UA);
+ reg_set_optimum_mode_check(data->vcc_dig,
+ MXT_ACTIVE_LOAD_DIG_UA);
if (data->pdata->i2c_pull_up)
- regulator_set_optimum_mode(data->vcc_i2c, MXT_I2C_LOAD_UA);
+ reg_set_optimum_mode_check(data->vcc_i2c, MXT_I2C_LOAD_UA);
return rc;
fail_regulator_hpm:
- regulator_set_optimum_mode(data->vcc_ana, MXT_LPM_LOAD_UA);
+ reg_set_optimum_mode_check(data->vcc_ana, MXT_LPM_LOAD_UA);
if (data->pdata->digital_pwr_regulator)
- regulator_set_optimum_mode(data->vcc_dig, MXT_LPM_LOAD_DIG_UA);
+ reg_set_optimum_mode_check(data->vcc_dig, MXT_LPM_LOAD_DIG_UA);
if (data->pdata->i2c_pull_up)
- regulator_set_optimum_mode(data->vcc_i2c, MXT_I2C_LPM_LOAD_UA);
+ reg_set_optimum_mode_check(data->vcc_i2c, MXT_I2C_LPM_LOAD_UA);
return rc;
}