linux-ide.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] libata: fixup return type of wait_for_completion_timeout
@ 2015-02-10  8:39 Nicholas Mc Guire
  2015-02-10 14:53 ` Tejun Heo
  0 siblings, 1 reply; 5+ messages in thread
From: Nicholas Mc Guire @ 2015-02-10  8:39 UTC (permalink / raw)
  To: Tejun Heo; +Cc: linux-ide, linux-kernel, Nicholas Mc Guire

return type of wait_for_completion_timeout is unsigned long not int. The
return variable is renamed to reflect its use and the type adjusted to
unsigned long.

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

Patch was only compile tested with x86_64_defconfig (implies CONFIG_ATA=y)

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

 drivers/ata/libata-core.c |    7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
index 4c35f08..bddf8b6 100644
--- a/drivers/ata/libata-core.c
+++ b/drivers/ata/libata-core.c
@@ -1563,7 +1563,7 @@ unsigned ata_exec_internal_sg(struct ata_device *dev,
 	DECLARE_COMPLETION_ONSTACK(wait);
 	unsigned long flags;
 	unsigned int err_mask;
-	int rc;
+	unsigned long irq_timeout;
 
 	spin_lock_irqsave(ap->lock, flags);
 
@@ -1644,14 +1644,15 @@ unsigned ata_exec_internal_sg(struct ata_device *dev,
 	if (ap->ops->error_handler)
 		ata_eh_release(ap);
 
-	rc = wait_for_completion_timeout(&wait, msecs_to_jiffies(timeout));
+	irq_timeout = wait_for_completion_timeout(&wait,
+					      msecs_to_jiffies(timeout));
 
 	if (ap->ops->error_handler)
 		ata_eh_acquire(ap);
 
 	ata_sff_flush_pio_task(ap);
 
-	if (!rc) {
+	if (irq_timeout == 0) {
 		spin_lock_irqsave(ap->lock, flags);
 
 		/* We're racing with irq here.  If we lose, the
-- 
1.7.10.4


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

* Re: [PATCH] libata: fixup return type of wait_for_completion_timeout
  2015-02-10  8:39 [PATCH] libata: fixup return type of wait_for_completion_timeout Nicholas Mc Guire
@ 2015-02-10 14:53 ` Tejun Heo
  2015-02-10 15:55   ` Nicholas Mc Guire
  0 siblings, 1 reply; 5+ messages in thread
From: Tejun Heo @ 2015-02-10 14:53 UTC (permalink / raw)
  To: Nicholas Mc Guire; +Cc: linux-ide, linux-kernel

On Tue, Feb 10, 2015 at 03:39:36AM -0500, Nicholas Mc Guire wrote:
> -	if (!rc) {
> +	if (irq_timeout == 0) {

Why == 0 tho?  This always bothers me.  To match this style, we'd use
!= 0 to test the other direction.  In what way is "if (ret != 0)"
better than "if (ret)"?  We're negating the two tests needlessly.

Thanks.

-- 
tejun

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

* Re: [PATCH] libata: fixup return type of wait_for_completion_timeout
  2015-02-10 14:53 ` Tejun Heo
@ 2015-02-10 15:55   ` Nicholas Mc Guire
  2015-02-10 15:56     ` Tejun Heo
  2015-02-10 16:38     ` Sergei Shtylyov
  0 siblings, 2 replies; 5+ messages in thread
From: Nicholas Mc Guire @ 2015-02-10 15:55 UTC (permalink / raw)
  To: Tejun Heo; +Cc: Nicholas Mc Guire, linux-ide, linux-kernel

On Tue, 10 Feb 2015, Tejun Heo wrote:

> On Tue, Feb 10, 2015 at 03:39:36AM -0500, Nicholas Mc Guire wrote:
> > -	if (!rc) {
> > +	if (irq_timeout == 0) {
> 
> Why == 0 tho?  This always bothers me.  To match this style, we'd use
> != 0 to test the other direction.  In what way is "if (ret != 0)"
> better than "if (ret)"?  We're negating the two tests needlessly.
>
The == 0 seemed better to me than ! here because it would read

  if (not irq_timeout) {

while it actually did time out - but this could be resolved by renaming
irq_timeout to time_left (as was suggested by Sergei Shtylyov
<sergei.shtylyov@cogentembedded.com> for a similar patch) and then it 
would read:

   if (time_left == 0) {

which would nicely describe the timeout state.

if that addresses your concerns then I'll fix it up and repost.

thx!
hofrat

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

* Re: [PATCH] libata: fixup return type of wait_for_completion_timeout
  2015-02-10 15:55   ` Nicholas Mc Guire
@ 2015-02-10 15:56     ` Tejun Heo
  2015-02-10 16:38     ` Sergei Shtylyov
  1 sibling, 0 replies; 5+ messages in thread
From: Tejun Heo @ 2015-02-10 15:56 UTC (permalink / raw)
  To: Nicholas Mc Guire; +Cc: Nicholas Mc Guire, linux-ide, linux-kernel

On Tue, Feb 10, 2015 at 04:55:17PM +0100, Nicholas Mc Guire wrote:
> On Tue, 10 Feb 2015, Tejun Heo wrote:
> 
> > On Tue, Feb 10, 2015 at 03:39:36AM -0500, Nicholas Mc Guire wrote:
> > > -	if (!rc) {
> > > +	if (irq_timeout == 0) {
> > 
> > Why == 0 tho?  This always bothers me.  To match this style, we'd use
> > != 0 to test the other direction.  In what way is "if (ret != 0)"
> > better than "if (ret)"?  We're negating the two tests needlessly.
> >
> The == 0 seemed better to me than ! here because it would read
> 
>   if (not irq_timeout) {
> 
> while it actually did time out - but this could be resolved by renaming
> irq_timeout to time_left (as was suggested by Sergei Shtylyov
> <sergei.shtylyov@cogentembedded.com> for a similar patch) and then it 
> would read:
> 
>    if (time_left == 0) {
> 
> which would nicely describe the timeout state.
> 
> if that addresses your concerns then I'll fix it up and repost.

Plesae just do !

Thanks.

-- 
tejun

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

* Re: [PATCH] libata: fixup return type of wait_for_completion_timeout
  2015-02-10 15:55   ` Nicholas Mc Guire
  2015-02-10 15:56     ` Tejun Heo
@ 2015-02-10 16:38     ` Sergei Shtylyov
  1 sibling, 0 replies; 5+ messages in thread
From: Sergei Shtylyov @ 2015-02-10 16:38 UTC (permalink / raw)
  To: Nicholas Mc Guire, Tejun Heo; +Cc: Nicholas Mc Guire, linux-ide, linux-kernel

On 02/10/2015 06:55 PM, Nicholas Mc Guire wrote:

>> On Tue, Feb 10, 2015 at 03:39:36AM -0500, Nicholas Mc Guire wrote:
>>> -	if (!rc) {
>>> +	if (irq_timeout == 0) {

>> Why == 0 tho?  This always bothers me.  To match this style, we'd use
>> != 0 to test the other direction.  In what way is "if (ret != 0)"
>> better than "if (ret)"?  We're negating the two tests needlessly.

> The == 0 seemed better to me than ! here because it would read

>    if (not irq_timeout) {

    No, 'irq_timeout  == 0' isn't really better.

> while it actually did time out - but this could be resolved by renaming
> irq_timeout to time_left (as was suggested by Sergei Shtylyov
> <sergei.shtylyov@cogentembedded.com> for a similar patch) and then it
> would read:

>     if (time_left == 0) {

> which would nicely describe the timeout state.

    '!time_left' also would.

> if that addresses your concerns then I'll fix it up and repost.

> thx!
> hofrat

MBR, Sergei

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

end of thread, other threads:[~2015-02-10 16:38 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-02-10  8:39 [PATCH] libata: fixup return type of wait_for_completion_timeout Nicholas Mc Guire
2015-02-10 14:53 ` Tejun Heo
2015-02-10 15:55   ` Nicholas Mc Guire
2015-02-10 15:56     ` Tejun Heo
2015-02-10 16:38     ` Sergei Shtylyov

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