From: Antti Palosaari <crope@iki.fi>
To: Anil Belur <askb23@gmail.com>,
m.chehab@samsung.com, gregkh@linuxfoundation.org
Cc: devel@driverdev.osuosl.org, linux-media@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/1] staging: media: msi3101: sdr-msi3101.c - replace with time_before_eq()
Date: Sun, 29 Jun 2014 22:17:15 +0300 [thread overview]
Message-ID: <53B0663B.9080806@iki.fi> (raw)
In-Reply-To: <1404019216-4726-1-git-send-email-askb23@gmail.com>
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/
next prev parent reply other threads:[~2014-06-29 19:17 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
2014-06-30 3:25 ` Anil Shashikumar Belur
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=53B0663B.9080806@iki.fi \
--to=crope@iki.fi \
--cc=askb23@gmail.com \
--cc=devel@driverdev.osuosl.org \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=m.chehab@samsung.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.