aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMurilo Opsfelder Araujo <mopsfelder@gmail.com>2014-07-31 07:34:11 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2014-08-01 17:40:30 -0400
commit80039faa8809461f8e23892e14277f9f0af45505 (patch)
tree5353dc64e9682c2add0d37ed0951782fa058dc8f
parentd746cb55b036da18f8cdcf76c9604d8e74315827 (diff)
Staging: android: timed_gpio.c: improved logic of gpio_get_time()
This patch improves the logic of gpio_get_time() and, thereafter, makes checkpatch.pl happy. Signed-off-by: Murilo Opsfelder Araujo <mopsfelder@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/staging/android/timed_gpio.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/drivers/staging/android/timed_gpio.c b/drivers/staging/android/timed_gpio.c
index 180c209a009e..8fa4758517c0 100644
--- a/drivers/staging/android/timed_gpio.c
+++ b/drivers/staging/android/timed_gpio.c
@@ -45,16 +45,17 @@ static enum hrtimer_restart gpio_timer_func(struct hrtimer *timer)
45 45
46static int gpio_get_time(struct timed_output_dev *dev) 46static int gpio_get_time(struct timed_output_dev *dev)
47{ 47{
48 struct timed_gpio_data *data = 48 struct timed_gpio_data *data;
49 container_of(dev, struct timed_gpio_data, dev); 49 struct timeval t;
50 50
51 if (hrtimer_active(&data->timer)) { 51 data = container_of(dev, struct timed_gpio_data, dev);
52 ktime_t r = hrtimer_get_remaining(&data->timer);
53 struct timeval t = ktime_to_timeval(r);
54 52
55 return t.tv_sec * 1000 + t.tv_usec / 1000; 53 if (!hrtimer_active(&data->timer))
56 } else
57 return 0; 54 return 0;
55
56 t = ktime_to_timeval(hrtimer_get_remaining(&data->timer));
57
58 return t.tv_sec * 1000 + t.tv_usec / 1000;
58} 59}
59 60
60static void gpio_enable(struct timed_output_dev *dev, int value) 61static void gpio_enable(struct timed_output_dev *dev, int value)