netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] wan: time_before()
@ 2014-05-25 17:32 Manuel Schölling
  2014-05-25 17:58 ` Joe Perches
  0 siblings, 1 reply; 7+ messages in thread
From: Manuel Schölling @ 2014-05-25 17:32 UTC (permalink / raw)
  To: kevin.curtis; +Cc: netdev, linux-kernel, kernel-janitors, Manuel Schölling

To be future-proof and for better readability the time comparisons are
modified to use time_before() instead of plain, error-prone math.

Signed-off-by: Manuel Schölling <manuel.schoelling@gmx.de>
---
 drivers/net/wan/farsync.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/wan/farsync.c b/drivers/net/wan/farsync.c
index bcfff0d..d007f60 100644
--- a/drivers/net/wan/farsync.c
+++ b/drivers/net/wan/farsync.c
@@ -697,14 +697,14 @@ fst_cpureset(struct fst_card_info *card)
 		 * We are delaying here to allow the 9054 to reset itself
 		 */
 		j = jiffies + 1;
-		while (jiffies < j)
+		while (time_before(jiffies, j))
 			/* Do nothing */ ;
 		outw(0x240f, card->pci_conf + CNTRL_9054 + 2);
 		/*
 		 * We are delaying here to allow the 9054 to reload its eeprom
 		 */
 		j = jiffies + 1;
-		while (jiffies < j)
+		while (time_before(jiffies, j))
 			/* Do nothing */ ;
 		outw(0x040f, card->pci_conf + CNTRL_9054 + 2);
 
-- 
1.7.10.4

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

* Re: [PATCH] wan: time_before()
  2014-05-25 17:32 [PATCH] wan: time_before() Manuel Schölling
@ 2014-05-25 17:58 ` Joe Perches
  2014-05-26  4:40   ` David Miller
  0 siblings, 1 reply; 7+ messages in thread
From: Joe Perches @ 2014-05-25 17:58 UTC (permalink / raw)
  To: Manuel Schölling; +Cc: kevin.curtis, netdev, linux-kernel, kernel-janitors

On Sun, 2014-05-25 at 19:32 +0200, Manuel Schölling wrote:
> To be future-proof and for better readability the time comparisons are
> modified to use time_before() instead of plain, error-prone math.

Sensible change, but it seems these should be
udelay(some_constant) instead of a a rather
variable time wait based on a system/config
defined jiffies.

Kevin?

> diff --git a/drivers/net/wan/farsync.c b/drivers/net/wan/farsync.c
[]
> @@ -697,14 +697,14 @@ fst_cpureset(struct fst_card_info *card)
>  		 * We are delaying here to allow the 9054 to reset itself
>  		 */
>  		j = jiffies + 1;
> -		while (jiffies < j)
> +		while (time_before(jiffies, j))
>  			/* Do nothing */ ;
>  		outw(0x240f, card->pci_conf + CNTRL_9054 + 2);
>  		/*
>  		 * We are delaying here to allow the 9054 to reload its eeprom
>  		 */
>  		j = jiffies + 1;
> -		while (jiffies < j)
> +		while (time_before(jiffies, j))
>  			/* Do nothing */ ;
>  		outw(0x040f, card->pci_conf + CNTRL_9054 + 2);
>  



--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH] wan: time_before()
  2014-05-25 17:58 ` Joe Perches
@ 2014-05-26  4:40   ` David Miller
  2014-05-28  7:09     ` Kevin Curtis
  0 siblings, 1 reply; 7+ messages in thread
From: David Miller @ 2014-05-26  4:40 UTC (permalink / raw)
  To: joe
  Cc: manuel.schoelling, kevin.curtis, netdev, linux-kernel, kernel-janitors

From: Joe Perches <joe@perches.com>
Date: Sun, 25 May 2014 10:58:52 -0700

> On Sun, 2014-05-25 at 19:32 +0200, Manuel Schölling wrote:
>> To be future-proof and for better readability the time comparisons are
>> modified to use time_before() instead of plain, error-prone math.
> 
> Sensible change, but it seems these should be
> udelay(some_constant) instead of a a rather
> variable time wait based on a system/config
> defined jiffies.

Agreed, this code probably wants udelay(10) or something like
that.
--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* RE: [PATCH] wan: time_before()
  2014-05-26  4:40   ` David Miller
@ 2014-05-28  7:09     ` Kevin Curtis
  2014-05-31 15:07       ` [PATCH] wan: Use usleep_range() Manuel Schölling
  0 siblings, 1 reply; 7+ messages in thread
From: Kevin Curtis @ 2014-05-28  7:09 UTC (permalink / raw)
  To: David Miller, joe
  Cc: manuel.schoelling, netdev, linux-kernel, kernel-janitors

Hi,
    Yes, a usleep(10) would be just fine.


Regards

Kevin

-----Original Message-----
From: David Miller [mailto:davem@davemloft.net] 
Sent: 26 May 2014 05:41
To: joe@perches.com
Cc: manuel.schoelling@gmx.de; Kevin Curtis; netdev@vger.kernel.org; linux-kernel@vger.kernel.org; kernel-janitors@vger.kernel.org
Subject: Re: [PATCH] wan: time_before()

From: Joe Perches <joe@perches.com>
Date: Sun, 25 May 2014 10:58:52 -0700

> On Sun, 2014-05-25 at 19:32 +0200, Manuel Schölling wrote:
>> To be future-proof and for better readability the time comparisons 
>> are modified to use time_before() instead of plain, error-prone math.
> 
> Sensible change, but it seems these should be
> udelay(some_constant) instead of a a rather variable time wait based 
> on a system/config defined jiffies.

Agreed, this code probably wants udelay(10) or something like that.

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

* [PATCH] wan: Use usleep_range()
  2014-05-28  7:09     ` Kevin Curtis
@ 2014-05-31 15:07       ` Manuel Schölling
  2014-06-02  8:56         ` Kevin Curtis
  2014-06-03  0:01         ` David Miller
  0 siblings, 2 replies; 7+ messages in thread
From: Manuel Schölling @ 2014-05-31 15:07 UTC (permalink / raw)
  To: kevin.curtis; +Cc: davem, joe, netdev, linux-kernel, Manuel Schölling

Instead of using a jiffies hack we can use the standard api for delays.

Signed-off-by: Manuel Schölling <manuel.schoelling@gmx.de>
---
 drivers/net/wan/farsync.c |   10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/drivers/net/wan/farsync.c b/drivers/net/wan/farsync.c
index bcfff0d..02f6d1c 100644
--- a/drivers/net/wan/farsync.c
+++ b/drivers/net/wan/farsync.c
@@ -26,6 +26,7 @@
 #include <linux/ioport.h>
 #include <linux/init.h>
 #include <linux/interrupt.h>
+#include <linux/delay.h>
 #include <linux/if.h>
 #include <linux/hdlc.h>
 #include <asm/io.h>
@@ -678,7 +679,6 @@ static inline void
 fst_cpureset(struct fst_card_info *card)
 {
 	unsigned char interrupt_line_register;
-	unsigned long j = jiffies + 1;
 	unsigned int regval;
 
 	if (card->family == FST_FAMILY_TXU) {
@@ -696,16 +696,12 @@ fst_cpureset(struct fst_card_info *card)
 		/*
 		 * We are delaying here to allow the 9054 to reset itself
 		 */
-		j = jiffies + 1;
-		while (jiffies < j)
-			/* Do nothing */ ;
+		usleep_range(10, 20);
 		outw(0x240f, card->pci_conf + CNTRL_9054 + 2);
 		/*
 		 * We are delaying here to allow the 9054 to reload its eeprom
 		 */
-		j = jiffies + 1;
-		while (jiffies < j)
-			/* Do nothing */ ;
+		usleep_range(10, 20);
 		outw(0x040f, card->pci_conf + CNTRL_9054 + 2);
 
 		if (pci_write_config_byte
-- 
1.7.10.4

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

* RE: [PATCH] wan: Use usleep_range()
  2014-05-31 15:07       ` [PATCH] wan: Use usleep_range() Manuel Schölling
