linux-media.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/1] staging: media: msi3101: sdr-msi3101.c - replace with time_before_eq()
@ 2014-06-29  5:20 Anil Belur
  2014-06-29 19:17 ` Antti Palosaari
  0 siblings, 1 reply; 3+ messages in thread
From: Anil Belur @ 2014-06-29  5:20 UTC (permalink / raw)
  To: m.chehab, crope, gregkh; +Cc: devel, linux-media, linux-kernel, Anil Belur

From: Anil Belur <askb23@gmail.com>

- this fix replaces jiffies interval comparision with safer function to
  avoid any overflow and wrap around ?

Signed-off-by: Anil Belur <askb23@gmail.com>
---
 drivers/staging/media/msi3101/sdr-msi3101.c | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/media/msi3101/sdr-msi3101.c b/drivers/staging/media/msi3101/sdr-msi3101.c
index 08d0d09..b828857 100644
--- a/drivers/staging/media/msi3101/sdr-msi3101.c
+++ b/drivers/staging/media/msi3101/sdr-msi3101.c
@@ -180,6 +180,7 @@ static int msi3101_convert_stream_504(struct msi3101_state *s, u8 *dst,
 {
 	int i, i_max, dst_len = 0;
 	u32 sample_num[3];
+	unsigned long expires;
 
 	/* There could be 1-3 1024 bytes URB frames */
 	i_max = src_len / 1024;
@@ -208,7 +209,8 @@ 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) {
+	expires = s->jiffies_next + msecs_to_jiffies(10000);
+	if (time_before_eq(expires, 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;
@@ -332,6 +334,7 @@ static int msi3101_convert_stream_384(struct msi3101_state *s, u8 *dst,
 {
 	int i, i_max, dst_len = 0;
 	u32 sample_num[3];
+	unsigned long expires;
 
 	/* There could be 1-3 1024 bytes URB frames */
 	i_max = src_len / 1024;
@@ -360,7 +363,8 @@ 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) {
+	expires = s->jiffies_next + msecs_to_jiffies(10000);
+	if (time_before_eq(expires, 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;
@@ -397,6 +401,7 @@ static int msi3101_convert_stream_336(struct msi3101_state *s, u8 *dst,
 {
 	int i, i_max, dst_len = 0;
 	u32 sample_num[3];
+	unsigned long expires;
 
 	/* There could be 1-3 1024 bytes URB frames */
 	i_max = src_len / 1024;
@@ -425,7 +430,8 @@ 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) {
+	expires = s->jiffies_next + msecs_to_jiffies(10000);
+	if (time_before_eq(expires, 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;
@@ -460,6 +466,7 @@ static int msi3101_convert_stream_252(struct msi3101_state *s, u8 *dst,
 {
 	int i, i_max, dst_len = 0;
 	u32 sample_num[3];
+	unsigned long expires;
 
 	/* There could be 1-3 1024 bytes URB frames */
 	i_max = src_len / 1024;
@@ -488,7 +495,8 @@ 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) {
+	expires = s->jiffies_next + msecs_to_jiffies(10000);
+	if (time_before_eq(expires, 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.9.1


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

* Re: [PATCH 1/1] staging: media: msi3101: sdr-msi3101.c - replace with time_before_eq()
  2014-06-29  5:20 [PATCH 1/1] staging: media: msi3101: sdr-msi3101.c - replace with time_before_eq() Anil Belur
@ 2014-06-29 19:17 ` Antti Palosaari
  2014-06-30  3:25   ` Anil Shashikumar Belur
  0 siblings, 1 reply; 3+ messages in thread
From: Antti Palosaari @ 2014-06-29 19:17 UTC (permalink / raw)
  To: Anil Belur, m.chehab, gregkh; +Cc: devel, linux-media, linux-kernel

Moikka!
That is already fixed by someone else and patch is somewhere Mauro or 
Hans queue.

regards
Antti

On 06/29/2014 08:20 AM, Anil Belur wrote:
> From: Anil Belur <askb23@gmail.com>
>
> - this fix replaces jiffies interval comparision with safer function to
>    avoid any overflow and wrap around ?
>
> Signed-off-by: Anil Belur <askb23@gmail.com>
> ---
>   drivers/staging/media/msi3101/sdr-msi3101.c | 16 ++++++++++++----
>   1 file changed, 12 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/staging/media/msi3101/sdr-msi3101.c b/drivers/staging/media/msi3101/sdr-msi3101.c
> index 08d0d09..b828857 100644
> --- a/drivers/staging/media/msi3101/sdr-msi3101.c
> +++ b/drivers/staging/media/msi3101/sdr-msi3101.c
> @@ -180,6 +180,7 @@ static int msi3101_convert_stream_504(struct msi3101_state *s, u8 *dst,
>   {
>   	int i, i_max, dst_len = 0;
>   	u32 sample_num[3];
> +	unsigned long expires;
>
>   	/* There could be 1-3 1024 bytes URB frames */
>   	i_max = src_len / 1024;
> @@ -208,7 +209,8 @@ 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) {
> +	expires = s->jiffies_next + msecs_to_jiffies(10000);
> +	if (time_before_eq(expires, 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;
> @@ -332,6 +334,7 @@ static int msi3101_convert_stream_384(struct msi3101_state *s, u8 *dst,
>   {
>   	int i, i_max, dst_len = 0;
>   	u32 sample_num[3];
> +	unsigned long expires;
>
>   	/* There could be 1-3 1024 bytes URB frames */
>   	i_max = src_len / 1024;
> @@ -360,7 +363,8 @@ 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) {
> +	expires = s->jiffies_next + msecs_to_jiffies(10000);
> +	if (time_before_eq(expires, 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;
> @@ -397,6 +401,7 @@ static int msi3101_convert_stream_336(struct msi3101_state *s, u8 *dst,
>   {
>   	int i, i_max, dst_len = 0;
>   	u32 sample_num[3];
> +	unsigned long expires;
>
>   	/* There could be 1-3 1024 bytes URB frames */
>   	i_max = src_len / 1024;
> @@ -425,7 +430,8 @@ 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) {
> +	expires = s->jiffies_next + msecs_to_jiffies(10000);
> +	if (time_before_eq(expires, 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;
> @@ -460,6 +466,7 @@ static int msi3101_convert_stream_252(struct msi3101_state *s, u8 *dst,
>   {
>   	int i, i_max, dst_len = 0;
>   	u32 sample_num[3];
> +	unsigned long expires;
>
>   	/* There could be 1-3 1024 bytes URB frames */
>   	i_max = src_len / 1024;
> @@ -488,7 +495,8 @@ 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) {
> +	expires = s->jiffies_next + msecs_to_jiffies(10000);
> +	if (time_before_eq(expires, 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;
>

-- 
http://palosaari.fi/

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

* Re: [PATCH 1/1] staging: media: msi3101: sdr-msi3101.c - replace with time_before_eq()
  2014-06-29 19:17 ` Antti Palosaari
@ 2014-06-30  3:25   ` Anil Shashikumar Belur
  0 siblings, 0 replies; 3+ messages in thread
From: Anil Shashikumar Belur @ 2014-06-30  3:25 UTC (permalink / raw)
  To: Antti Palosaari; +Cc: m.chehab, gregkh, devel, linux-media, linux-kernel


On Monday 30 June 2014 12:47 AM, Antti Palosaari wrote:
> Moikka!
> That is already fixed by someone else and patch is somewhere Mauro or
> Hans queue.
>
> regards
> Antti
>
Moikka :)

Ah no worries - I could not find the changes with the latest updates.

Thanks

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

end of thread, other threads:[~2014-06-30  3:25 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-06-29  5:20 [PATCH 1/1] staging: media: msi3101: sdr-msi3101.c - replace with time_before_eq() Anil Belur
2014-06-29 19:17 ` Antti Palosaari
2014-06-30  3:25   ` Anil Shashikumar Belur

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