linux-mips.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Pavel Machek <pavel@ucw.cz>
To: Wu Zhangjin <wuzhangjin@gmail.com>
Cc: Ralf Baechle <ralf@linux-mips.org>,
	akpm@linux-foundation.org, linux-mips@linux-mips.org,
	linux-kernel@vger.kernel.org,
	Dmitry Torokhov <dmitry.torokhov@gmail.com>,
	"Rafael J . Wysocki" <rjw@sisk.pl>,
	zhangfx@lemote.com, linux-laptop@vger.kernel.org,
	Stephen Rothwell <sfr@canb.auug.org.au>
Subject: Re: [PATCH v8 5/8] Loongson: YeeLoong: add hardware monitoring driver
Date: Mon, 7 Dec 2009 10:49:10 +0100	[thread overview]
Message-ID: <20091207094909.GD23088@elf.ucw.cz> (raw)
In-Reply-To: <1260178870.9092.34.camel@falcon.domain.org>

On Mon 2009-12-07 17:41:10, Wu Zhangjin wrote:
> On Mon, 2009-12-07 at 09:04 +0100, Pavel Machek wrote:
> > > > What is going on here? I thought the value is already in two's
> > > > complement... Is the above equivalent of
> > > > 
> > > > 	      if (value < 0)
> > > > 	      	 value = -value; 
> > > > 
> > > > ? If so, why? If not, can you add a comment?
> > > 
> > > Right, then, will use this instead:
> > > 
> > > static int get_battery_current(void)
> > > { 
> > > 	s16 value;
> > > 
> > > 	value = (ec_read(REG_BAT_CURRENT_HIGH) << 8) |
> > > 		(ec_read(REG_BAT_CURRENT_LOW));
> > > 
> > > 	return abs(value);
> > > }
> > 
> > That's certainly better. But... why not return signed value? Current
> > flowing from the battery is certainly very different from current
> > flowing into it...
> 
> You are totally right ;)
> 
> Just test it, when flowing from the battery, the value is negative, and
> when flowing into the battery, the value is positive, so, no abs()
> needed. thanks!

Make it return -value, then. I believe other code uses >0 values for
discharge.
									Pavel

-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

  reply	other threads:[~2009-12-07  9:49 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-12-06  7:01 [PATCH v8 0/8] Loongson: YeeLoong: add platform drivers Wu Zhangjin
2009-12-06  7:01 ` [PATCH v8 1/8] MIPS: add subdirectory for platform extension drivers Wu Zhangjin
2009-12-08  7:37   ` Wu Zhangjin
2009-12-06  7:01 ` [PATCH v8 2/8] Loongson: YeeLoong: add platform driver Wu Zhangjin
2009-12-06  7:01 ` [PATCH v8 3/8] Loongson: YeeLoong: add backlight driver Wu Zhangjin
2009-12-08  7:52   ` Wu Zhangjin
2009-12-06  7:01 ` [PATCH v8 4/8] Loongson: YeeLoong: add battery driver Wu Zhangjin
2009-12-06  7:01 ` [PATCH v8 5/8] Loongson: YeeLoong: add hardware monitoring driver Wu Zhangjin
2009-12-06  8:47   ` Pavel Machek
2009-12-07  0:54     ` Wu Zhangjin
2009-12-07  8:04       ` Pavel Machek
2009-12-07  9:41         ` Wu Zhangjin
2009-12-07  9:49           ` Pavel Machek [this message]
2009-12-07 11:01             ` Wu Zhangjin
2009-12-08  7:09               ` Pavel Machek
2009-12-08  7:26                 ` Wu Zhangjin
2009-12-08  6:50             ` Wu Zhangjin
2009-12-08  7:06               ` Pavel Machek
2009-12-08  7:18                 ` Wu Zhangjin
2009-12-06  7:01 ` [PATCH v8 6/8] Loongson: YeeLoong: add video output driver Wu Zhangjin
2009-12-06  7:01 ` [PATCH v8 7/8] Loongson: YeeLoong: add suspend support Wu Zhangjin
2009-12-06  7:01 ` [PATCH v8 8/8] Loongson: YeeLoong: add input/hotkey driver Wu Zhangjin
2009-12-07  6:48   ` Dmitry Torokhov
2009-12-07  7:26     ` Wu Zhangjin
2009-12-08  6:52     ` Wu Zhangjin
2009-12-08  7:23       ` Dmitry Torokhov
2009-12-08  7:34         ` Wu Zhangjin

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=20091207094909.GD23088@elf.ucw.cz \
    --to=pavel@ucw.cz \
    --cc=akpm@linux-foundation.org \
    --cc=dmitry.torokhov@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-laptop@vger.kernel.org \
    --cc=linux-mips@linux-mips.org \
    --cc=ralf@linux-mips.org \
    --cc=rjw@sisk.pl \
    --cc=sfr@canb.auug.org.au \
    --cc=wuzhangjin@gmail.com \
    --cc=zhangfx@lemote.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).