On Thu 23. Feb - 20:51:14, Danny Kukawka wrote:
> Hi,
>
> this patch fixes problems with powersave -s and also with dbus methode
> BatteryState if no battery is in the system available. Currently the methode
> return BAT_NORM_STATE (which result in powersave -s == NORMAL) but it should
> be BAT_NONE_STATE.
>
> Please review.
>
> Cheers,
>
> Danny
>
> daemon/battery.cpp | 2 +-
> libpower/battery.c | 40 ++++++++++++++++++++++------------------
> 2 files changed, 23 insertions(+), 19 deletions(-)
> Index: daemon/battery.cpp
> ===================================================================
> --- daemon/battery.cpp (Revision 1950)
> +++ daemon/battery.cpp (Arbeitskopie)
> @@ -48,7 +48,7 @@
>
> _msecs_last_battery_read = 0;
>
> - if (getBatteriesInfo(&_bg) < 0) {
> + if (getBatteriesInfo(&_bg) <= 0) {
> pDebug(DBG_INFO, "Could not get battery info");
> // cannot read out battery, no cpufreq, stop polling
> // suppors AC online and set battery state to normal
Will apply this, thanks.
> Index: libpower/battery.c
> ===================================================================
> --- libpower/battery.c (Revision 1950)
> +++ libpower/battery.c (Arbeitskopie)
> @@ -104,27 +104,31 @@
> continue;
> }
>
> - /* calculate the charging rate for the multiple battery case */
> - if (bg.remaining_minutes > 0 && bd.remaining_capacity !=
> UNKNOWN) {
> - int to_go = 0;
> - if (bg.charging_state & CHARG_STATE_CHARGING) {
> - if (bd.last_full_capacity != UNKNOWN)
> - to_go = bd.last_full_capacity -
> bd.remaining_capacity;
> - } else {
> - to_go = bd.remaining_capacity;
> + if( bd.present == PRESENT_NO) {
> + valid_batteries--;
> + } else {
> + /* calculate the charging rate for the multiple battery
> case */
> + if (bg.remaining_minutes > 0 && bd.remaining_capacity
> != UNKNOWN) {
> + int to_go = 0;
> + if (bg.charging_state & CHARG_STATE_CHARGING) {
> + if (bd.last_full_capacity != UNKNOWN)
> + to_go = bd.last_full_capacity -
> bd.remaining_capacity;
> + } else {
> + to_go = bd.remaining_capacity;
> + }
> + rate += (to_go / bg.remaining_minutes);
> }
> - rate += (to_go / bg.remaining_minutes);
> - }
>
> - /* FIXME: can we have one battery with valid last_full and a
> - second battery with last_full == UNKNOWN?
> - This would make those values totally bogus. */
> - if (bd.last_full_capacity != UNKNOWN) {
> - last_full_capacity_sum += bd.last_full_capacity;
> + /* FIXME: can we have one battery with valid last_full
> and a
> + second battery with last_full == UNKNOWN?
> + This would make those values totally bogus. */
> + if (bd.last_full_capacity != UNKNOWN) {
> + last_full_capacity_sum += bd.last_full_capacity;
>
> - /* see the FIXME above, same applies here... */
> - if (bd.remaining_capacity != UNKNOWN) {
> - remaining_capacity_sum += bd.remaining_capacity;
> + /* see the FIXME above, same applies here... */
> + if (bd.remaining_capacity != UNKNOWN) {
> + remaining_capacity_sum +=
> bd.remaining_capacity;
> + }
> }
> }
> }
This patch only adds an additional check (which was missing before) for
the presence of the battery, right?
If that's correct, I think exactly the same is done with the following
patch:
Index: battery.c
===================================================================
--- battery.c (revision 1913)
+++ battery.c (working copy)
@@ -81,7 +81,7 @@
for (int i = 0; i < numBatteries; ++i) {
BatteryGeneral bg;
- if (getBatteryInfo(i, &bg) < 0) {
+ if (getBatteryInfo(i, &bg) <= 0) {
continue;
}
getBatteryInfo(...) returns 0 in case of success but without the queried
battery being present. At this point, valid_batteries was not yet
increased.
Regards,
Holger
_______________________________________________
powersave-devel mailing list
[email protected]
http://forge.novell.com/mailman/listinfo/powersave-devel