public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] bq27x00_battery: Do not report nominal available capaciy if battery is not calibrated
@ 2012-11-10 14:42 Pali Rohár
  2012-11-19  0:05 ` Anton Vorontsov
  0 siblings, 1 reply; 3+ messages in thread
From: Pali Rohár @ 2012-11-10 14:42 UTC (permalink / raw)
  To: linux-kernel; +Cc: Anton Vorontsov, David Woodhouse, Pali Rohár

Signed-off-by: Pali Rohár <pali.rohar@gmail.com>
---
 drivers/power/bq27x00_battery.c |    8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/drivers/power/bq27x00_battery.c b/drivers/power/bq27x00_battery.c
index 5860d4d..41b3328 100644
--- a/drivers/power/bq27x00_battery.c
+++ b/drivers/power/bq27x00_battery.c
@@ -230,6 +230,14 @@ static int bq27x00_battery_read_charge(struct bq27x00_device_info *di, u8 reg)
  */
 static inline int bq27x00_battery_read_nac(struct bq27x00_device_info *di)
 {
+	int flags;
+	bool is_bq27500 = di->chip == BQ27500;
+	bool is_higher = bq27xxx_is_chip_version_higher(di);
+
+	flags = bq27x00_read(di, BQ27x00_REG_FLAGS, !is_bq27500);
+	if (flags >= 0 && !is_higher && (flags & BQ27000_FLAG_CI))
+		return -ENODATA;
+
 	return bq27x00_battery_read_charge(di, BQ27x00_REG_NAC);
 }
 
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] bq27x00_battery: Do not report nominal available capaciy if battery is not calibrated
  2012-11-10 14:42 [PATCH] bq27x00_battery: Do not report nominal available capaciy if battery is not calibrated Pali Rohár
@ 2012-11-19  0:05 ` Anton Vorontsov
  2012-11-19 18:43   ` Pali Rohár
  0 siblings, 1 reply; 3+ messages in thread
From: Anton Vorontsov @ 2012-11-19  0:05 UTC (permalink / raw)
  To: Pali Rohár; +Cc: linux-kernel, David Woodhouse

On Sat, Nov 10, 2012 at 03:42:48PM +0100, Pali Rohár wrote:
> Signed-off-by: Pali Rohár <pali.rohar@gmail.com>
> ---
>  drivers/power/bq27x00_battery.c |    8 ++++++++
>  1 file changed, 8 insertions(+)

OK, I'm assuming we don't want this because otherwise we're getting bogus
values in the sysfs, and so we confuse userland. I added this explanation
to the commit message, but still would be great to hear some confirmation.

Anyways, this is applied now.

Thanks!

> diff --git a/drivers/power/bq27x00_battery.c b/drivers/power/bq27x00_battery.c
> index 5860d4d..41b3328 100644
> --- a/drivers/power/bq27x00_battery.c
> +++ b/drivers/power/bq27x00_battery.c
> @@ -230,6 +230,14 @@ static int bq27x00_battery_read_charge(struct bq27x00_device_info *di, u8 reg)
>   */
>  static inline int bq27x00_battery_read_nac(struct bq27x00_device_info *di)
>  {
> +	int flags;
> +	bool is_bq27500 = di->chip == BQ27500;
> +	bool is_higher = bq27xxx_is_chip_version_higher(di);
> +
> +	flags = bq27x00_read(di, BQ27x00_REG_FLAGS, !is_bq27500);
> +	if (flags >= 0 && !is_higher && (flags & BQ27000_FLAG_CI))
> +		return -ENODATA;
> +
>  	return bq27x00_battery_read_charge(di, BQ27x00_REG_NAC);
>  }
>  
> -- 
> 1.7.10.4

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] bq27x00_battery: Do not report nominal available capaciy if battery is not calibrated
  2012-11-19  0:05 ` Anton Vorontsov
@ 2012-11-19 18:43   ` Pali Rohár
  0 siblings, 0 replies; 3+ messages in thread
From: Pali Rohár @ 2012-11-19 18:43 UTC (permalink / raw)
  To: Anton Vorontsov; +Cc: linux-kernel, David Woodhouse

[-- Attachment #1: Type: text/plain, Size: 631 bytes --]

On Sunday 18 November 2012 16:05:52 Anton Vorontsov wrote:
> On Sat, Nov 10, 2012 at 03:42:48PM +0100, Pali Rohár wrote:
> > Signed-off-by: Pali Rohár <pali.rohar@gmail.com>
> > ---
> > 
> >  drivers/power/bq27x00_battery.c |    8 ++++++++
> >  1 file changed, 8 insertions(+)
> 
> OK, I'm assuming we don't want this because otherwise we're
> getting bogus values in the sysfs, and so we confuse userland.
> I added this explanation to the commit message, but still
> would be great to hear some confirmation.
> 
> Anyways, this is applied now.
> 
> Thanks!
> 

Right.

-- 
Pali Rohár
pali.rohar@gmail.com

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2012-11-19 18:43 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-11-10 14:42 [PATCH] bq27x00_battery: Do not report nominal available capaciy if battery is not calibrated Pali Rohár
2012-11-19  0:05 ` Anton Vorontsov
2012-11-19 18:43   ` Pali Rohár

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox