Skip to contentSkip to conversation

Fix compiling error in powernv/rng.c

RFC PATCH In review Li Zhong 2 participants 3 messages Nov 15, 2013 – Nov 19, 2013 PowerPC

lore
Share & tools
lore

Li Zhong

author
#0 lore raw

RFC PATCH 1/1 Fix compiling error in powernv/rng.c

This is seen when CONFIG_SMP is not enabled:

arch/powerpc/platforms/powernv/rng.c: In function 'rng_init_per_cpu':
arch/powerpc/platforms/powernv/rng.c:74: error: implicit declaration of function 'cpu_to_chip_id'

---
 arch/powerpc/platforms/powernv/rng.c |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)
arch/powerpc/platforms/powernv/rng.c +8 -0
index 8844628..04430a7 100644
@@ -59,6 +59,7 @@ int powernv_get_random_long(unsigned long *v)
 }
 EXPORT_SYMBOL_GPL(powernv_get_random_long);
 
+#ifdef CONFIG_SMP
 static __init void rng_init_per_cpu(struct powernv_rng *rng,
 				    struct device_node *dn)
 {
@@ -75,6 +76,13 @@ static __init void rng_init_per_cpu(struct powernv_rng *rng,
 		}
 	}
 }
+#else
+static __init void rng_init_per_cpu(struct powernv_rng *rng,
+				    struct device_node *dn)
+{
+	per_cpu(powernv_rng, 0) = rng;
+}
+#endif
 
 static __init int rng_create(struct device_node *dn)
 {
#1 lore raw
Quoted 4 lines · Li Zhong

This is seen when CONFIG_SMP is not enabled:

arch/powerpc/platforms/powernv/rng.c: In function 'rng_init_per_cpu':
arch/powerpc/platforms/powernv/rng.c:74: error: implicit declaration of function 'cpu_to_chip_id'

Hi Li,

We try whenever possible to avoid adding #ifdefs in C code.

Also on a multi chip system where there are multiple RNGs, your code for UP will not necessarily choose the RNG on the same core as the cpu.

I have a different fix that I will send.

cheers

author
#2 lore raw
Quoted 6 lines · Michael Ellerman
Quoted 4 lines · Li Zhong

This is seen when CONFIG_SMP is not enabled:

arch/powerpc/platforms/powernv/rng.c: In function 'rng_init_per_cpu':
arch/powerpc/platforms/powernv/rng.c:74: error: implicit declaration of function 'cpu_to_chip_id'

Quoted 6 lines

Hi Li,

We try whenever possible to avoid adding #ifdefs in C code.

Also on a multi chip system where there are multiple RNGs, your code for UP will not necessarily choose the RNG on the same core as the cpu.

OK, thank you for the review, Michael.

Just try to make sure I understand it:

So even in UP, we could have multiple rng sources, and we should try to use the source which has the same chip_id as the logical cpu?

Thanks, Zhong

Quoted 4 lines

I have a different fix that I will send.

cheers