Messages in this thread | | | Date | Tue, 15 Feb 2011 13:48:28 +0200 | Subject | Re: [PATCH 07/14 v3] bq27x00: Cache battery registers | From | Grazvydas Ignotas <> |
| |
On Tue, Feb 15, 2011 at 12:14 AM, Lars-Peter Clausen <lars@metafoo.de> wrote: > On 02/14/2011 10:58 PM, Grazvydas Ignotas wrote: >> On Mon, Feb 14, 2011 at 5:01 AM, Lars-Peter Clausen <lars@metafoo.de> wrote: >>> >>> - ret = bq27x00_read(di, BQ27x00_REG_AI, &curr, false); >>> - if (ret) { >>> - dev_err(di->dev, "error reading current\n"); >>> - return 0; >>> - } >>> + if (di->chip == BQ27500) >>> + curr = bq27x00_read(di, BQ27x00_REG_AI, false); >>> + else >>> + curr = di->cache.current_now; >>> + >>> + if (curr < 0) >>> + return curr; >> >> This is wrong, as read function returns negative values for bq27500 >> when discharging. That's why read function used to pass value through >> argument before your series (return value was for error code). > > I don't think so. The register is 16bit wide and it is read as a unsigned. So > in the non error case bq27x00_read will always return >= 0. > The value is later reinterpreted as a signed 16bit.(See the other lines you > quoted underneath).
Hmh, right..
> Did you experience any actual problem with current being wrong?
Yes, the returned current values were randomly jumping between -500000 and 600000 while the device was discharging, so I thought uninitialized values were being returned (this never happened before the series; no errors in dmesg). I'll need to debug a bit more I guess.. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
| |