mirror of
https://github.com/torvalds/linux.git
synced 2024-11-02 02:01:29 +00:00
Input: mms114 - Fix regulator enable and disable paths
When it uses regulators the mms114 driver checks to see if it managed to acquire regulators and ignores errors. This is not the intended usage and not great style in general. Since the driver already refuses to probe if it fails to allocate the regulators simply make the enable and disable calls unconditional and add appropriate error handling, including adding cleanup of the regulators if setup_reg() fails. Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com> Acked-by: Joonyoung Shim <jy0922.shim@samsung.com> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
This commit is contained in:
parent
f94352f8db
commit
4b7d293c64
@ -314,15 +314,27 @@ static int mms114_start(struct mms114_data *data)
|
|||||||
struct i2c_client *client = data->client;
|
struct i2c_client *client = data->client;
|
||||||
int error;
|
int error;
|
||||||
|
|
||||||
if (data->core_reg)
|
error = regulator_enable(data->core_reg);
|
||||||
regulator_enable(data->core_reg);
|
if (error) {
|
||||||
if (data->io_reg)
|
dev_err(&client->dev, "Failed to enable avdd: %d\n", error);
|
||||||
regulator_enable(data->io_reg);
|
return error;
|
||||||
|
}
|
||||||
|
|
||||||
|
error = regulator_enable(data->io_reg);
|
||||||
|
if (error) {
|
||||||
|
dev_err(&client->dev, "Failed to enable vdd: %d\n", error);
|
||||||
|
regulator_disable(data->core_reg);
|
||||||
|
return error;
|
||||||
|
}
|
||||||
|
|
||||||
mdelay(MMS114_POWERON_DELAY);
|
mdelay(MMS114_POWERON_DELAY);
|
||||||
|
|
||||||
error = mms114_setup_regs(data);
|
error = mms114_setup_regs(data);
|
||||||
if (error < 0)
|
if (error < 0) {
|
||||||
|
regulator_disable(data->io_reg);
|
||||||
|
regulator_disable(data->core_reg);
|
||||||
return error;
|
return error;
|
||||||
|
}
|
||||||
|
|
||||||
if (data->pdata->cfg_pin)
|
if (data->pdata->cfg_pin)
|
||||||
data->pdata->cfg_pin(true);
|
data->pdata->cfg_pin(true);
|
||||||
@ -335,16 +347,20 @@ static int mms114_start(struct mms114_data *data)
|
|||||||
static void mms114_stop(struct mms114_data *data)
|
static void mms114_stop(struct mms114_data *data)
|
||||||
{
|
{
|
||||||
struct i2c_client *client = data->client;
|
struct i2c_client *client = data->client;
|
||||||
|
int error;
|
||||||
|
|
||||||
disable_irq(client->irq);
|
disable_irq(client->irq);
|
||||||
|
|
||||||
if (data->pdata->cfg_pin)
|
if (data->pdata->cfg_pin)
|
||||||
data->pdata->cfg_pin(false);
|
data->pdata->cfg_pin(false);
|
||||||
|
|
||||||
if (data->io_reg)
|
error = regulator_disable(data->io_reg);
|
||||||
regulator_disable(data->io_reg);
|
if (error)
|
||||||
if (data->core_reg)
|
dev_warn(&client->dev, "Failed to disable vdd: %d\n", error);
|
||||||
regulator_disable(data->core_reg);
|
|
||||||
|
error = regulator_disable(data->core_reg);
|
||||||
|
if (error)
|
||||||
|
dev_warn(&client->dev, "Failed to disable avdd: %d\n", error);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int mms114_input_open(struct input_dev *dev)
|
static int mms114_input_open(struct input_dev *dev)
|
||||||
|
Loading…
Reference in New Issue
Block a user