Skip to content

Commit 4b7d293

Browse files
brooniedtor
authored andcommitted
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>
1 parent f94352f commit 4b7d293

1 file changed

Lines changed: 25 additions & 9 deletions

File tree

‎drivers/input/touchscreen/mms114.c‎

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -314,15 +314,27 @@ static int mms114_start(struct mms114_data *data)
314314
struct i2c_client *client = data->client;
315315
int error;
316316

317-
if (data->core_reg)
318-
regulator_enable(data->core_reg);
319-
if (data->io_reg)
320-
regulator_enable(data->io_reg);
317+
error = regulator_enable(data->core_reg);
318+
if (error) {
319+
dev_err(&client->dev, "Failed to enable avdd: %d\n", error);
320+
return error;
321+
}
322+
323+
error = regulator_enable(data->io_reg);
324+
if (error) {
325+
dev_err(&client->dev, "Failed to enable vdd: %d\n", error);
326+
regulator_disable(data->core_reg);
327+
return error;
328+
}
329+
321330
mdelay(MMS114_POWERON_DELAY);
322331

323332
error = mms114_setup_regs(data);
324-
if (error < 0)
333+
if (error < 0) {
334+
regulator_disable(data->io_reg);
335+
regulator_disable(data->core_reg);
325336
return error;
337+
}
326338

327339
if (data->pdata->cfg_pin)
328340
data->pdata->cfg_pin(true);
@@ -335,16 +347,20 @@ static int mms114_start(struct mms114_data *data)
335347
static void mms114_stop(struct mms114_data *data)
336348
{
337349
struct i2c_client *client = data->client;
350+
int error;
338351

339352
disable_irq(client->irq);
340353

341354
if (data->pdata->cfg_pin)
342355
data->pdata->cfg_pin(false);
343356

344-
if (data->io_reg)
345-
regulator_disable(data->io_reg);
346-
if (data->core_reg)
347-
regulator_disable(data->core_reg);
357+
error = regulator_disable(data->io_reg);
358+
if (error)
359+
dev_warn(&client->dev, "Failed to disable vdd: %d\n", error);
360+
361+
error = regulator_disable(data->core_reg);
362+
if (error)
363+
dev_warn(&client->dev, "Failed to disable avdd: %d\n", error);
348364
}
349365

350366
static int mms114_input_open(struct input_dev *dev)

0 commit comments

Comments
 (0)