All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Staging: android: timed_gpio.c: remove else statement after return
@ 2014-07-28 23:11 Murilo Opsfelder Araujo
  2014-07-29  5:02 ` Joe Perches
  0 siblings, 1 reply; 5+ messages in thread
From: Murilo Opsfelder Araujo @ 2014-07-28 23:11 UTC (permalink / raw)
  To: devel, linux-kernel; +Cc: gregkh, Murilo Opsfelder Araujo

This patch makes checkpatch.pl script happy by fixing the following
warning:

WARNING: else is not generally useful after a break or return

Signed-off-by: Murilo Opsfelder Araujo <mopsfelder@gmail.com>
---
 drivers/staging/android/timed_gpio.c |    5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/android/timed_gpio.c b/drivers/staging/android/timed_gpio.c
index 180c209..05cb578 100644
--- a/drivers/staging/android/timed_gpio.c
+++ b/drivers/staging/android/timed_gpio.c
@@ -53,8 +53,9 @@ static int gpio_get_time(struct timed_output_dev *dev)
 		struct timeval t = ktime_to_timeval(r);
 
 		return t.tv_sec * 1000 + t.tv_usec / 1000;
-	} else
-		return 0;
+	}
+
+	return 0;
 }
 
 static void gpio_enable(struct timed_output_dev *dev, int value)
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] Staging: android: timed_gpio.c: remove else statement after return
  2014-07-28 23:11 [PATCH] Staging: android: timed_gpio.c: remove else statement after return Murilo Opsfelder Araujo
@ 2014-07-29  5:02 ` Joe Perches
  2014-07-30 23:47   ` [PATCH] Staging: android: timed_gpio.c: improved logic of gpio_get_time() Murilo Opsfelder Araujo
  0 siblings, 1 reply; 5+ messages in thread
From: Joe Perches @ 2014-07-29  5:02 UTC (permalink / raw)
  To: Murilo Opsfelder Araujo; +Cc: devel, linux-kernel, gregkh

On Mon, 2014-07-28 at 20:11 -0300, Murilo Opsfelder Araujo wrote:
> This patch makes checkpatch.pl script happy by fixing the following
> warning:
> 
> WARNING: else is not generally useful after a break or return
> 
> Signed-off-by: Murilo Opsfelder Araujo <mopsfelder@gmail.com>
> ---
>  drivers/staging/android/timed_gpio.c |    5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/staging/android/timed_gpio.c b/drivers/staging/android/timed_gpio.c
> index 180c209..05cb578 100644
> --- a/drivers/staging/android/timed_gpio.c
> +++ b/drivers/staging/android/timed_gpio.c
> @@ -53,8 +53,9 @@ static int gpio_get_time(struct timed_output_dev *dev)
>  		struct timeval t = ktime_to_timeval(r);
>  
>  		return t.tv_sec * 1000 + t.tv_usec / 1000;
> -	} else
> -		return 0;
> +	}
> +
> +	return 0;
>  }

It may be better to reverse the logic here.
Something like:

 drivers/staging/android/timed_gpio.c | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/drivers/staging/android/timed_gpio.c b/drivers/staging/android/timed_gpio.c
index 180c209..8fa4758 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)
 
 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)




^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH] Staging: android: timed_gpio.c: improved logic of gpio_get_time()
  2014-07-29  5:02 ` Joe Perches
@ 2014-07-30 23:47   ` Murilo Opsfelder Araujo
  2014-07-31  8:25     ` Dan Carpenter
  0 siblings, 1 reply; 5+ messages in thread
From: Murilo Opsfelder Araujo @ 2014-07-30 23:47 UTC (permalink / raw)
  To: devel, linux-kernel; +Cc: gregkh, joe, Murilo Opsfelder Araujo

Thanks for reviewing my first patch, Joe.  How about this new one,
guys?

-- >8 --
Consequently, made checkpatch.pl happy.

Signed-off-by: Murilo Opsfelder Araujo <mopsfelder@gmail.com>
---
 drivers/staging/android/timed_gpio.c |   15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/drivers/staging/android/timed_gpio.c b/drivers/staging/android/timed_gpio.c
index 180c209..8fa4758 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)

 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)
--
1.7.10.4

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] Staging: android: timed_gpio.c: improved logic of gpio_get_time()
  2014-07-30 23:47   ` [PATCH] Staging: android: timed_gpio.c: improved logic of gpio_get_time() Murilo Opsfelder Araujo
@ 2014-07-31  8:25     ` Dan Carpenter
  2014-07-31 11:34       ` [PATCH v2] " Murilo Opsfelder Araujo
  0 siblings, 1 reply; 5+ messages in thread
From: Dan Carpenter @ 2014-07-31  8:25 UTC (permalink / raw)
  To: Murilo Opsfelder Araujo; +Cc: devel, linux-kernel, joe, gregkh

On Wed, Jul 30, 2014 at 08:47:19PM -0300, Murilo Opsfelder Araujo wrote:
> Thanks for reviewing my first patch, Joe.  How about this new one,
> guys?
> 
> -- >8 --
> Consequently, made checkpatch.pl happy.
> 
> Signed-off-by: Murilo Opsfelder Araujo <mopsfelder@gmail.com>

This changelog is all mangled.  Try applying it with `git am`.  It
doesn't make sense to begin with.  What consequently?

regards,
dan carpenter


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH v2] Staging: android: timed_gpio.c: improved logic of gpio_get_time()
  2014-07-31  8:25     ` Dan Carpenter
@ 2014-07-31 11:34       ` Murilo Opsfelder Araujo
  0 siblings, 0 replies; 5+ messages in thread
From: Murilo Opsfelder Araujo @ 2014-07-31 11:34 UTC (permalink / raw)
  To: devel, linux-kernel; +Cc: gregkh, joe, dan.carpenter, Murilo Opsfelder Araujo

This patch improves the logic of gpio_get_time() and, thereafter,
makes checkpatch.pl happy.

Signed-off-by: Murilo Opsfelder Araujo <mopsfelder@gmail.com>
---

Thanks for reviweing my patch, Dan.  I think I got the proper way
without using option --scissors in git-am.

What about this new commit message?

 drivers/staging/android/timed_gpio.c |   15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/drivers/staging/android/timed_gpio.c b/drivers/staging/android/timed_gpio.c
index 180c209..8fa4758 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)

 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)
--
1.7.10.4

^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2014-07-31 11:35 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-07-28 23:11 [PATCH] Staging: android: timed_gpio.c: remove else statement after return Murilo Opsfelder Araujo
2014-07-29  5:02 ` Joe Perches
2014-07-30 23:47   ` [PATCH] Staging: android: timed_gpio.c: improved logic of gpio_get_time() Murilo Opsfelder Araujo
2014-07-31  8:25     ` Dan Carpenter
2014-07-31 11:34       ` [PATCH v2] " Murilo Opsfelder Araujo

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.