public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] USB: image: use msecs_to_jiffies for time conversion
@ 2015-02-06  9:50 Nicholas Mc Guire
  2015-02-06 12:27 ` Sergei Shtylyov
  0 siblings, 1 reply; 4+ messages in thread
From: Nicholas Mc Guire @ 2015-02-06  9:50 UTC (permalink / raw)
  To: Greg Kroah-Hartman, linux-usb, linux-kernel; +Cc: Nicholas Mc Guire

This is only an API consolidation and should make things more readable
it replaces var * HZ / 1000 by msecs_to_jiffies(var).

Signed-off-by: Nicholas Mc Guire <hofrat@osadl.org>
---

Note that the indentation is not aligned with the correct ( here due to
lines going over 80 char - not sure if this is the right way to resolve
this (this file has quite a few coding style issues).

Patch was only compile tested with x86_64_defconfig + CONFIG_USB_MDC800=m

Patch is against 3.19.0-rc7 (localversion-next is -next-20150204)

 drivers/usb/image/mdc800.c |   11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/image/mdc800.c b/drivers/usb/image/mdc800.c
index a62865a..3a72e8f 100644
--- a/drivers/usb/image/mdc800.c
+++ b/drivers/usb/image/mdc800.c
@@ -347,7 +347,8 @@ static int mdc800_usb_waitForIRQ (int mode, int msec)
 {
 	mdc800->camera_request_ready=1+mode;
 
-	wait_event_timeout(mdc800->irq_wait, mdc800->irq_woken, msec*HZ/1000);
+	wait_event_timeout(mdc800->irq_wait, mdc800->irq_woken,
+			   msecs_to_jiffies(msec));
 	mdc800->irq_woken = 0;
 
 	if (mdc800->camera_request_ready>0)
@@ -743,8 +744,9 @@ static ssize_t mdc800_device_read (struct file *file, char __user *buf, size_t l
 					mutex_unlock(&mdc800->io_lock);
 					return len-left;
 				}
-				wait_event_timeout(mdc800->download_wait, mdc800->downloaded,
-										TO_DOWNLOAD_GET_READY*HZ/1000);
+				wait_event_timeout(mdc800->download_wait,
+				     mdc800->downloaded,
+				     msecs_to_jiffies(TO_DOWNLOAD_GET_READY));
 				mdc800->downloaded = 0;
 				if (mdc800->download_urb->status != 0)
 				{
@@ -867,7 +869,8 @@ static ssize_t mdc800_device_write (struct file *file, const char __user *buf, s
 				mutex_unlock(&mdc800->io_lock);
 				return -EIO;
 			}
-			wait_event_timeout(mdc800->write_wait, mdc800->written, TO_WRITE_GET_READY*HZ/1000);
+			wait_event_timeout(mdc800->write_wait, mdc800->written,
+					msecs_to_jiffies(TO_WRITE_GET_READY));
 			mdc800->written = 0;
 			if (mdc800->state == WORKING)
 			{
-- 
1.7.10.4


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

* Re: [PATCH] USB: image: use msecs_to_jiffies for time conversion
  2015-02-06  9:50 [PATCH] USB: image: use msecs_to_jiffies for time conversion Nicholas Mc Guire
@ 2015-02-06 12:27 ` Sergei Shtylyov
  2015-02-06 13:36   ` Nicholas Mc Guire
  0 siblings, 1 reply; 4+ messages in thread
From: Sergei Shtylyov @ 2015-02-06 12:27 UTC (permalink / raw)
  To: Nicholas Mc Guire, Greg Kroah-Hartman, linux-usb, linux-kernel

Hello.

On 2/6/2015 12:50 PM, Nicholas Mc Guire wrote:

> This is only an API consolidation and should make things more readable
> it replaces var * HZ / 1000 by msecs_to_jiffies(var).

> Signed-off-by: Nicholas Mc Guire <hofrat@osadl.org>
> ---

> Note that the indentation is not aligned with the correct ( here due to
> lines going over 80 char - not sure if this is the right way to resolve
> this (this file has quite a few coding style issues).

> Patch was only compile tested with x86_64_defconfig + CONFIG_USB_MDC800=m

> Patch is against 3.19.0-rc7 (localversion-next is -next-20150204)

>   drivers/usb/image/mdc800.c |   11 +++++++----
>   1 file changed, 7 insertions(+), 4 deletions(-)

> diff --git a/drivers/usb/image/mdc800.c b/drivers/usb/image/mdc800.c
> index a62865a..3a72e8f 100644
> --- a/drivers/usb/image/mdc800.c
> +++ b/drivers/usb/image/mdc800.c
[...]
> @@ -743,8 +744,9 @@ static ssize_t mdc800_device_read (struct file *file, char __user *buf, size_t l
>   					mutex_unlock(&mdc800->io_lock);
>   					return len-left;
>   				}
> -				wait_event_timeout(mdc800->download_wait, mdc800->downloaded,
> -										TO_DOWNLOAD_GET_READY*HZ/1000);
> +				wait_event_timeout(mdc800->download_wait,
> +				     mdc800->downloaded,
> +				     msecs_to_jiffies(TO_DOWNLOAD_GET_READY));

    Don't indent with spaces (you're not aligning to open paren anyway), use 
the final tab instead, please.

WBR, Sergei


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

* Re: [PATCH] USB: image: use msecs_to_jiffies for time conversion
  2015-02-06 12:27 ` Sergei Shtylyov
@ 2015-02-06 13:36   ` Nicholas Mc Guire
  2015-02-06 13:43     ` Sergei Shtylyov
  0 siblings, 1 reply; 4+ messages in thread
From: Nicholas Mc Guire @ 2015-02-06 13:36 UTC (permalink / raw)
  To: Sergei Shtylyov
  Cc: Nicholas Mc Guire, Greg Kroah-Hartman, linux-usb, linux-kernel

On Fri, 06 Feb 2015, Sergei Shtylyov wrote:

> Hello.
>
> On 2/6/2015 12:50 PM, Nicholas Mc Guire wrote:
>
>> This is only an API consolidation and should make things more readable
>> it replaces var * HZ / 1000 by msecs_to_jiffies(var).
>
>> Signed-off-by: Nicholas Mc Guire <hofrat@osadl.org>
>> ---
>
>> Note that the indentation is not aligned with the correct ( here due to
>> lines going over 80 char - not sure if this is the right way to resolve
>> this (this file has quite a few coding style issues).
>
>> Patch was only compile tested with x86_64_defconfig + CONFIG_USB_MDC800=m
>
>> Patch is against 3.19.0-rc7 (localversion-next is -next-20150204)
>
>>   drivers/usb/image/mdc800.c |   11 +++++++----
>>   1 file changed, 7 insertions(+), 4 deletions(-)
>
>> diff --git a/drivers/usb/image/mdc800.c b/drivers/usb/image/mdc800.c
>> index a62865a..3a72e8f 100644
>> --- a/drivers/usb/image/mdc800.c
>> +++ b/drivers/usb/image/mdc800.c
> [...]
>> @@ -743,8 +744,9 @@ static ssize_t mdc800_device_read (struct file *file, char __user *buf, size_t l
>>   					mutex_unlock(&mdc800->io_lock);
>>   					return len-left;
>>   				}
>> -				wait_event_timeout(mdc800->download_wait, mdc800->downloaded,
>> -										TO_DOWNLOAD_GET_READY*HZ/1000);
>> +				wait_event_timeout(mdc800->download_wait,
>> +				     mdc800->downloaded,
>> +				     msecs_to_jiffies(TO_DOWNLOAD_GET_READY));
>
>    Don't indent with spaces (you're not aligning to open paren anyway), 
> use the final tab instead, please.
>
thanks ! In the diff output that problem is actually not well visible.
was not really clear on how to do this properly - the problem with 
using the last tab stop is that you then get the following code

                                wait_event_timeout(mdc800->download_wait,
                                mdc800->downloaded,
                                msecs_to_jiffies(TO_DOWNLOAD_GET_READY));
                                mdc800->downloaded = 0;