@ 2014-06-02  8:56         ` Kevin Curtis
  2014-06-03  0:01         ` David Miller
  1 sibling, 0 replies; 7+ messages in thread
From: Kevin Curtis @ 2014-06-02  8:56 UTC (permalink / raw)
  To: Manuel Schölling; +Cc: davem, joe, netdev, linux-kernel

Hi Manuel,
   This look fine to me.

Regards

Kevin

-----Original Message-----
From: Manuel Schölling [mailto:manuel.schoelling@gmx.de] 
Sent: 31 May 2014 16:08
To: Kevin Curtis
Cc: davem@davemloft.net; joe@perches.com; netdev@vger.kernel.org; linux-kernel@vger.kernel.org; Manuel Schölling
Subject: [PATCH] wan: Use usleep_range()

Instead of using a jiffies hack we can use the standard api for delays.

Signed-off-by: Manuel Schölling <manuel.schoelling@gmx.de>
---
 drivers/net/wan/farsync.c |   10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/drivers/net/wan/farsync.c b/drivers/net/wan/farsync.c index bcfff0d..02f6d1c 100644
--- a/drivers/net/wan/farsync.c
+++ b/drivers/net/wan/farsync.c
@@ -26,6 +26,7 @@
 #include <linux/ioport.h>
 #include <linux/init.h>
 #include <linux/interrupt.h>
+#include <linux/delay.h>
 #include <linux/if.h>
 #include <linux/hdlc.h>
 #include <asm/io.h>
@@ -678,7 +679,6 @@ static inline void
 fst_cpureset(struct fst_card_info *card)  {
 	unsigned char interrupt_line_register;
-	unsigned long j = jiffies + 1;
 	unsigned int regval;
 
 	if (card->family == FST_FAMILY_TXU) {
@@ -696,16 +696,12 @@ fst_cpureset(struct fst_card_info *card)
 		/*
 		 * We are delaying here to allow the 9054 to reset itself
 		 */
-		j = jiffies + 1;
-		while (jiffies < j)
-			/* Do nothing */ ;
+		usleep_range(10, 20);
 		outw(0x240f, card->pci_conf + CNTRL_9054 + 2);
 		/*
 		 * We are delaying here to allow the 9054 to reload its eeprom
 		 */
-		j = jiffies + 1;
-		while (jiffies < j)
-			/* Do nothing */ ;
+		usleep_range(10, 20);
 		outw(0x040f, card->pci_conf + CNTRL_9054 + 2);
 
 		if (pci_write_config_byte
--
1.7.10.4


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

* Re: [PATCH] wan: Use usleep_range()
  2014-05-31 15:07       ` [PATCH] wan: Use usleep_range() Manuel Schölling
  2014-06-02  8:56         ` Kevin Curtis
@ 2014-06-03  0:01         ` David Miller
  1 sibling, 0 replies; 7+ messages in thread
From: David Miller @ 2014-06-03  0:01 UTC (permalink / raw)
  To: manuel.schoelling; +Cc: kevin.curtis, joe, netdev, linux-kernel

From: Manuel Schölling <manuel.schoelling@gmx.de>
Date: Sat, 31 May 2014 17:07:51 +0200

> Instead of using a jiffies hack we can use the standard api for delays.
> 
> Signed-off-by: Manuel Schölling <manuel.schoelling@gmx.de>

Applied, thanks.

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

end of thread, other threads:[~2014-06-03  0:01 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-05-25 17:32 [PATCH] wan: time_before() Manuel Schölling
2014-05-25 17:58 ` Joe Perches
2014-05-26  4:40   ` David Miller
2014-05-28  7:09     ` Kevin Curtis
2014-05-31 15:07       ` [PATCH] wan: Use usleep_range() Manuel Schölling
2014-06-02  8:56         ` Kevin Curtis
2014-06-03  0:01         ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).