* [PATCH 1/2] mISDN: Use time_before()
@ 2014-05-21 19:10 Manuel Schölling
2014-05-21 19:10 ` [PATCH 2/2] mISDN: use mod_timer() Manuel Schölling
2014-05-21 19:27 ` [PATCH 1/2] mISDN: Use time_before() Sergei Shtylyov
0 siblings, 2 replies; 9+ messages in thread
From: Manuel Schölling @ 2014-05-21 19:10 UTC (permalink / raw)
To: isdn; +Cc: manuel.schoelling, netdev, linux-kernel
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/isdn/mISDN/l1oip_core.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/isdn/mISDN/l1oip_core.c b/drivers/isdn/mISDN/l1oip_core.c
index 2c0d2c2..1c2bc36 100644
--- a/drivers/isdn/mISDN/l1oip_core.c
+++ b/drivers/isdn/mISDN/l1oip_core.c
@@ -287,7 +287,7 @@ l1oip_socket_send(struct l1oip *hc, u8 localcodec, u8 channel, u32 chanmask,
p = frame;
/* restart timer */
- if ((int)(hc->keep_tl.expires-jiffies) < 5 * HZ) {
+ if (time_before(hc->keep_tl.expires - 5 * HZ, jiffies)) {
del_timer(&hc->keep_tl);
hc->keep_tl.expires = jiffies + L1OIP_KEEPALIVE * HZ;
add_timer(&hc->keep_tl);
@@ -621,7 +621,8 @@ multiframe:
goto multiframe;
/* restart timer */
- if ((int)(hc->timeout_tl.expires-jiffies) < 5 * HZ || !hc->timeout_on) {
+ if (time_before(hc->timeout_tl.expires - 5 * HZ, jiffies)
+ || !hc->timeout_on) {
hc->timeout_on = 1;
del_timer(&hc->timeout_tl);
hc->timeout_tl.expires = jiffies + L1OIP_TIMEOUT * HZ;
--
1.7.10.4
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH 2/2] mISDN: use mod_timer()
2014-05-21 19:10 [PATCH 1/2] mISDN: Use time_before() Manuel Schölling
@ 2014-05-21 19:10 ` Manuel Schölling
2014-05-21 19:27 ` [PATCH 1/2] mISDN: Use time_before() Sergei Shtylyov
1 sibling, 0 replies; 9+ messages in thread
From: Manuel Schölling @ 2014-05-21 19:10 UTC (permalink / raw)
To: isdn; +Cc: manuel.schoelling, netdev, linux-kernel
The code for resetting the timer can be simplified if mod_timer() is used
instead of del_timer() followed by add_timer().
Signed-off-by: Manuel Schölling <manuel.schoelling@gmx.de>
---
drivers/isdn/mISDN/l1oip_core.c | 8 ++------
1 file changed, 2 insertions(+), 6 deletions(-)
diff --git a/drivers/isdn/mISDN/l1oip_core.c b/drivers/isdn/mISDN/l1oip_core.c
index 1c2bc36..a4c6cc0 100644
--- a/drivers/isdn/mISDN/l1oip_core.c
+++ b/drivers/isdn/mISDN/l1oip_core.c
@@ -288,9 +288,7 @@ l1oip_socket_send(struct l1oip *hc, u8 localcodec, u8 channel, u32 chanmask,
/* restart timer */
if (time_before(hc->keep_tl.expires - 5 * HZ, jiffies)) {
- del_timer(&hc->keep_tl);
- hc->keep_tl.expires = jiffies + L1OIP_KEEPALIVE * HZ;
- add_timer(&hc->keep_tl);
+ mod_timer(&hc->keep_tl, jiffies + L1OIP_KEEPALIVE * HZ);
} else
hc->keep_tl.expires = jiffies + L1OIP_KEEPALIVE * HZ;
@@ -624,9 +622,7 @@ multiframe:
if (time_before(hc->timeout_tl.expires - 5 * HZ, jiffies)
|| !hc->timeout_on) {
hc->timeout_on = 1;
- del_timer(&hc->timeout_tl);
- hc->timeout_tl.expires = jiffies + L1OIP_TIMEOUT * HZ;
- add_timer(&hc->timeout_tl);
+ mod_timer(&hc->timeout_tl, jiffies + L1OIP_TIMEOUT * HZ);
} else /* only adjust timer */
hc->timeout_tl.expires = jiffies + L1OIP_TIMEOUT * HZ;
--
1.7.10.4
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH 1/2] mISDN: Use time_before()
2014-05-21 19:10 [PATCH 1/2] mISDN: Use time_before() Manuel Schölling
2014-05-21 19:10 ` [PATCH 2/2] mISDN: use mod_timer() Manuel Schölling
@ 2014-05-21 19:27 ` Sergei Shtylyov
2014-05-21 20:07 ` Joe Perches
2014-05-21 20:08 ` [PATCH v2 " Manuel Schölling
1 sibling, 2 replies; 9+ messages in thread
From: Sergei Shtylyov @ 2014-05-21 19:27 UTC (permalink / raw)
To: Manuel Schölling, isdn; +Cc: netdev, linux-kernel
Hello.
On 05/21/2014 11:10 PM, 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.
> Signed-off-by: Manuel Schölling <manuel.schoelling@gmx.de>
> ---
> drivers/isdn/mISDN/l1oip_core.c | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
> diff --git a/drivers/isdn/mISDN/l1oip_core.c b/drivers/isdn/mISDN/l1oip_core.c
> index 2c0d2c2..1c2bc36 100644
> --- a/drivers/isdn/mISDN/l1oip_core.c
> +++ b/drivers/isdn/mISDN/l1oip_core.c
> @@ -287,7 +287,7 @@ l1oip_socket_send(struct l1oip *hc, u8 localcodec, u8 channel, u32 chanmask,
> p = frame;
>
> /* restart timer */
> - if ((int)(hc->keep_tl.expires-jiffies) < 5 * HZ) {
> + if (time_before(hc->keep_tl.expires - 5 * HZ, jiffies)) {
Wouldn't it be clearer this way:
if (time_before(hc->keep_tl.expires, jiffies + 5 * HZ)) {
> del_timer(&hc->keep_tl);
> hc->keep_tl.expires = jiffies + L1OIP_KEEPALIVE * HZ;
> add_timer(&hc->keep_tl);
> @@ -621,7 +621,8 @@ multiframe:
> goto multiframe;
>
> /* restart timer */
> - if ((int)(hc->timeout_tl.expires-jiffies) < 5 * HZ || !hc->timeout_on) {
> + if (time_before(hc->timeout_tl.expires - 5 * HZ, jiffies)
> + || !hc->timeout_on) {
Please leave || on the previous line.
WBR, Sergei
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 1/2] mISDN: Use time_before()
2014-05-21 19:27 ` [PATCH 1/2] mISDN: Use time_before() Sergei Shtylyov
@ 2014-05-21 20:07 ` Joe Perches
2014-05-21 20:43 ` Sergei Shtylyov
2014-05-21 20:08 ` [PATCH v2 " Manuel Schölling
1 sibling, 1 reply; 9+ messages in thread
From: Joe Perches @ 2014-05-21 20:07 UTC (permalink / raw)
To: Sergei Shtylyov; +Cc: Manuel Schölling, isdn, netdev, linux-kernel
On Wed, 2014-05-21 at 23:27 +0400, Sergei Shtylyov wrote:
> On 05/21/2014 11:10 PM, 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.
> > diff --git a/drivers/isdn/mISDN/l1oip_core.c b/drivers/isdn/mISDN/l1oip_core.c
[]
> > @@ -287,7 +287,7 @@ l1oip_socket_send(struct l1oip *hc, u8 localcodec, u8 channel, u32 chanmask,
> > p = frame;
> >
> > /* restart timer */
> > - if ((int)(hc->keep_tl.expires-jiffies) < 5 * HZ) {
> > + if (time_before(hc->keep_tl.expires - 5 * HZ, jiffies)) {
>
> Wouldn't it be clearer this way:
>
> if (time_before(hc->keep_tl.expires, jiffies + 5 * HZ)) {
> > del_timer(&hc->keep_tl);
> > hc->keep_tl.expires = jiffies + L1OIP_KEEPALIVE * HZ;
> > add_timer(&hc->keep_tl);
mod_timer?
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH v2 1/2] mISDN: Use time_before()
2014-05-21 19:27 ` [PATCH 1/2] mISDN: Use time_before() Sergei Shtylyov
2014-05-21 20:07 ` Joe Perches
@ 2014-05-21 20:08 ` Manuel Schölling
2014-05-21 20:08 ` [PATCH v2 2/2] mISDN: Use mod_timer() Manuel Schölling
2014-05-22 19:50 ` [PATCH v2 1/2] mISDN: Use time_before() David Miller
1 sibling, 2 replies; 9+ messages in thread
From: Manuel Schölling @ 2014-05-21 20:08 UTC (permalink / raw)
To: isdn; +Cc: manuel.schoelling, netdev, linux-kernel
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/isdn/mISDN/l1oip_core.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/isdn/mISDN/l1oip_core.c b/drivers/isdn/mISDN/l1oip_core.c
index 2c0d2c2..084f936 100644
--- a/drivers/isdn/mISDN/l1oip_core.c
+++ b/drivers/isdn/mISDN/l1oip_core.c
@@ -287,7 +287,7 @@ l1oip_socket_send(struct l1oip *hc, u8 localcodec, u8 channel, u32 chanmask,
p = frame;
/* restart timer */
- if ((int)(hc->keep_tl.expires-jiffies) < 5 * HZ) {
+ if (time_before(hc->keep_tl.expires, jiffies + 5 * HZ)) {
del_timer(&hc->keep_tl);
hc->keep_tl.expires = jiffies + L1OIP_KEEPALIVE * HZ;
add_timer(&hc->keep_tl);
@@ -621,7 +621,7 @@ multiframe:
goto multiframe;
/* restart timer */
- if ((int)(hc->timeout_tl.expires-jiffies) < 5 * HZ || !hc->timeout_on) {
+ if (time_before(hc->timeout_tl.expires, jiffies + 5 * HZ) || !hc->timeout_on) {
hc->timeout_on = 1;
del_timer(&hc->timeout_tl);
hc->timeout_tl.expires = jiffies + L1OIP_TIMEOUT * HZ;
--
1.7.10.4
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH v2 2/2] mISDN: Use mod_timer()
2014-05-21 20:08 ` [PATCH v2 " Manuel Schölling
@ 2014-05-21 20:08 ` Manuel Schölling
2014-05-22 19:50 ` David Miller
2014-05-22 19:50 ` [PATCH v2 1/2] mISDN: Use time_before() David Miller
1 sibling, 1 reply; 9+ messages in thread
From: Manuel Schölling @ 2014-05-21 20:08 UTC (permalink / raw)
To: isdn; +Cc: manuel.schoelling, netdev, linux-kernel
The code for resetting the timer can be simplified if mod_timer() is used
instead of del_timer() followed by add_timer().
Signed-off-by: Manuel Schölling <manuel.schoelling@gmx.de>
---
drivers/isdn/mISDN/l1oip_core.c | 12 ++++--------
1 file changed, 4 insertions(+), 8 deletions(-)
diff --git a/drivers/isdn/mISDN/l1oip_core.c b/drivers/isdn/mISDN/l1oip_core.c
index 084f936..9f454d7 100644
--- a/drivers/isdn/mISDN/l1oip_core.c
+++ b/drivers/isdn/mISDN/l1oip_core.c
@@ -287,11 +287,9 @@ l1oip_socket_send(struct l1oip *hc, u8 localcodec, u8 channel, u32 chanmask,
p = frame;
/* restart timer */
- if (time_before(hc->keep_tl.expires, jiffies + 5 * HZ)) {
- del_timer(&hc->keep_tl);
- hc->keep_tl.expires = jiffies + L1OIP_KEEPALIVE * HZ;
- add_timer(&hc->keep_tl);
- } else
+ if (time_before(hc->keep_tl.expires, jiffies + 5 * HZ))
+ mod_timer(&hc->keep_tl, jiffies + L1OIP_KEEPALIVE * HZ);
+ else
hc->keep_tl.expires = jiffies + L1OIP_KEEPALIVE * HZ;
if (debug & DEBUG_L1OIP_MSG)
@@ -623,9 +621,7 @@ multiframe:
/* restart timer */
if (time_before(hc->timeout_tl.expires, jiffies + 5 * HZ) || !hc->timeout_on) {
hc->timeout_on = 1;
- del_timer(&hc->timeout_tl);
- hc->timeout_tl.expires = jiffies + L1OIP_TIMEOUT * HZ;
- add_timer(&hc->timeout_tl);
+ mod_timer(&hc->timeout_tl, jiffies + L1OIP_TIMEOUT * HZ);
} else /* only adjust timer */
hc->timeout_tl.expires = jiffies + L1OIP_TIMEOUT * HZ;
--
1.7.10.4
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH 1/2] mISDN: Use time_before()
2014-05-21 20:07 ` Joe Perches
@ 2014-05-21 20:43 ` Sergei Shtylyov
0 siblings, 0 replies; 9+ messages in thread
From: Sergei Shtylyov @ 2014-05-21 20:43 UTC (permalink / raw)
To: Joe Perches; +Cc: Manuel Schölling, isdn, netdev, linux-kernel
Hello.
On 05/22/2014 12:07 AM, Joe Perches wrote:
>>> To be future-proof and for better readability the time comparisons are modified
>>> to use time_before() instead of plain, error-prone math.
>>> diff --git a/drivers/isdn/mISDN/l1oip_core.c b/drivers/isdn/mISDN/l1oip_core.c
> []
>>> @@ -287,7 +287,7 @@ l1oip_socket_send(struct l1oip *hc, u8 localcodec, u8 channel, u32 chanmask,
>>> p = frame;
>>>
>>> /* restart timer */
>>> - if ((int)(hc->keep_tl.expires-jiffies) < 5 * HZ) {
>>> + if (time_before(hc->keep_tl.expires - 5 * HZ, jiffies)) {
>> Wouldn't it be clearer this way:
>> if (time_before(hc->keep_tl.expires, jiffies + 5 * HZ)) {
>>> del_timer(&hc->keep_tl);
>>> hc->keep_tl.expires = jiffies + L1OIP_KEEPALIVE * HZ;
>>> add_timer(&hc->keep_tl);
> mod_timer?
Done by the 2nd patch.
WBR, Sergei
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v2 1/2] mISDN: Use time_before()
2014-05-21 20:08 ` [PATCH v2 " Manuel Schölling
2014-05-21 20:08 ` [PATCH v2 2/2] mISDN: Use mod_timer() Manuel Schölling
@ 2014-05-22 19:50 ` David Miller
1 sibling, 0 replies; 9+ messages in thread
From: David Miller @ 2014-05-22 19:50 UTC (permalink / raw)
To: manuel.schoelling; +Cc: isdn, netdev, linux-kernel
From: Manuel Schölling <manuel.schoelling@gmx.de>
Date: Wed, 21 May 2014 22:08:47 +0200
> 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>
Applied.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v2 2/2] mISDN: Use mod_timer()
2014-05-21 20:08 ` [PATCH v2 2/2] mISDN: Use mod_timer() Manuel Schölling
@ 2014-05-22 19:50 ` David Miller
0 siblings, 0 replies; 9+ messages in thread
From: David Miller @ 2014-05-22 19:50 UTC (permalink / raw)
To: manuel.schoelling; +Cc: isdn, netdev, linux-kernel
From: Manuel Schölling <manuel.schoelling@gmx.de>
Date: Wed, 21 May 2014 22:08:48 +0200
> The code for resetting the timer can be simplified if mod_timer() is used
> instead of del_timer() followed by add_timer().
>
> Signed-off-by: Manuel Schölling <manuel.schoelling@gmx.de>
Applied.
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2014-05-22 19:50 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-05-21 19:10 [PATCH 1/2] mISDN: Use time_before() Manuel Schölling
2014-05-21 19:10 ` [PATCH 2/2] mISDN: use mod_timer() Manuel Schölling
2014-05-21 19:27 ` [PATCH 1/2] mISDN: Use time_before() Sergei Shtylyov
2014-05-21 20:07 ` Joe Perches
2014-05-21 20:43 ` Sergei Shtylyov
2014-05-21 20:08 ` [PATCH v2 " Manuel Schölling
2014-05-21 20:08 ` [PATCH v2 2/2] mISDN: Use mod_timer() Manuel Schölling
2014-05-22 19:50 ` David Miller
2014-05-22 19:50 ` [PATCH v2 1/2] mISDN: Use time_before() 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).