* [PATCH 2/2] ACPI battery: update battery status first when querying from sysfs
@ 2010-11-02 3:24 Zhang Rui
2010-11-02 4:13 ` Seblu
0 siblings, 1 reply; 4+ messages in thread
From: Zhang Rui @ 2010-11-02 3:24 UTC (permalink / raw)
To: Brown, Len; +Cc: linux-acpi@vger.kernel.org, cbou, seblu, Zhang, Rui
Sometimes the Battery driver doesn't get notifications when it's
plugged/unplugged. And this results in the incorrect Battery
status reported by the power supply sysfs I/F.
Update the Battery status first when querying from sysfs.
Signed-off-by: Zhang Rui <rui.zhang@intel.com>
---
drivers/acpi/battery.c | 3 +++
1 file changed, 3 insertions(+)
Index: linux-2.6/drivers/acpi/battery.c
===================================================================
--- linux-2.6.orig/drivers/acpi/battery.c
+++ linux-2.6/drivers/acpi/battery.c
@@ -184,6 +184,9 @@ static int acpi_battery_get_property(str
int ret = 0;
struct acpi_battery *battery = to_acpi_battery(psy);
+ if (acpi_battery_update(battery))
+ return -ENODEV;
+
if (acpi_battery_present(battery)) {
/* run battery update only if it is present */
acpi_battery_get_state(battery);
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH 2/2] ACPI battery: update battery status first when querying from sysfs 2010-11-02 3:24 [PATCH 2/2] ACPI battery: update battery status first when querying from sysfs Zhang Rui @ 2010-11-02 4:13 ` Seblu 2010-11-02 5:22 ` Zhang Rui 0 siblings, 1 reply; 4+ messages in thread From: Seblu @ 2010-11-02 4:13 UTC (permalink / raw) To: Zhang Rui; +Cc: Brown, Len, linux-acpi@vger.kernel.org, cbou On Tue, Nov 2, 2010 at 4:24 AM, Zhang Rui <rui.zhang@intel.com> wrote: > > Sometimes the Battery driver doesn't get notifications when it's > plugged/unplugged. And this results in the incorrect Battery > status reported by the power supply sysfs I/F. > > Update the Battery status first when querying from sysfs. > > Signed-off-by: Zhang Rui <rui.zhang@intel.com> > --- > drivers/acpi/battery.c | 3 +++ > 1 file changed, 3 insertions(+) > > Index: linux-2.6/drivers/acpi/battery.c > =================================================================== > --- linux-2.6.orig/drivers/acpi/battery.c > +++ linux-2.6/drivers/acpi/battery.c > @@ -184,6 +184,9 @@ static int acpi_battery_get_property(str > int ret = 0; > struct acpi_battery *battery = to_acpi_battery(psy); > > + if (acpi_battery_update(battery)) > + return -ENODEV; > + > if (acpi_battery_present(battery)) { > /* run battery update only if it is present */ > acpi_battery_get_state(battery); > > > Hello Zhang, i trying 2 times your patch and $ make CHK include/linux/version.h CHK include/generated/utsrelease.h CALL scripts/checksyscalls.sh CHK include/generated/compile.h LD drivers/acpi/acpi.o LD drivers/acpi/built-in.o LD [M] drivers/acpi/processor.o CC [M] drivers/acpi/battery.o drivers/acpi/battery.c: In function ‘acpi_battery_get_property’: drivers/acpi/battery.c:187:2: error: implicit declaration of function ‘acpi_battery_update’ drivers/acpi/battery.c: At top level: drivers/acpi/battery.c:611:12: error: static declaration of ‘acpi_battery_update’ follows non-static declaration drivers/acpi/battery.c:187:6: note: previous implicit declaration of ‘acpi_battery_update’ was here make[2]: *** [drivers/acpi/battery.o] Error 1 make[1]: *** [drivers/acpi] Error 2 make: *** [drivers] Error 2 i've the same error on 2.6.37-rc1 and last linus git. Regards, -- Sébastien Luttringer www.seblu.net -- To unsubscribe from this list: send the line "unsubscribe linux-acpi" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 2/2] ACPI battery: update battery status first when querying from sysfs 2010-11-02 4:13 ` Seblu @ 2010-11-02 5:22 ` Zhang Rui 2010-11-02 18:22 ` Seblu 0 siblings, 1 reply; 4+ messages in thread From: Zhang Rui @ 2010-11-02 5:22 UTC (permalink / raw) To: Seblu; +Cc: Brown, Len, linux-acpi@vger.kernel.org, cbou@mail.ru On Tue, 2010-11-02 at 12:13 +0800, Seblu wrote: > On Tue, Nov 2, 2010 at 4:24 AM, Zhang Rui <rui.zhang@intel.com> wrote: > > > > Sometimes the Battery driver doesn't get notifications when it's > > plugged/unplugged. And this results in the incorrect Battery > > status reported by the power supply sysfs I/F. > > > > Update the Battery status first when querying from sysfs. > > > > Signed-off-by: Zhang Rui <rui.zhang@intel.com> > > --- > > drivers/acpi/battery.c | 3 +++ > > 1 file changed, 3 insertions(+) > > > > Index: linux-2.6/drivers/acpi/battery.c > > =================================================================== > > --- linux-2.6.orig/drivers/acpi/battery.c > > +++ linux-2.6/drivers/acpi/battery.c > > @@ -184,6 +184,9 @@ static int acpi_battery_get_property(str > > int ret = 0; > > struct acpi_battery *battery = to_acpi_battery(psy); > > > > + if (acpi_battery_update(battery)) > > + return -ENODEV; > > + > > if (acpi_battery_present(battery)) { > > /* run battery update only if it is present */ > > acpi_battery_get_state(battery); > > > > > > > Hello Zhang, > > i trying 2 times your patch and > > $ make > CHK include/linux/version.h > CHK include/generated/utsrelease.h > CALL scripts/checksyscalls.sh > CHK include/generated/compile.h > LD drivers/acpi/acpi.o > LD drivers/acpi/built-in.o > LD [M] drivers/acpi/processor.o > CC [M] drivers/acpi/battery.o > drivers/acpi/battery.c: In function ‘acpi_battery_get_property’: > drivers/acpi/battery.c:187:2: error: implicit declaration of function > ‘acpi_battery_update’ > drivers/acpi/battery.c: At top level: > drivers/acpi/battery.c:611:12: error: static declaration of > ‘acpi_battery_update’ follows non-static declaration > drivers/acpi/battery.c:187:6: note: previous implicit declaration of > ‘acpi_battery_update’ was here > make[2]: *** [drivers/acpi/battery.o] Error 1 > make[1]: *** [drivers/acpi] Error 2 > make: *** [drivers] Error 2 > > i've the same error on 2.6.37-rc1 and last linus git. > oops. wrong version attached. how about this one? Sometimes the Battery driver doesn't get notifications when it's plugged/unplugged. And this results in the incorrect Battery status reported by the power supply sysfs I/F. Update the Battery status first when querying from sysfs. Signed-off-by: Zhang Rui <rui.zhang@intel.com> --- drivers/acpi/battery.c | 5 +++++ 1 file changed, 5 insertions(+) Index: linux-2.6/drivers/acpi/battery.c =================================================================== --- linux-2.6.orig/drivers/acpi/battery.c +++ linux-2.6/drivers/acpi/battery.c @@ -177,6 +177,8 @@ static int acpi_battery_is_charged(struc return 0; } +static int acpi_battery_update(struct acpi_battery *battery); + static int acpi_battery_get_property(struct power_supply *psy, enum power_supply_property psp, union power_supply_propval *val) @@ -184,6 +186,9 @@ static int acpi_battery_get_property(str int ret = 0; struct acpi_battery *battery = to_acpi_battery(psy); + if (acpi_battery_update(battery)) + return -ENODEV; + if (acpi_battery_present(battery)) { /* run battery update only if it is present */ acpi_battery_get_state(battery); -- To unsubscribe from this list: send the line "unsubscribe linux-acpi" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 2/2] ACPI battery: update battery status first when querying from sysfs 2010-11-02 5:22 ` Zhang Rui @ 2010-11-02 18:22 ` Seblu 0 siblings, 0 replies; 4+ messages in thread From: Seblu @ 2010-11-02 18:22 UTC (permalink / raw) To: Zhang Rui; +Cc: Brown, Len, linux-acpi@vger.kernel.org, cbou@mail.ru On Tue, Nov 2, 2010 at 6:22 AM, Zhang Rui <rui.zhang@intel.com> wrote: > On Tue, 2010-11-02 at 12:13 +0800, Seblu wrote: >> On Tue, Nov 2, 2010 at 4:24 AM, Zhang Rui <rui.zhang@intel.com> wrote: >> > >> > Sometimes the Battery driver doesn't get notifications when it's >> > plugged/unplugged. And this results in the incorrect Battery >> > status reported by the power supply sysfs I/F. >> > >> > Update the Battery status first when querying from sysfs. >> > >> > Signed-off-by: Zhang Rui <rui.zhang@intel.com> >> > --- >> > drivers/acpi/battery.c | 3 +++ >> > 1 file changed, 3 insertions(+) >> > >> > Index: linux-2.6/drivers/acpi/battery.c >> > =================================================================== >> > --- linux-2.6.orig/drivers/acpi/battery.c >> > +++ linux-2.6/drivers/acpi/battery.c >> > @@ -184,6 +184,9 @@ static int acpi_battery_get_property(str >> > int ret = 0; >> > struct acpi_battery *battery = to_acpi_battery(psy); >> > >> > + if (acpi_battery_update(battery)) >> > + return -ENODEV; >> > + >> > if (acpi_battery_present(battery)) { >> > /* run battery update only if it is present */ >> > acpi_battery_get_state(battery); >> > >> > >> > >> Hello Zhang, >> >> i trying 2 times your patch and >> >> $ make >> CHK include/linux/version.h >> CHK include/generated/utsrelease.h >> CALL scripts/checksyscalls.sh >> CHK include/generated/compile.h >> LD drivers/acpi/acpi.o >> LD drivers/acpi/built-in.o >> LD [M] drivers/acpi/processor.o >> CC [M] drivers/acpi/battery.o >> drivers/acpi/battery.c: In function ‘acpi_battery_get_property’: >> drivers/acpi/battery.c:187:2: error: implicit declaration of function >> ‘acpi_battery_update’ >> drivers/acpi/battery.c: At top level: >> drivers/acpi/battery.c:611:12: error: static declaration of >> ‘acpi_battery_update’ follows non-static declaration >> drivers/acpi/battery.c:187:6: note: previous implicit declaration of >> ‘acpi_battery_update’ was here >> make[2]: *** [drivers/acpi/battery.o] Error 1 >> make[1]: *** [drivers/acpi] Error 2 >> make: *** [drivers] Error 2 >> >> i've the same error on 2.6.37-rc1 and last linus git. >> > oops. wrong version attached. > how about this one? > > Sometimes the Battery driver doesn't get notifications when it's > plugged/unplugged. And this results in the incorrect Battery > status reported by the power supply sysfs I/F. > > Update the Battery status first when querying from sysfs. > > Signed-off-by: Zhang Rui <rui.zhang@intel.com> > --- > drivers/acpi/battery.c | 5 +++++ > 1 file changed, 5 insertions(+) > > Index: linux-2.6/drivers/acpi/battery.c > =================================================================== > --- linux-2.6.orig/drivers/acpi/battery.c > +++ linux-2.6/drivers/acpi/battery.c > @@ -177,6 +177,8 @@ static int acpi_battery_is_charged(struc > return 0; > } > > +static int acpi_battery_update(struct acpi_battery *battery); > + > static int acpi_battery_get_property(struct power_supply *psy, > enum power_supply_property psp, > union power_supply_propval *val) > @@ -184,6 +186,9 @@ static int acpi_battery_get_property(str > int ret = 0; > struct acpi_battery *battery = to_acpi_battery(psy); > > + if (acpi_battery_update(battery)) > + return -ENODEV; > + > if (acpi_battery_present(battery)) { > /* run battery update only if it is present */ > acpi_battery_get_state(battery); > > > > I was not able to reproduce the problem with this patch. It smells good! -- Sébastien Luttringer www.seblu.net -- To unsubscribe from this list: send the line "unsubscribe linux-acpi" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2010-11-02 18:23 UTC | newest] Thread overview: 4+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2010-11-02 3:24 [PATCH 2/2] ACPI battery: update battery status first when querying from sysfs Zhang Rui 2010-11-02 4:13 ` Seblu 2010-11-02 5:22 ` Zhang Rui 2010-11-02 18:22 ` Seblu
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox