linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Geoff Thorpe <Geoff.Thorpe@freescale.com>
To: Timur Tabi <timur@freescale.com>
Cc: linuxppc-dev@ozlabs.org, smaclennan@pikatech.com
Subject: Re: [PATCH 1/2 v8] powerpc: introduce macro spin_event_timeout()
Date: Tue, 26 May 2009 12:20:47 -0400	[thread overview]
Message-ID: <4A1C16DF.9090802@freescale.com> (raw)
In-Reply-To: <ed82fe3e0905252027y198e78ct821753acacb1bdb1@mail.gmail.com>

Timur Tabi wrote:
> On Mon, May 25, 2009 at 12:46 PM, Jon Smirl <jonsmirl@gmail.com> wrote:
> 
>> I just tried using this. The !rc has the effect of making the error
>> return be zero instead the normal not zero.
> 
> You're confused.  It's not a "return code", it's a return value.  I
> guess I should have called the parameter "ret" instead of "rc", but I
> didn't expect people to get confused.
> 
> 'rc' is the value of the expression when the loop terminates.  That's
> what makes the most sense, because the developer will want to know
> what that value is.  If you're expression happens to rely on negative
> logic (e.g. wait until a bit is cleared), then of course it's going to
> appear "backwards" when you test it.

I've just been going through some hassles associated with wait_event
variants and their return codes.

Eg. wait_event_interruptible()'s return value is documented as; "The
function will return -ERESTARTSYS if it was interrupted by a signal and
0 if @condition evaluated to true." And wait_event_timeout()'s return
value is; "The function returns 0 if the @timeout elapsed, and the
remaining jiffies if the condition evaluated to true before the timeout
elapsed."

In all cases it seems, they don't return the what the expression
evaluates to, but instead return an indication about the wait outcome.
This is why I've taken to doing things like;
   wait_event_***(queue, !(ret = try_something()));

So from this user's perspective (FWIW), it would come as a surprise if
the return value reflected the evaluated expression rather than what
happened w.r.t. the spin/timeout.

Cheers,
Geoff

  reply	other threads:[~2009-05-26 16:21 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-05-19 19:26 [PATCH 0/2] introduce macro spin_event_timeout() Timur Tabi
2009-05-19 19:26 ` [PATCH 1/2 v8] powerpc: " Timur Tabi
2009-05-19 19:26   ` [PATCH 2/2] qe: add polling timeout to qe_issue_cmd() Timur Tabi
2009-05-19 20:10     ` Grant Likely
2009-05-19 21:09       ` Timur Tabi
2009-05-25 17:46   ` [PATCH 1/2 v8] powerpc: introduce macro spin_event_timeout() Jon Smirl
2009-05-26  3:27     ` Timur Tabi
2009-05-26 16:20       ` Geoff Thorpe [this message]
2009-05-26 16:27         ` Jon Smirl
2009-05-26 17:03         ` Timur Tabi
2009-05-26 17:56           ` Jon Smirl
2009-05-26 18:01             ` Timur Tabi
2009-05-26 18:09           ` Geoff Thorpe
2009-05-26 18:17             ` Timur Tabi
2009-05-26 19:04               ` Jon Smirl

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=4A1C16DF.9090802@freescale.com \
    --to=geoff.thorpe@freescale.com \
    --cc=linuxppc-dev@ozlabs.org \
    --cc=smaclennan@pikatech.com \
    --cc=timur@freescale.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 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).