Commit 923c572e authored by Rusty Russell's avatar Rusty Russell Committed by Linus Torvalds

[PATCH] any_online_cpus to return NR_CPUS to mean "none".

Matt Fleming points out that returning int from any_online_cpu
where cpu numbers are passed as unsigned ints elsewhere is awkward
and a little dangerous.

Make any_online_cpu() match find_first_bit(), by returning NR_CPUS
when no cpu is found, rather than -1.  This also simplifies the
future case where NR_CPUS > BITS_PER_LONG.
parent 99c06d3b
......@@ -78,12 +78,12 @@ static inline int num_booting_cpus(void)
extern void map_cpu_to_logical_apicid(void);
extern void unmap_cpu_to_logical_apicid(int cpu);
extern inline int any_online_cpu(unsigned int mask)
extern inline unsigned int any_online_cpu(unsigned int mask)
{
if (mask & cpu_online_map)
return __ffs(mask & cpu_online_map);
return -1;
return NR_CPUS;
}
#ifdef CONFIG_X86_LOCAL_APIC
......
......@@ -56,12 +56,12 @@ num_online_cpus (void)
return hweight64(cpu_online_map);
}
static inline int
static inline unsigned int
any_online_cpu (unsigned int mask)
{
if (mask & cpu_online_map)
return __ffs(mask & cpu_online_map);
return -1;
return NR_CPUS;
}
/*
......
......@@ -60,12 +60,12 @@ extern inline unsigned int num_online_cpus(void)
return hweight32(cpu_online_map);
}
extern inline int any_online_cpu(unsigned int mask)
extern inline unsigned int any_online_cpu(unsigned int mask)
{
if (mask & cpu_online_map)
return __ffs(mask & cpu_online_map);
return -1;
return NR_CPUS;
}
#endif /* CONFIG_SMP */
......
......@@ -53,12 +53,12 @@ extern inline unsigned int num_online_cpus(void)
return hweight32(cpu_online_map);
}
extern inline int any_online_cpu(unsigned int mask)
extern inline unsigned int any_online_cpu(unsigned int mask)
{
if (mask & cpu_online_map)
return __ffs(mask & cpu_online_map);
return -1;
return NR_CPUS;
}
extern int __cpu_up(unsigned int cpu);
......
......@@ -59,12 +59,12 @@ extern inline unsigned int num_online_cpus(void)
#endif /* __s390x__ */
}
extern inline int any_online_cpu(unsigned int mask)
extern inline unsigned int any_online_cpu(unsigned int mask)
{
if (mask & cpu_online_map)
return __ffs(mask & cpu_online_map);
return -1;
return NR_CPUS;
}
extern __inline__ __u16 hard_smp_processor_id(void)
......
......@@ -80,11 +80,11 @@ extern atomic_t sparc64_num_cpus_online;
extern atomic_t sparc64_num_cpus_possible;
#define num_possible_cpus() (atomic_read(&sparc64_num_cpus_possible))
static inline int any_online_cpu(unsigned long mask)
static inline unsigned int any_online_cpu(unsigned long mask)
{
if ((mask &= cpu_online_map) != 0UL)
return __ffs(mask);
return -1;
return NR_CPUS;
}
/*
......
......@@ -66,12 +66,12 @@ extern volatile unsigned long cpu_callout_map;
cpu = __ffs(mask), mask != 0; \
mask &= ~(1UL<<cpu))
extern inline int any_online_cpu(unsigned int mask)
extern inline unsigned int any_online_cpu(unsigned int mask)
{
if (mask & cpu_online_map)
return __ffs(mask & cpu_online_map);
return -1;
return NR_CPUS;
}
extern inline unsigned int num_online_cpus(void)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment