Skip to content

Commit

Permalink
[SPARC64]: Move topology init code into new file, sysfs.c
Browse files Browse the repository at this point in the history
Also, use per-cpu data for struct cpu.  Calling kmalloc for
each cpu in topology_init() is just plain clumsy.

Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
David S. Miller authored and David S. Miller committed Jun 5, 2007
1 parent 5ecd310 commit eff3414
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 21 deletions.
4 changes: 2 additions & 2 deletions arch/sparc64/kernel/Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# $Id: Makefile,v 1.70 2002/02/09 19:49:30 davem Exp $
#
# Makefile for the linux kernel.
#

Expand All @@ -8,7 +8,7 @@ EXTRA_CFLAGS := -Werror
extra-y := head.o init_task.o vmlinux.lds

obj-y := process.o setup.o cpu.o idprom.o \
traps.o auxio.o una_asm.o \
traps.o auxio.o una_asm.o sysfs.o \
irq.o ptrace.o time.o sys_sparc.o signal.o \
unaligned.o central.o pci.o starfire.o semaphore.o \
power.o sbus.o iommu_common.o sparc64_ksyms.o chmc.o \
Expand Down
19 changes: 0 additions & 19 deletions arch/sparc64/kernel/setup.c
Original file line number Diff line number Diff line change
Expand Up @@ -513,22 +513,3 @@ void sun_do_break(void)

int serial_console = -1;
int stop_a_enabled = 1;

static int __init topology_init(void)
{
int i, err;

err = -ENOMEM;

for_each_possible_cpu(i) {
struct cpu *p = kzalloc(sizeof(*p), GFP_KERNEL);
if (p) {
register_cpu(p, i);
err = 0;
}
}

return err;
}

subsys_initcall(topology_init);
26 changes: 26 additions & 0 deletions arch/sparc64/kernel/sysfs.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/* sysfs.c: Toplogy sysfs support code for sparc64.
*
* Copyright (C) 2007 David S. Miller <davem@davemloft.net>
*/
#include <linux/sysdev.h>
#include <linux/cpu.h>
#include <linux/smp.h>
#include <linux/percpu.h>
#include <linux/init.h>

static DEFINE_PER_CPU(struct cpu, cpu_devices);

static int __init topology_init(void)
{
int cpu;

for_each_possible_cpu(cpu) {
struct cpu *c = &per_cpu(cpu_devices, cpu);

register_cpu(c, cpu);
}

return 0;
}

subsys_initcall(topology_init);

0 comments on commit eff3414

Please sign in to comment.