2012-05-09 08:04:23

by Nikolaus Voss

[permalink] [raw]
Subject: [PATCH] drivers/power/sbs-battery.c: don't trigger false supply_changed event

power_supply_changed() events are triggerd based on the return value
of a get_property() call. However the property TECHNOLOGY is
hard-coded to LION in this driver, thus always succeeds.

So, with the battery removed, this triggers a false battery present
uevent. This uevent triggers a new query via power_supply_uevent()
which again starts to query all known properties and thus leads to
an infinite loop of battery present/not-present uevents.

This patch skips the battery presence detection for the hard-coded
property TECHNOLOGY.

Signed-off-by: Nikolaus Voss <[email protected]>
---
drivers/power/sbs-battery.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/power/sbs-battery.c b/drivers/power/sbs-battery.c
index 182d2ed..ef142f8 100644
--- a/drivers/power/sbs-battery.c
+++ b/drivers/power/sbs-battery.c
@@ -469,7 +469,7 @@ static int sbs_get_property(struct power_supply *psy,

case POWER_SUPPLY_PROP_TECHNOLOGY:
val->intval = POWER_SUPPLY_TECHNOLOGY_LION;
- break;
+ goto done; /* don't trigger power_supply_changed()! */

case POWER_SUPPLY_PROP_ENERGY_NOW:
case POWER_SUPPLY_PROP_ENERGY_FULL:
--
1.7.9.5


2012-05-09 14:51:17

by Rhyland Klein

[permalink] [raw]
Subject: RE: [PATCH] drivers/power/sbs-battery.c: don't trigger false supply_changed event

On Wed, 2012-05-09 at 2:31, Nikolaus Voss wrote:
>power_supply_changed() events are triggerd based on the return value
>of a get_property() call. However the property TECHNOLOGY is
>hard-coded to LION in this driver, thus always succeeds.
>
>So, with the battery removed, this triggers a false battery present
>uevent. This uevent triggers a new query via power_supply_uevent()
>which again starts to query all known properties and thus leads to
>an infinite loop of battery present/not-present uevents.
>
>This patch skips the battery presence detection for the hard-coded
>property TECHNOLOGY.
>
>Signed-off-by: Nikolaus Voss <[email protected]>

Acked-by Rhyland Klein <[email protected]>

--
nvpublic

2012-06-20 03:32:53

by Anton Vorontsov

[permalink] [raw]
Subject: Re: [PATCH] drivers/power/sbs-battery.c: don't trigger false supply_changed event

On Wed, May 09, 2012 at 07:51:05AM -0700, Rhyland Klein wrote:
> On Wed, 2012-05-09 at 2:31, Nikolaus Voss wrote:
> >power_supply_changed() events are triggerd based on the return value
> >of a get_property() call. However the property TECHNOLOGY is
> >hard-coded to LION in this driver, thus always succeeds.
> >
> >So, with the battery removed, this triggers a false battery present
> >uevent. This uevent triggers a new query via power_supply_uevent()
> >which again starts to query all known properties and thus leads to
> >an infinite loop of battery present/not-present uevents.
> >
> >This patch skips the battery presence detection for the hard-coded
> >property TECHNOLOGY.
> >
> >Signed-off-by: Nikolaus Voss <[email protected]>
>
> Acked-by Rhyland Klein <[email protected]>

Applied, thanks!

--
Anton Vorontsov
Email: [email protected]