Linux laptop Discussion Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Wu Zhangjin <wuzhangjin@gmail.com>
To: Pavel Machek <pavel@ucw.cz>
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
Subject: Re: [PATCH v7 5/8] Loongson: YeeLoong: add hardware monitoring driver
Date: Sat, 05 Dec 2009 00:29:45 +0800	[thread overview]
Message-ID: <1259944185.9554.8.camel@falcon.domain.org> (raw)
In-Reply-To: <20091204080813.GB1540@ucw.cz>

On Fri, 2009-12-04 at 09:08 +0100, Pavel Machek wrote:
> Hi!
> 
> > +static int get_cpu_temp(void)
> > +{
> > +	int value;
> > +
> > +	value = ec_read(REG_TEMPERATURE_VALUE);
> > +
> > +	if (value & (1 << 7))
> > +		value = (value & 0x7f) - 128;
> > +	else
> > +		value = value & 0xff;
> 
> wtf?
> 
> Maybe value should be 's8'?
> 
> > +static int get_battery_current(void)
> > +{
> > +	int value;
> > +
> > +	value = (ec_read(REG_BAT_CURRENT_HIGH) << 8) |
> > +		(ec_read(REG_BAT_CURRENT_LOW));
> > +
> > +	if (value & 0x8000)
> > +		value = 0xffff - value;
> 
> Another version of  pair-complement conversion; this one is broken --
> off by 1.
> 
> > +static int parse_arg(const char *buf, unsigned long count, int *val)
> > +{
> > +	if (!count)
> > +		return 0;
> > +	if (sscanf(buf, "%i", val) != 1)
> > +		return -EINVAL;
> > +	return count;
> > +}
> 
> We have strict_strtoul for a reason...
> 

Done, thanks!

Regards,
	Wu Zhangjin

  reply	other threads:[~2009-12-04 16:29 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <cover.1259932036.git.wuzhangjin@gmail.com>
2009-12-04 13:34 ` [PATCH v7 4/8] Loongson: YeeLoong: add battery driver Wu Zhangjin
2009-12-04  8:04   ` Pavel Machek
2009-12-04 14:56     ` Wu Zhangjin
2009-12-08  6:57   ` Wu Zhangjin
2009-12-04 13:35 ` [PATCH v7 5/8] Loongson: YeeLoong: add hardware monitoring driver Wu Zhangjin
2009-12-04  8:08   ` Pavel Machek
2009-12-04 16:29     ` Wu Zhangjin [this message]
2009-12-04 13:36 ` [PATCH v7 6/8] Loongson: YeeLoong: add video output driver Wu Zhangjin
2009-12-04  8:11   ` Pavel Machek
2009-12-04 15:04     ` Wu Zhangjin
2009-12-08  6:54   ` Wu Zhangjin
2009-12-04 13:37 ` [PATCH v7 7/8] Loongson: YeeLoong: add suspend support Wu Zhangjin
2009-12-04 13:39 ` [PATCH v7 8/8] Loongson: YeeLoong: add input/hotkey driver Wu Zhangjin
2009-12-04  8:14   ` Pavel Machek
2009-12-04 14:57     ` 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=1259944185.9554.8.camel@falcon.domain.org \
    --to=wuzhangjin@gmail.com \
    --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=pavel@ucw.cz \
    --cc=ralf@linux-mips.org \
    --cc=rjw@sisk.pl \
    --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