which semed really bad and 
                                
				wait_event_timeout(mdc800->download_wait,
                                     mdc800->downloaded,
                                     msecs_to_jiffies(TO_DOWNLOAD_GET_READY));
                                mdc800->downloaded = 0;

makes it atleast somewhat readable. If I indent a full tab ghen it goes over
80 char.

So in this case - should one use the last tab-stop anyway ?

thx!
hofrat

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

* Re: [PATCH] USB: image: use msecs_to_jiffies for time conversion
  2015-02-06 13:36   ` Nicholas Mc Guire
@ 2015-02-06 13:43     ` Sergei Shtylyov
  0 siblings, 0 replies; 4+ messages in thread
From: Sergei Shtylyov @ 2015-02-06 13:43 UTC (permalink / raw)
  To: Nicholas Mc Guire
  Cc: Nicholas Mc Guire, Greg Kroah-Hartman, linux-usb, linux-kernel

On 2/6/2015 4:36 PM, Nicholas Mc Guire wrote:

>>> This is only an API consolidation and should make things more readable
>>> it replaces var * HZ / 1000 by msecs_to_jiffies(var).

>>> Signed-off-by: Nicholas Mc Guire <hofrat@osadl.org>
>>> ---

>>> Note that the indentation is not aligned with the correct ( here due to
>>> lines going over 80 char - not sure if this is the right way to resolve
>>> this (this file has quite a few coding style issues).

>>> Patch was only compile tested with x86_64_defconfig + CONFIG_USB_MDC800=m

>>> Patch is against 3.19.0-rc7 (localversion-next is -next-20150204)

>>>    drivers/usb/image/mdc800.c |   11 +++++++----
>>>    1 file changed, 7 insertions(+), 4 deletions(-)

>>> diff --git a/drivers/usb/image/mdc800.c b/drivers/usb/image/mdc800.c
>>> index a62865a..3a72e8f 100644
>>> --- a/drivers/usb/image/mdc800.c
>>> +++ b/drivers/usb/image/mdc800.c
>> [...]
>>> @@ -743,8 +744,9 @@ static ssize_t mdc800_device_read (struct file *file, char __user *buf, size_t l
>>>    					mutex_unlock(&mdc800->io_lock);
>>>    					return len-left;
>>>    				}
>>> -				wait_event_timeout(mdc800->download_wait, mdc800->downloaded,
>>> -										TO_DOWNLOAD_GET_READY*HZ/1000);
>>> +				wait_event_timeout(mdc800->download_wait,
>>> +				     mdc800->downloaded,
>>> +				     msecs_to_jiffies(TO_DOWNLOAD_GET_READY));

>>     Don't indent with spaces (you're not aligning to open paren anyway),
>> use the final tab instead, please.

> thanks ! In the diff output that problem is actually not well visible.
> was not really clear on how to do this properly - the problem with
> using the last tab stop is that you then get the following code

>                                  wait_event_timeout(mdc800->download_wait,
>                                  mdc800->downloaded,
>                                  msecs_to_jiffies(TO_DOWNLOAD_GET_READY));
>                                  mdc800->downloaded = 0;

> which semed really bad and

    Yes, it's horrible.

> 				wait_event_timeout(mdc800->download_wait,
>                                       mdc800->downloaded,
>                                       msecs_to_jiffies(TO_DOWNLOAD_GET_READY));
>                                  mdc800->downloaded = 0;

> makes it atleast somewhat readable. If I indent a full tab ghen it goes over
> 80 char.

    Ah, I didn't realize that, sorry.

> So in this case - should one use the last tab-stop anyway ?

    Probably not.

> thx!
> hofrat

WBR, Sergei


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

end of thread, other threads:[~2015-02-06 13:43 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-02-06  9:50 [PATCH] USB: image: use msecs_to_jiffies for time conversion Nicholas Mc Guire
2015-02-06 12:27 ` Sergei Shtylyov
2015-02-06 13:36   ` Nicholas Mc Guire
2015-02-06 13:43     ` Sergei Shtylyov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox