* [PATCH] msi3103: Use time_before_eq()
@ 2014-05-25 12:39 Manuel Schölling
2014-06-15 9:47 ` Antti Palosaari
0 siblings, 1 reply; 4+ messages in thread
From: Manuel Schölling @ 2014-05-25 12:39 UTC (permalink / raw)
To: crope
Cc: m.chehab, gregkh, linux-media, devel, linux-kernel,
kernel-janitors, Manuel Schölling
To be future-proof and for better readability the time comparisons are
modified to use time_before_eq() instead of plain, error-prone math.
Signed-off-by: Manuel Schölling <manuel.schoelling@gmx.de>
---
drivers/staging/media/msi3101/sdr-msi3101.c | 28 +++++++++++++--------------
1 file changed, 14 insertions(+), 14 deletions(-)
diff --git a/drivers/staging/media/msi3101/sdr-msi3101.c b/drivers/staging/media/msi3101/sdr-msi3101.c
index 65d351f..7a0a8ca 100644
--- a/drivers/staging/media/msi3101/sdr-msi3101.c
+++ b/drivers/staging/media/msi3101/sdr-msi3101.c
@@ -207,10 +207,10 @@ static int msi3101_convert_stream_504(struct msi3101_state *s, u8 *dst,
dst_len += 1008;
}
- /* calculate samping rate and output it in 10 seconds intervals */
- if ((s->jiffies_next + msecs_to_jiffies(10000)) <= jiffies) {
+ /* calculate sampling rate and output it in 10 seconds intervals */
+ if (time_before_eq(s->jiffies_next + 10 * HZ, jiffies)) {
unsigned long jiffies_now = jiffies;
- unsigned long msecs = jiffies_to_msecs(jiffies_now) - jiffies_to_msecs(s->jiffies_next);
+ unsigned long msecs = jiffies_to_msecs(jiffies_now - s->jiffies_next);
unsigned int samples = sample_num[i_max - 1] - s->sample;
s->jiffies_next = jiffies_now;
s->sample = sample_num[i_max - 1];
@@ -265,7 +265,7 @@ static int msi3101_convert_stream_504_u8(struct msi3101_state *s, u8 *dst,
dst_len += 1008;
}
- /* calculate samping rate and output it in 10 seconds intervals */
+ /* calculate sampling rate and output it in 10 seconds intervals */
if (unlikely(time_is_before_jiffies(s->jiffies_next))) {
#define MSECS 10000UL
unsigned int samples = sample_num[i_max - 1] - s->sample;
@@ -359,10 +359,10 @@ static int msi3101_convert_stream_384(struct msi3101_state *s, u8 *dst,
dst_len += 984;
}
- /* calculate samping rate and output it in 10 seconds intervals */
- if ((s->jiffies_next + msecs_to_jiffies(10000)) <= jiffies) {
+ /* calculate sampling rate and output it in 10 seconds intervals */
+ if (time_before_eq(s->jiffies_next + 10 * HZ, jiffies)) {
unsigned long jiffies_now = jiffies;
- unsigned long msecs = jiffies_to_msecs(jiffies_now) - jiffies_to_msecs(s->jiffies_next);
+ unsigned long msecs = jiffies_to_msecs(jiffies_now - s->jiffies_next);
unsigned int samples = sample_num[i_max - 1] - s->sample;
s->jiffies_next = jiffies_now;
s->sample = sample_num[i_max - 1];
@@ -424,10 +424,10 @@ static int msi3101_convert_stream_336(struct msi3101_state *s, u8 *dst,
dst_len += 1008;
}
- /* calculate samping rate and output it in 10 seconds intervals */
- if ((s->jiffies_next + msecs_to_jiffies(10000)) <= jiffies) {
+ /* calculate sampling rate and output it in 10 seconds intervals */
+ if (time_before_eq(s->jiffies_next + 10 * HZ, jiffies)) {
unsigned long jiffies_now = jiffies;
- unsigned long msecs = jiffies_to_msecs(jiffies_now) - jiffies_to_msecs(s->jiffies_next);
+ unsigned long msecs = jiffies_to_msecs(jiffies_now - s->jiffies_next);
unsigned int samples = sample_num[i_max - 1] - s->sample;
s->jiffies_next = jiffies_now;
s->sample = sample_num[i_max - 1];
@@ -487,10 +487,10 @@ static int msi3101_convert_stream_252(struct msi3101_state *s, u8 *dst,
dst_len += 1008;
}
- /* calculate samping rate and output it in 10 seconds intervals */
- if ((s->jiffies_next + msecs_to_jiffies(10000)) <= jiffies) {
+ /* calculate sampling rate and output it in 10 seconds intervals */
+ if (time_before_eq(s->jiffies_next + 10 * HZ, jiffies)) {
unsigned long jiffies_now = jiffies;
- unsigned long msecs = jiffies_to_msecs(jiffies_now) - jiffies_to_msecs(s->jiffies_next);
+ unsigned long msecs = jiffies_to_msecs(jiffies_now - s->jiffies_next);
unsigned int samples = sample_num[i_max - 1] - s->sample;
s->jiffies_next = jiffies_now;
s->sample = sample_num[i_max - 1];
@@ -560,7 +560,7 @@ static int msi3101_convert_stream_252_u16(struct msi3101_state *s, u8 *dst,
dst_len += 1008;
}
- /* calculate samping rate and output it in 10 seconds intervals */
+ /* calculate sampling rate and output it in 10 seconds intervals */
if (unlikely(time_is_before_jiffies(s->jiffies_next))) {
#define MSECS 10000UL
unsigned int samples = sample_num[i_max - 1] - s->sample;
--
1.7.10.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] msi3103: Use time_before_eq()
2014-05-25 12:39 [PATCH] msi3103: Use time_before_eq() Manuel Schölling
@ 2014-06-15 9:47 ` Antti Palosaari
0 siblings, 0 replies; 4+ messages in thread
From: Antti Palosaari @ 2014-06-15 9:47 UTC (permalink / raw)
To: Manuel Schölling
Cc: m.chehab, gregkh, linux-media, devel, linux-kernel, kernel-janitors
Acked-by: Antti Palosaari <crope@iki.fi>
Reviewed-by: Antti Palosaari <crope@iki.fi>
Mauro, pick that from patchwork to 3.16. I am not going to PULL request it.
regards
Antti
On 05/25/2014 03:39 PM, Manuel Schölling wrote:
> To be future-proof and for better readability the time comparisons are
> modified to use time_before_eq() instead of plain, error-prone math.
>
> Signed-off-by: Manuel Schölling <manuel.schoelling@gmx.de>
> ---
> drivers/staging/media/msi3101/sdr-msi3101.c | 28 +++++++++++++--------------
> 1 file changed, 14 insertions(+), 14 deletions(-)
>
> diff --git a/drivers/staging/media/msi3101/sdr-msi3101.c b/drivers/staging/media/msi3101/sdr-msi3101.c
> index 65d351f..7a0a8ca 100644
> --- a/drivers/staging/media/msi3101/sdr-msi3101.c
> +++ b/drivers/staging/media/msi3101/sdr-msi3101.c
> @@ -207,10 +207,10 @@ static int msi3101_convert_stream_504(struct msi3101_state *s, u8 *dst,
> dst_len += 1008;
> }
>
> - /* calculate samping rate and output it in 10 seconds intervals */
> - if ((s->jiffies_next + msecs_to_jiffies(10000)) <= jiffies) {
> + /* calculate sampling rate and output it in 10 seconds intervals */
> + if (time_before_eq(s->jiffies_next + 10 * HZ, jiffies)) {
> unsigned long jiffies_now = jiffies;
> - unsigned long msecs = jiffies_to_msecs(jiffies_now) - jiffies_to_msecs(s->jiffies_next);
> + unsigned long msecs = jiffies_to_msecs(jiffies_now - s->jiffies_next);
> unsigned int samples = sample_num[i_max - 1] - s->sample;
> s->jiffies_next = jiffies_now;
> s->sample = sample_num[i_max - 1];
> @@ -265,7 +265,7 @@ static int msi3101_convert_stream_504_u8(struct msi3101_state *s, u8 *dst,
> dst_len += 1008;
> }
>
> - /* calculate samping rate and output it in 10 seconds intervals */
> + /* calculate sampling rate and output it in 10 seconds intervals */
> if (unlikely(time_is_before_jiffies(s->jiffies_next))) {
> #define MSECS 10000UL
> unsigned int samples = sample_num[i_max - 1] - s->sample;
> @@ -359,10 +359,10 @@ static int msi3101_convert_stream_384(struct msi3101_state *s, u8 *dst,
> dst_len += 984;
> }
>
> - /* calculate samping rate and output it in 10 seconds intervals */
> - if ((s->jiffies_next + msecs_to_jiffies(10000)) <= jiffies) {
> + /* calculate sampling rate and output it in 10 seconds intervals */
> + if (time_before_eq(s->jiffies_next + 10 * HZ, jiffies)) {
> unsigned long jiffies_now = jiffies;
> - unsigned long msecs = jiffies_to_msecs(jiffies_now) - jiffies_to_msecs(s->jiffies_next);
> + unsigned long msecs = jiffies_to_msecs(jiffies_now - s->jiffies_next);
> unsigned int samples = sample_num[i_max - 1] - s->sample;
> s->jiffies_next = jiffies_now;
> s->sample = sample_num[i_max - 1];
> @@ -424,10 +424,10 @@ static int msi3101_convert_stream_336(struct msi3101_state *s, u8 *dst,
> dst_len += 1008;
> }
>
> - /* calculate samping rate and output it in 10 seconds intervals */
> - if ((s->jiffies_next + msecs_to_jiffies(10000)) <= jiffies) {
> + /* calculate sampling rate and output it in 10 seconds intervals */
> + if (time_before_eq(s->jiffies_next + 10 * HZ, jiffies)) {
> unsigned long jiffies_now = jiffies;
> - unsigned long msecs = jiffies_to_msecs(jiffies_now) - jiffies_to_msecs(s->jiffies_next);
> + unsigned long msecs = jiffies_to_msecs(jiffies_now - s->jiffies_next);
> unsigned int samples = sample_num[i_max - 1] - s->sample;
> s->jiffies_next = jiffies_now;
> s->sample = sample_num[i_max - 1];
> @@ -487,10 +487,10 @@ static int msi3101_convert_stream_252(struct msi3101_state *s, u8 *dst,
> dst_len += 1008;
> }
>
> - /* calculate samping rate and output it in 10 seconds intervals */
> - if ((s->jiffies_next + msecs_to_jiffies(10000)) <= jiffies) {
> + /* calculate sampling rate and output it in 10 seconds intervals */
> + if (time_before_eq(s->jiffies_next + 10 * HZ, jiffies)) {
> unsigned long jiffies_now = jiffies;
> - unsigned long msecs = jiffies_to_msecs(jiffies_now) - jiffies_to_msecs(s->jiffies_next);
> + unsigned long msecs = jiffies_to_msecs(jiffies_now - s->jiffies_next);
> unsigned int samples = sample_num[i_max - 1] - s->sample;
> s->jiffies_next = jiffies_now;
> s->sample = sample_num[i_max - 1];
> @@ -560,7 +560,7 @@ static int msi3101_convert_stream_252_u16(struct msi3101_state *s, u8 *dst,
> dst_len += 1008;
> }
>
> - /* calculate samping rate and output it in 10 seconds intervals */
> + /* calculate sampling rate and output it in 10 seconds intervals */
> if (unlikely(time_is_before_jiffies(s->jiffies_next))) {
> #define MSECS 10000UL
> unsigned int samples = sample_num[i_max - 1] - s->sample;
>
--
http://palosaari.fi/
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] msi3103: Use time_before_eq()
2014-05-24 18:47 Manuel Schölling
@ 2014-05-24 19:10 ` Joe Perches
0 siblings, 0 replies; 4+ messages in thread
From: Joe Perches @ 2014-05-24 19:10 UTC (permalink / raw)
To: Manuel Schölling
Cc: crope, m.chehab, gregkh, linux-media, devel, linux-kernel,
kernel-janitors
On Sat, 2014-05-24 at 20:47 +0200, Manuel Schölling wrote:
> To be future-proof and for better readability the time comparisons are
> modified to use time_before_eq() instead of plain, error-prone math.
A couple of unrelated, trivial notes: (repeated a few times)
> diff --git a/drivers/staging/media/msi3101/sdr-msi3101.c b/drivers/staging/media/msi3101/sdr-msi3101.c
[]
> @@ -208,7 +208,7 @@ static int msi3101_convert_stream_504(struct msi3101_state *s, u8 *dst,
> }
>
> /* calculate samping rate and output it in 10 seconds intervals */
s/samping/sampling/
> - if ((s->jiffies_next + msecs_to_jiffies(10000)) <= jiffies) {
> + if (time_before_eq(s->jiffies_next + 10 * HZ, jiffies)) {
> unsigned long jiffies_now = jiffies;
> unsigned long msecs = jiffies_to_msecs(jiffies_now) - jiffies_to_msecs(s->jiffies_next);
Perhaps better to subtract then convert
instead of convert twice then subtract.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH] msi3103: Use time_before_eq()
@ 2014-05-24 18:47 Manuel Schölling
2014-05-24 19:10 ` Joe Perches
0 siblings, 1 reply; 4+ messages in thread
From: Manuel Schölling @ 2014-05-24 18:47 UTC (permalink / raw)
To: crope
Cc: m.chehab, gregkh, linux-media, devel, linux-kernel,
kernel-janitors, Manuel Schölling
To be future-proof and for better readability the time comparisons are
modified to use time_before_eq() instead of plain, error-prone math.
Signed-off-by: Manuel Schölling <manuel.schoelling@gmx.de>
---
drivers/staging/media/msi3101/sdr-msi3101.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/staging/media/msi3101/sdr-msi3101.c b/drivers/staging/media/msi3101/sdr-msi3101.c
index 65d351f..b52726b 100644
--- a/drivers/staging/media/msi3101/sdr-msi3101.c
+++ b/drivers/staging/media/msi3101/sdr-msi3101.c
@@ -208,7 +208,7 @@ static int msi3101_convert_stream_504(struct msi3101_state *s, u8 *dst,
}
/* calculate samping rate and output it in 10 seconds intervals */
- if ((s->jiffies_next + msecs_to_jiffies(10000)) <= jiffies) {
+ if (time_before_eq(s->jiffies_next + 10 * HZ, jiffies)) {
unsigned long jiffies_now = jiffies;
unsigned long msecs = jiffies_to_msecs(jiffies_now) - jiffies_to_msecs(s->jiffies_next);
unsigned int samples = sample_num[i_max - 1] - s->sample;
@@ -360,7 +360,7 @@ static int msi3101_convert_stream_384(struct msi3101_state *s, u8 *dst,
}
/* calculate samping rate and output it in 10 seconds intervals */
- if ((s->jiffies_next + msecs_to_jiffies(10000)) <= jiffies) {
+ if (time_before_eq(s->jiffies_next + 10 * HZ, jiffies)) {
unsigned long jiffies_now = jiffies;
unsigned long msecs = jiffies_to_msecs(jiffies_now) - jiffies_to_msecs(s->jiffies_next);
unsigned int samples = sample_num[i_max - 1] - s->sample;
@@ -425,7 +425,7 @@ static int msi3101_convert_stream_336(struct msi3101_state *s, u8 *dst,
}
/* calculate samping rate and output it in 10 seconds intervals */
- if ((s->jiffies_next + msecs_to_jiffies(10000)) <= jiffies) {
+ if (time_before_eq(s->jiffies_next + 10 * HZ, jiffies)) {
unsigned long jiffies_now = jiffies;
unsigned long msecs = jiffies_to_msecs(jiffies_now) - jiffies_to_msecs(s->jiffies_next);
unsigned int samples = sample_num[i_max - 1] - s->sample;
@@ -488,7 +488,7 @@ static int msi3101_convert_stream_252(struct msi3101_state *s, u8 *dst,
}
/* calculate samping rate and output it in 10 seconds intervals */
- if ((s->jiffies_next + msecs_to_jiffies(10000)) <= jiffies) {
+ if (time_before_eq(s->jiffies_next + 10 * HZ, jiffies)) {
unsigned long jiffies_now = jiffies;
unsigned long msecs = jiffies_to_msecs(jiffies_now) - jiffies_to_msecs(s->jiffies_next);
unsigned int samples = sample_num[i_max - 1] - s->sample;
--
1.7.10.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2014-06-15 9:47 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-05-25 12:39 [PATCH] msi3103: Use time_before_eq() Manuel Schölling
2014-06-15 9:47 ` Antti Palosaari
-- strict thread matches above, loose matches on Subject: below --
2014-05-24 18:47 Manuel Schölling
2014-05-24 19:10 ` Joe Perches
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).