linux-omap.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Tomi Valkeinen <tomi.valkeinen@ti.com>
To: Kevin Hilman <khilman@ti.com>
Cc: linux-omap@vger.kernel.org
Subject: Re: context_loss_count error value
Date: Thu, 26 May 2011 08:55:15 +0300	[thread overview]
Message-ID: <1306389315.1922.4.camel@deskari> (raw)
In-Reply-To: <87tycitteb.fsf@ti.com>

On Wed, 2011-05-25 at 13:30 -0700, Kevin Hilman wrote:
> Tomi Valkeinen <tomi.valkeinen@ti.com> writes:
> 
> > On Wed, 2011-05-25 at 11:34 -0700, Kevin Hilman wrote:
> >> Tomi Valkeinen <tomi.valkeinen@ti.com> writes:

<snip>

> >> 
> >> > +		if (off_mode_enabled) {
> >> > +			count = (count + 1) & 0x7fffffff;
> >> > +			dummy_context_loss_counter = count;
> >> > +		}
> >> 
> >> Again, I don't think this masking is needed.   count is already an
> >> 'int', so when it gets bigger than INT_MAX, it will wrap.
> >
> > When count is INT_MAX and one is added to it, it'll wrap to INT_MIN,
> > i.e. maximum negative value, which would be an error value. So by
> > masking out the highest bit we'll get nonnegative count range from 0 to
> > INT_MAX.
> >
> > Perhaps a comment would be justified here =).
> 
> Indeed, and using INT_MAX instead of the hard-coded constants would help
> readability also.

It may be just me, but as I see it, INT_MAX is a number like any other,
and using it as a mask feels confusing to me.

Would this be ok to you:

/*
 * Context loss count has to be a non-negative value. Clear the sign
 * bit to get a value range from 0 to INT_MAX.
 */
count &= ~(1 << 31);

 Tomi



  reply	other threads:[~2011-05-26  5:55 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-05-18  7:40 context_loss_count error value Tomi Valkeinen
2011-05-18 10:50 ` Kevin Hilman
2011-05-18 11:33   ` Tomi Valkeinen
2011-05-18 14:24     ` Kevin Hilman
2011-05-18 14:41       ` Tomi Valkeinen
2011-05-24 15:47         ` Tomi Valkeinen
2011-05-24 23:45           ` Kevin Hilman
2011-05-25  6:05             ` Tomi Valkeinen
2011-05-25  8:31             ` Tomi Valkeinen
2011-05-25 18:34               ` Kevin Hilman
2011-05-25 18:45                 ` Tomi Valkeinen
2011-05-25 20:30                   ` Kevin Hilman
2011-05-26  5:55                     ` Tomi Valkeinen [this message]
2011-05-26 15:56                       ` Kevin Hilman

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=1306389315.1922.4.camel@deskari \
    --to=tomi.valkeinen@ti.com \
    --cc=khilman@ti.com \
    --cc=linux-omap@vger.kernel.org \
    /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).