public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Anton Vorontsov <avorontsov@ru.mvista.com>
To: Andres Salomon <dilinger@collabora.co.uk>
Cc: cbou@mail.ru, dwmw2@infradead.org, linux-kernel@vger.kernel.org,
	richard@laptop.org, Andrew Morton <akpm@linux-foundation.org>,
	Paul Fox <pgf@laptop.org>,
	dsaxena@laptop.org
Subject: Re: [PATCH 2/5] power_supply: fix up olpc_battery's eeprom read function
Date: Wed, 1 Jul 2009 02:57:52 +0400	[thread overview]
Message-ID: <20090630225752.GA12076@oksana.dev.rtsoft.ru> (raw)
In-Reply-To: <20090630021400.6a9f2482@mycelium.queued.net>

On Tue, Jun 30, 2009 at 02:14:00AM -0400, Andres Salomon wrote:
> 
> The eeprom read function was placing values into the wrong place in
> 'buf'; we were starting from buf[off], rather than buf[0].
> 
> Also, the for loop that we were using was much uglier than it needed to
> be.  This cleans it up a bit.
> 
> Signed-off-by: Andres Salomon <dilinger@collabora.co.uk>

Applied to battery-2.6.31.git w/ some cosmtic changes.
Please ensure that everything is OK.

Thanks!

> ---
>  drivers/power/olpc_battery.c |   14 ++++++--------
>  1 files changed, 6 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/power/olpc_battery.c b/drivers/power/olpc_battery.c
> index 0d1928d..d2df0db 100644
> --- a/drivers/power/olpc_battery.c
> +++ b/drivers/power/olpc_battery.c
> @@ -343,21 +343,19 @@ static ssize_t olpc_bat_eeprom_read(struct kobject *kobj,
>  		struct bin_attribute *attr, char *buf, loff_t off, size_t count)
>  {
>  	uint8_t ec_byte;
> -	int ret, end;
> +	int ret, i;
>  
>  	if (off >= EEPROM_SIZE)
>  		return 0;
>  	if (off + count > EEPROM_SIZE)
>  		count = EEPROM_SIZE - off;
>  
> -	end = EEPROM_START + off + count;
> -	for (ec_byte = EEPROM_START + off; ec_byte < end; ec_byte++) {
> -		ret = olpc_ec_cmd(EC_BAT_EEPROM, &ec_byte, 1,
> -				&buf[ec_byte - EEPROM_START], 1);
> +	for (i = 0; i < count; i++) {
> +		ec_byte = EEPROM_START + off + i;
> +		ret = olpc_ec_cmd(EC_BAT_EEPROM, &ec_byte, 1, &buf[i], 1);
>  		if (ret) {
> -			printk(KERN_ERR "olpc-battery:  EC command "
> -					"EC_BAT_EEPROM @ 0x%x failed -"
> -					" %d!\n", ec_byte, ret);
> +			printk(KERN_ERR "olpc-battery:  EC_BAT_EEPROM cmd @ 0x%x failed - %d!\n",
> +					ec_byte, ret);
>  			return -EIO;
>  		}
>  	}
> -- 
> 1.5.6.5
> 

-- 
Anton Vorontsov
email: cbouatmailru@gmail.com
irc://irc.freenode.net/bd2

      reply	other threads:[~2009-06-30 22:57 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-06-30  6:14 [PATCH 2/5] power_supply: fix up olpc_battery's eeprom read function Andres Salomon
2009-06-30 22:57 ` Anton Vorontsov [this message]

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=20090630225752.GA12076@oksana.dev.rtsoft.ru \
    --to=avorontsov@ru.mvista.com \
    --cc=akpm@linux-foundation.org \
    --cc=cbou@mail.ru \
    --cc=dilinger@collabora.co.uk \
    --cc=dsaxena@laptop.org \
    --cc=dwmw2@infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pgf@laptop.org \
    --cc=richard@laptop.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