[EMAIL PROTECTED] wrote:
> 
>           Dear J.D.,
> 
>      I am not sure of what I will write here as I am not a kernel developer
> nor a APM specialist. So sorry, if I am completely wrong.
> 
<snip>
> 
>      This code means that in case of APM_LOW_BATTERY the code for the
> APM_POWER_STATUS_CHANGE is also executed and I am not sure you really want
> this. It may work, but it is not really clean.
> 
>      Just my two cents!
> 
>      Best regards,
>      Loic.

Good eye. It would ignore LOW_BATTERY events on occasion.  I fixed it
and attached again.  

Thanks,

JD



-- 
 J.D. Smith                             |*|      WORK: (607) 255-5842    
 Cornell University Dept. of Astronomy  |*|            (607) 255-6263
 304 Space Sciences Bldg.               |*|       FAX: (607) 255-5875 
 Ithaca, NY 14853                       |*|
--- linux/arch/i386/kernel/apm_save.c   Wed Jun 16 12:32:53 1999
+++ linux/arch/i386/kernel/apm.c        Wed Jun 16 12:40:10 1999
@@ -90,6 +90,10 @@
  *         Use CONFIG_SMP instead of __SMP__
  *         Ignore BOUNCES for three seconds.
  *         Stephen Rothwell
+ *    ***: Added CONFIG_APM_IGNORE_MULTIPLE_POWER to ignore multiple 
+ *         POWER_STATUS_CHANGE events for which the power status 
+ *         doesn't change.
+ *         J.D. Smith <[EMAIL PROTECTED]>
  *
  * APM 1.1 Reference:
  *
@@ -185,12 +189,19 @@
  * really only need one at a time, so just ignore any beyond the first.
  * This is probably safe on most laptops.
  *
+ * CONFIG_APM_IGNORE_MULTIPLE_POWER: The Dell Inspiron 7000 bios sends
+ * multiple power_status change events within a few seconds of
+ * (un)plugging the ac cord.  Ignore any consecutive events for which
+ * the ac power status is unchanged. Should be safe on most laptops.
+ *
  * If you are debugging the APM support for your laptop, note that code for
  * all of these options is contained in this file, so you can #define or
  * #undef these on the next line to avoid recompiling the whole kernel.
  *
  */
 
+#define CONFIG_APM_IGNORE_MULTIPLE_POWER
+
 /* KNOWN PROBLEM MACHINES:
  *
  * U: TI 4000M TravelMate: BIOS is *NOT* APM compliant
@@ -863,6 +874,12 @@
        static int              ignore_bounce = 0;
 #endif
 
+#ifdef CONFIG_APM_IGNORE_MULTIPLE_POWER
+       unsigned short bx = 0xff;
+       unsigned short acls = 0xff;
+       static unsigned short save_ac_line_status = 0xff;
+#endif
+
        while ((event = get_event()) != 0) {
 #ifdef APM_DEBUG
                if (event <= NR_APM_EVENT_NAME)
@@ -925,8 +942,16 @@
                        send_event(event, 0, NULL);
                        break;
 
-               case APM_LOW_BATTERY:
                case APM_POWER_STATUS_CHANGE:
+#ifdef CONFIG_APM_IGNORE_MULTIPLE_POWER        
+                       if (!apm_get_power_status(&bx, &acls, &acls)) {
+                               acls = (bx >> 8) & 0xff;
+                               if (acls == save_ac_line_status)
+                                       break;
+                               save_ac_line_status = acls;
+                       }
+#endif 
+               case APM_LOW_BATTERY:
                case APM_CAPABILITY_CHANGE:
                        send_event(event, 0, NULL);
                        break;

Reply via email to