aboutsummaryrefslogtreecommitdiffstats
path: root/arch/i386
diff options
context:
space:
mode:
authorAndreas Mohr <andi@rhlx01.fht-esslingen.de>2006-06-23 05:04:17 -0400
committerLinus Torvalds <torvalds@g5.osdl.org>2006-06-23 10:42:56 -0400
commit87af2ffd4ccd0e6a2ff316fd008a9bedb4a4cb66 (patch)
tree4cd80cf123aa220e5c1c3c534bf09fa8d001ad28 /arch/i386
parenta0b4da91f4c5710b9c20219a19e905145647b48b (diff)
[PATCH] i386 apm.c optimization
- avoid expensive modulo (integer division) which happened since APM_MAX_EVENTS is 20 (non-power-of-2) - kill compiler warnings by initializing two variables - add __read_mostly to some important static variables that are read often (by idle loop etc.) - constify several structures Signed-off-by: Andreas Mohr <andi@lisas.de> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'arch/i386')
-rw-r--r--arch/i386/kernel/apm.c39
1 files changed, 22 insertions, 17 deletions
diff --git a/arch/i386/kernel/apm.c b/arch/i386/kernel/apm.c
index df0e1745f189..9e819eb68229 100644
--- a/arch/i386/kernel/apm.c
+++ b/arch/i386/kernel/apm.c
@@ -374,14 +374,14 @@ static struct {
374 unsigned short segment; 374 unsigned short segment;
375} apm_bios_entry; 375} apm_bios_entry;
376static int clock_slowed; 376static int clock_slowed;
377static int idle_threshold = DEFAULT_IDLE_THRESHOLD; 377static int idle_threshold __read_mostly = DEFAULT_IDLE_THRESHOLD;
378static int idle_period = DEFAULT_IDLE_PERIOD; 378static int idle_period __read_mostly = DEFAULT_IDLE_PERIOD;
379static int set_pm_idle; 379static int set_pm_idle;
380static int suspends_pending; 380static int suspends_pending;
381static int standbys_pending; 381static int standbys_pending;
382static int ignore_sys_suspend; 382static int ignore_sys_suspend;
383static int ignore_normal_resume; 383static int ignore_normal_resume;
384static int bounce_interval = DEFAULT_BOUNCE_INTERVAL; 384static int bounce_interval __read_mostly = DEFAULT_BOUNCE_INTERVAL;
385 385
386#ifdef CONFIG_APM_RTC_IS_GMT 386#ifdef CONFIG_APM_RTC_IS_GMT
387# define clock_cmos_diff 0 387# define clock_cmos_diff 0
@@ -390,8 +390,8 @@ static int bounce_interval = DEFAULT_BOUNCE_INTERVAL;
390static long clock_cmos_diff; 390static long clock_cmos_diff;
391static int got_clock_diff; 391static int got_clock_diff;
392#endif 392#endif
393static int debug; 393static int debug __read_mostly;
394static int smp; 394static int smp __read_mostly;
395static int apm_disabled = -1; 395static int apm_disabled = -1;
396#ifdef CONFIG_SMP 396#ifdef CONFIG_SMP
397static int power_off; 397static int power_off;
@@ -403,8 +403,8 @@ static int realmode_power_off = 1;
403#else 403#else
404static int realmode_power_off; 404static int realmode_power_off;
405#endif 405#endif
406static int exit_kapmd; 406static int exit_kapmd __read_mostly;
407static int kapmd_running; 407static int kapmd_running __read_mostly;
408#ifdef CONFIG_APM_ALLOW_INTS 408#ifdef CONFIG_APM_ALLOW_INTS
409static int allow_ints = 1; 409static int allow_ints = 1;
410#else 410#else
@@ -416,15 +416,15 @@ static DECLARE_WAIT_QUEUE_HEAD(apm_waitqueue);
416static DECLARE_WAIT_QUEUE_HEAD(apm_suspend_waitqueue); 416static DECLARE_WAIT_QUEUE_HEAD(apm_suspend_waitqueue);
417static struct apm_user * user_list; 417static struct apm_user * user_list;
418static DEFINE_SPINLOCK(user_list_lock); 418static DEFINE_SPINLOCK(user_list_lock);
419static struct desc_struct bad_bios_desc = { 0, 0x00409200 }; 419static const struct desc_struct bad_bios_desc = { 0, 0x00409200 };
420 420
421static char driver_version[] = "1.16ac"; /* no spaces */ 421static const char driver_version[] = "1.16ac"; /* no spaces */
422 422
423/* 423/*
424 * APM event names taken from the APM 1.2 specification. These are 424 * APM event names taken from the APM 1.2 specification. These are
425 * the message codes that the BIOS uses to tell us about events 425 * the message codes that the BIOS uses to tell us about events
426 */ 426 */
427static char * apm_event_name[] = { 427static const char * const apm_event_name[] = {
428 "system standby", 428 "system standby",
429 "system suspend", 429 "system suspend",
430 "normal resume", 430 "normal resume",
@@ -616,7 +616,7 @@ static u8 apm_bios_call(u32 func, u32 ebx_in, u32 ecx_in,
616 * @ecx_in: ECX register value for BIOS call 616 * @ecx_in: ECX register value for BIOS call
617 * @eax: EAX register on return from the BIOS call 617 * @eax: EAX register on return from the BIOS call
618 * 618 *
619 * Make a BIOS call that does only returns one value, or just status. 619 * Make a BIOS call that returns one value only, or just status.
620 * If there is an error, then the error code is returned in AH 620 * If there is an error, then the error code is returned in AH
621 * (bits 8-15 of eax) and this function returns non-zero. This is 621 * (bits 8-15 of eax) and this function returns non-zero. This is
622 * used for simpler BIOS operations. This call may hold interrupts 622 * used for simpler BIOS operations. This call may hold interrupts
@@ -822,7 +822,7 @@ static void apm_do_busy(void)
822#define IDLE_CALC_LIMIT (HZ * 100) 822#define IDLE_CALC_LIMIT (HZ * 100)
823#define IDLE_LEAKY_MAX 16 823#define IDLE_LEAKY_MAX 16
824 824
825static void (*original_pm_idle)(void); 825static void (*original_pm_idle)(void) __read_mostly;
826 826
827/** 827/**
828 * apm_cpu_idle - cpu idling for APM capable Linux 828 * apm_cpu_idle - cpu idling for APM capable Linux
@@ -1063,7 +1063,8 @@ static int apm_engage_power_management(u_short device, int enable)
1063 1063
1064static int apm_console_blank(int blank) 1064static int apm_console_blank(int blank)
1065{ 1065{
1066 int error, i; 1066 int error = APM_NOT_ENGAGED; /* silence gcc */
1067 int i;
1067 u_short state; 1068 u_short state;
1068 static const u_short dev[3] = { 0x100, 0x1FF, 0x101 }; 1069 static const u_short dev[3] = { 0x100, 0x1FF, 0x101 };
1069 1070
@@ -1104,7 +1105,8 @@ static int queue_empty(struct apm_user *as)
1104 1105
1105static apm_event_t get_queued_event(struct apm_user *as) 1106static apm_event_t get_queued_event(struct apm_user *as)
1106{ 1107{
1107 as->event_tail = (as->event_tail + 1) % APM_MAX_EVENTS; 1108 if (++as->event_tail >= APM_MAX_EVENTS)
1109 as->event_tail = 0;
1108 return as->events[as->event_tail]; 1110 return as->events[as->event_tail];
1109} 1111}
1110 1112
@@ -1118,13 +1120,16 @@ static void queue_event(apm_event_t event, struct apm_user *sender)
1118 for (as = user_list; as != NULL; as = as->next) { 1120 for (as = user_list; as != NULL; as = as->next) {
1119 if ((as == sender) || (!as->reader)) 1121 if ((as == sender) || (!as->reader))
1120 continue; 1122 continue;
1121 as->event_head = (as->event_head + 1) % APM_MAX_EVENTS; 1123 if (++as->event_head >= APM_MAX_EVENTS)
1124 as->event_head = 0;
1125
1122 if (as->event_head == as->event_tail) { 1126 if (as->event_head == as->event_tail) {
1123 static int notified; 1127 static int notified;
1124 1128
1125 if (notified++ == 0) 1129 if (notified++ == 0)
1126 printk(KERN_ERR "apm: an event queue overflowed\n"); 1130 printk(KERN_ERR "apm: an event queue overflowed\n");
1127 as->event_tail = (as->event_tail + 1) % APM_MAX_EVENTS; 1131 if (++as->event_tail >= APM_MAX_EVENTS)
1132 as->event_tail = 0;
1128 } 1133 }
1129 as->events[as->event_head] = event; 1134 as->events[as->event_head] = event;
1130 if ((!as->suser) || (!as->writer)) 1135 if ((!as->suser) || (!as->writer))
@@ -1282,7 +1287,7 @@ static void standby(void)
1282static apm_event_t get_event(void) 1287static apm_event_t get_event(void)
1283{ 1288{
1284 int error; 1289 int error;
1285 apm_event_t event; 1290 apm_event_t event = APM_NO_EVENTS; /* silence gcc */
1286 apm_eventinfo_t info; 1291 apm_eventinfo_t info;
1287 1292
1288 static int notified; 1293 static int notified;