mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] add num_possible_cpus() to fix 2.5.29 apm.c compilation
@ 2002-07-28 14:17 Muli Ben-Yehuda
  2002-07-30  3:20 ` Rusty Russell
  0 siblings, 1 reply; 2+ messages in thread
From: Muli Ben-Yehuda @ 2002-07-28 14:17 UTC (permalink / raw)
  To: Rusty Russell; +Cc: Linux-Kernel

[-- Attachment #1: Type: text/plain, Size: 2270 bytes --]

This patch fixes the apm.c breakage in 2.5.29 by providing definitions
for num_possible_cpus() for UP and SMP. There were several patches
posted to fix it, but I think this is what the author intended. Rusty?

Patch against latest bitkeeper, compiles fine on UP and SMP. Don't
have an SMP machine to test it own. 

# This is a BitKeeper generated patch for the following project:
# Project Name: Linux kernel tree
# This patch format is intended for GNU patch command version 2.5 or higher.
# This patch includes the following deltas:
#	           ChangeSet	1.477   -> 1.478  
#	include/asm-i386/smp.h	1.11    -> 1.12   
#	arch/i386/kernel/apm.c	1.34    -> 1.35   
#	 include/linux/smp.h	1.12    -> 1.13   
#
# The following is the BitKeeper ChangeSet Log
# --------------------------------------------
# 02/07/28	mulix@alhambra.merseine.nu	1.478
# fix compilation failure in apm.c due to missing num_possible_cpus()
# --------------------------------------------
#
diff -Nru a/arch/i386/kernel/apm.c b/arch/i386/kernel/apm.c
--- a/arch/i386/kernel/apm.c	Sun Jul 28 17:07:57 2002
+++ b/arch/i386/kernel/apm.c	Sun Jul 28 17:07:57 2002
@@ -214,6 +214,7 @@
 #include <linux/sched.h>
 #include <linux/pm.h>
 #include <linux/kernel.h>
+#include <linux/smp.h>
 #include <linux/smp_lock.h>
 
 #include <asm/system.h>
diff -Nru a/include/asm-i386/smp.h b/include/asm-i386/smp.h
--- a/include/asm-i386/smp.h	Sun Jul 28 17:07:57 2002
+++ b/include/asm-i386/smp.h	Sun Jul 28 17:07:57 2002
@@ -93,6 +93,11 @@
 	return hweight32(cpu_online_map);
 }
 
+extern inline unsigned int num_possible_cpus(void)
+{
+	return hweight32(phys_cpu_present_map);
+}
+
 extern inline int any_online_cpu(unsigned int mask)
 {
 	if (mask & cpu_online_map)
diff -Nru a/include/linux/smp.h b/include/linux/smp.h
--- a/include/linux/smp.h	Sun Jul 28 17:07:57 2002
+++ b/include/linux/smp.h	Sun Jul 28 17:07:57 2002
@@ -96,6 +96,7 @@
 #define cpu_online_map				1
 #define cpu_online(cpu)				({ cpu; 1; })
 #define num_online_cpus()			1
+#define num_possible_cpus()                     1
 #define __per_cpu_data
 #define per_cpu(var, cpu)			var
 #define this_cpu(var)				var

-- 
http://vipe.technion.ac.il/~mulix/
http://syscalltrack.sf.net/

[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] add num_possible_cpus() to fix 2.5.29 apm.c compilation
  2002-07-28 14:17 [PATCH] add num_possible_cpus() to fix 2.5.29 apm.c compilation Muli Ben-Yehuda
@ 2002-07-30  3:20 ` Rusty Russell
  0 siblings, 0 replies; 2+ messages in thread
From: Rusty Russell @ 2002-07-30  3:20 UTC (permalink / raw)
  To: Muli Ben-Yehuda, torvalds; +Cc: Linux-Kernel, sfr

In message <20020728141750.GB9573@alhambra.actcom.co.il> you write:
> This patch fixes the apm.c breakage in 2.5.29 by providing definitions
> for num_possible_cpus() for UP and SMP. There were several patches
> posted to fix it, but I think this is what the author intended. Rusty?

Actually, since i386 isn't going to be doing hotplug CPUs any time
soon, and the APM code will need a CPU notifier if/when that happens
anyway, best to revert that part of the patch.

Linus, please apply:
diff -urpN -I \$.*\$ --exclude TAGS -X /home/rusty/devel/kernel/kernel-patches/current-dontdiff --minimal linux-2.5.29/arch/i386/kernel/apm.c working-2.5.29-apm/arch/i386/kernel/apm.c
--- linux-2.5.29/arch/i386/kernel/apm.c	Sat Jul 27 15:24:35 2002
+++ working-2.5.29-apm/arch/i386/kernel/apm.c	Tue Jul 30 13:19:24 2002
@@ -1589,7 +1589,7 @@ static int apm_get_info(char *buf, char 
 
 	p = buf;
 
-	if ((num_possible_cpus() == 1) &&
+	if ((num_online_cpus() == 1) &&
 	    !(error = apm_get_power_status(&bx, &cx, &dx))) {
 		ac_line_status = (bx >> 8) & 0xff;
 		battery_status = bx & 0xff;
@@ -1720,7 +1720,7 @@ static int apm(void *unused)
 		}
 	}
 
-	if (debug && (num_possible_cpus() == 1)) {
+	if (debug && (num_online_cpus() == 1)) {
 		error = apm_get_power_status(&bx, &cx, &dx);
 		if (error)
 			printk(KERN_INFO "apm: power status not available\n");
@@ -1764,7 +1764,7 @@ static int apm(void *unused)
 		pm_power_off = apm_power_off;
 	register_sysrq_key('o', &sysrq_poweroff_op);
 
-	if (num_possible_cpus() == 1) {
+	if (num_online_cpus() == 1) {
 #if defined(CONFIG_APM_DISPLAY_BLANK) && defined(CONFIG_VT)
 		console_blank_hook = apm_console_blank;
 #endif
@@ -1907,7 +1907,9 @@ static int __init apm_init(void)
 		printk(KERN_NOTICE "apm: disabled on user request.\n");
 		return -ENODEV;
 	}
-	if ((num_possible_cpus() > 1) && !power_off) {
+	/* FIXME: When boot code changes, this will need to be
+           deactivated when/if a CPU comes up --RR */
+	if ((num_online_cpus() > 1) && !power_off) {
 		printk(KERN_NOTICE "apm: disabled - APM is not SMP safe.\n");
 		return -ENODEV;
 	}
@@ -1964,7 +1966,9 @@ static int __init apm_init(void)
 
 	kernel_thread(apm, NULL, CLONE_FS | CLONE_FILES | CLONE_SIGHAND | SIGCHLD);
 
-	if (num_possible_cpus() > 1) {
+	/* FIXME: When boot code changes, this will need to be
+           deactivated when/if a CPU comes up --RR */
+	if (num_online_cpus() > 1) {
 		printk(KERN_NOTICE
 		   "apm: disabled - APM is not SMP safe (power off active).\n");
 		return 0;


--
  Anyone who quotes me in their sig is an idiot. -- Rusty Russell.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2002-07-30  4:09 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-07-28 14:17 [PATCH] add num_possible_cpus() to fix 2.5.29 apm.c compilation Muli Ben-Yehuda
2002-07-30  3:20 ` Rusty Russell

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®