From: Oleksij Rempel <linux@xxxxxxxxxxxxxxxx> Make sure zforce_start() is not called if FW init was not completed. Signed-off-by: Oleksij Rempel <fixed-term.Oleksij.Rempel@xxxxxxxxxxxx> Signed-off-by: Knut Wohlrab <Knut.Wohlrab@xxxxxxxxxxxx> --- drivers/input/touchscreen/zforce_ts.c | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/drivers/input/touchscreen/zforce_ts.c b/drivers/input/touchscreen/zforce_ts.c index 9839d86..c912a0b 100644 --- a/drivers/input/touchscreen/zforce_ts.c +++ b/drivers/input/touchscreen/zforce_ts.c @@ -102,7 +102,6 @@ struct zforce_point { enum zforce_state { ZF_STATE_UNINITIALZED = 0, ZF_STATE_PROBE_COMPLETE, - ZF_STATE_DEV_OPENED, }; /* @@ -150,6 +149,7 @@ struct zforce_ts { int notification; enum zforce_state state; + atomic_t opened; }; static int zforce_command(struct zforce_ts *ts, u8 cmd) @@ -647,12 +647,13 @@ static void zforce_boot(struct zforce_ts *ts) ts->state = ZF_STATE_PROBE_COMPLETE; break; - case ZF_STATE_DEV_OPENED: - ret = zforce_start(ts); - if (ret) - dev_err(dev, "Failed to restart, %d\n", ret); - break; } + + if (!atomic_read(&ts->opened)) + return; + + if (zforce_start(ts)) + dev_err(dev, "Failed to restart, %d\n", ret); } static void zforce_notification_queue(struct work_struct *work) @@ -690,11 +691,13 @@ static int zforce_input_open(struct input_dev *dev) struct zforce_ts *ts = input_get_drvdata(dev); int ret; - ret = zforce_start(ts); - if (ret) - return ret; + if (ts->state == ZF_STATE_PROBE_COMPLETE) { + ret = zforce_start(ts); + if (ret) + return ret; + } - ts->state = ZF_STATE_DEV_OPENED; + atomic_inc(&ts->opened); return 0; } @@ -709,7 +712,7 @@ static void zforce_input_close(struct input_dev *dev) if (ret) dev_warn(&client->dev, "stopping zforce failed\n"); - ts->state = ZF_STATE_PROBE_COMPLETE; + atomic_dec(&ts->opened); return; } -- 1.9.1 -- To unsubscribe from this list: send the line "unsubscribe linux-input" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html