Staging: android: timed_gpio.c: improved logic of gpio_get_time()
authorMurilo Opsfelder Araujo <mopsfelder@gmail.com>
Thu, 31 Jul 2014 11:34:11 +0000 (08:34 -0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 1 Aug 2014 21:40:30 +0000 (14:40 -0700)
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>
drivers/staging/android/timed_gpio.c

index 180c209a009e6f62166540a71777dbfa22e4658f..8fa4758517c00fbb1e45703fb3d04098175b5982 100644 (file)
@@ -45,16 +45,17 @@ static enum hrtimer_restart gpio_timer_func(struct hrtimer *timer)
 
 static int gpio_get_time(struct timed_output_dev *dev)
 {
-       struct timed_gpio_data  *data =
-               container_of(dev, struct timed_gpio_data, dev);
+       struct timed_gpio_data *data;
+       struct timeval t;
 
-       if (hrtimer_active(&data->timer)) {
-               ktime_t r = hrtimer_get_remaining(&data->timer);
-               struct timeval t = ktime_to_timeval(r);
+       data = container_of(dev, struct timed_gpio_data, dev);
 
-               return t.tv_sec * 1000 + t.tv_usec / 1000;
-       } else
+       if (!hrtimer_active(&data->timer))
                return 0;
+
+       t = ktime_to_timeval(hrtimer_get_remaining(&data->timer));
+
+       return t.tv_sec * 1000 + t.tv_usec / 1000;
 }
 
 static void gpio_enable(struct timed_output_dev *dev, int value)