diff options
author | Subramaniam Chanderashekarapuram | 2014-07-28 16:17:38 -0500 |
---|---|---|
committer | Subramaniam Chanderashekarapuram | 2014-07-31 11:06:52 -0500 |
commit | dafd94912c4dad76c35f2d188f23aae92d4a5335 (patch) | |
tree | 5d440c208d77a2c80d051b947e48dcf02efc0ffd | |
parent | da6074c9657dcdac05652b370c4a41327bdc428b (diff) | |
download | kernel-audio-dafd94912c4dad76c35f2d188f23aae92d4a5335.tar.gz kernel-audio-dafd94912c4dad76c35f2d188f23aae92d4a5335.tar.xz kernel-audio-dafd94912c4dad76c35f2d188f23aae92d4a5335.zip |
TI-EC: fix trigger key read logic
The trigger logic for earlycam currently check for the case if the
gpio is set or not. However, there are times when the gpio read can fail.
In this use case, the gpio is behind an i2c device and depending on the
the success of the i2c transcation, the read could pass or fail. In case of
failures it returns a value thats not handled properly.
Fixing the logic to support failure cases too.
Change-Id: If55030cc0884b3ac8afa943e3dd54e131cc4fef3
Signed-off-by: Subramaniam Chanderashekarapuram <subramaniam.ca@ti.com>
-rw-r--r-- | drivers/misc/ti-ec/earlycam.c | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/drivers/misc/ti-ec/earlycam.c b/drivers/misc/ti-ec/earlycam.c index a74ebe0c086e..3cf82ef55c9e 100644 --- a/drivers/misc/ti-ec/earlycam.c +++ b/drivers/misc/ti-ec/earlycam.c | |||
@@ -368,12 +368,11 @@ int main_fn(void *arg) | |||
368 | cam_init = 2; | 368 | cam_init = 2; |
369 | 369 | ||
370 | while (1) { | 370 | while (1) { |
371 | while ((val = | 371 | |
372 | gpio_get_value_cansleep( | 372 | do { |
373 | earlycam_dev->reverse_gpio)) == | ||
374 | 1) { | ||
375 | /* Spin inside this loop, sleeping for 100 mS | 373 | /* Spin inside this loop, sleeping for 100 mS |
376 | * everytime until the user presses the gpio. | 374 | * everytime until the user presses the gpio OR |
375 | * in case there was an error reading the value. | ||
377 | * This should be replaced by interrupt based | 376 | * This should be replaced by interrupt based |
378 | * mechanism to avoid waking up the cpu | 377 | * mechanism to avoid waking up the cpu |
379 | * frequently | 378 | * frequently |
@@ -396,7 +395,9 @@ int main_fn(void *arg) | |||
396 | once = 1; | 395 | once = 1; |
397 | } | 396 | } |
398 | msleep(100); | 397 | msleep(100); |
399 | } | 398 | val = gpio_get_value_cansleep |
399 | (earlycam_dev->reverse_gpio); | ||
400 | } while (val == 1 || val < 0); | ||
400 | 401 | ||
401 | /* So we got a gpio press, start by initializing camera first */ | 402 | /* So we got a gpio press, start by initializing camera first */ |
402 | if (cam_init == 2) { | 403 | if (cam_init == 2) { |