5a0e3ad6af
percpu.h is included by sched.h and module.h and thus ends up being included when building most .c files. percpu.h includes slab.h which in turn includes gfp.h making everything defined by the two files universally available and complicating inclusion dependencies. percpu.h -> slab.h dependency is about to be removed. Prepare for this change by updating users of gfp and slab facilities include those headers directly instead of assuming availability. As this conversion needs to touch large number of source files, the following script is used as the basis of conversion. http://userweb.kernel.org/~tj/misc/slabh-sweep.py The script does the followings. * Scan files for gfp and slab usages and update includes such that only the necessary includes are there. ie. if only gfp is used, gfp.h, if slab is used, slab.h. * When the script inserts a new include, it looks at the include blocks and try to put the new include such that its order conforms to its surrounding. It's put in the include block which contains core kernel includes, in the same order that the rest are ordered - alphabetical, Christmas tree, rev-Xmas-tree or at the end if there doesn't seem to be any matching order. * If the script can't find a place to put a new include (mostly because the file doesn't have fitting include block), it prints out an error message indicating which .h file needs to be added to the file. The conversion was done in the following steps. 1. The initial automatic conversion of all .c files updated slightly over 4000 files, deleting around 700 includes and adding ~480 gfp.h and ~3000 slab.h inclusions. The script emitted errors for ~400 files. 2. Each error was manually checked. Some didn't need the inclusion, some needed manual addition while adding it to implementation .h or embedding .c file was more appropriate for others. This step added inclusions to around 150 files. 3. The script was run again and the output was compared to the edits from #2 to make sure no file was left behind. 4. Several build tests were done and a couple of problems were fixed. e.g. lib/decompress_*.c used malloc/free() wrappers around slab APIs requiring slab.h to be added manually. 5. The script was run on all .h files but without automatically editing them as sprinkling gfp.h and slab.h inclusions around .h files could easily lead to inclusion dependency hell. Most gfp.h inclusion directives were ignored as stuff from gfp.h was usually wildly available and often used in preprocessor macros. Each slab.h inclusion directive was examined and added manually as necessary. 6. percpu.h was updated not to include slab.h. 7. Build test were done on the following configurations and failures were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my distributed build env didn't work with gcov compiles) and a few more options had to be turned off depending on archs to make things build (like ipr on powerpc/64 which failed due to missing writeq). * x86 and x86_64 UP and SMP allmodconfig and a custom test config. * powerpc and powerpc64 SMP allmodconfig * sparc and sparc64 SMP allmodconfig * ia64 SMP allmodconfig * s390 SMP allmodconfig * alpha SMP allmodconfig * um on x86_64 SMP allmodconfig 8. percpu.h modifications were reverted so that it could be applied as a separate patch and serve as bisection point. Given the fact that I had only a couple of failures from tests on step 6, I'm fairly confident about the coverage of this conversion patch. If there is a breakage, it's likely to be something in one of the arch headers which should be easily discoverable easily on most builds of the specific arch. Signed-off-by: Tejun Heo <tj@kernel.org> Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org> Cc: Ingo Molnar <mingo@redhat.com> Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
271 lines
6.1 KiB
C
271 lines
6.1 KiB
C
/* central.c: Central FHC driver for Sunfire/Starfire/Wildfire.
|
|
*
|
|
* Copyright (C) 1997, 1999, 2008 David S. Miller (davem@davemloft.net)
|
|
*/
|
|
|
|
#include <linux/kernel.h>
|
|
#include <linux/types.h>
|
|
#include <linux/slab.h>
|
|
#include <linux/string.h>
|
|
#include <linux/init.h>
|
|
#include <linux/of_device.h>
|
|
#include <linux/platform_device.h>
|
|
|
|
#include <asm/fhc.h>
|
|
#include <asm/upa.h>
|
|
|
|
struct clock_board {
|
|
void __iomem *clock_freq_regs;
|
|
void __iomem *clock_regs;
|
|
void __iomem *clock_ver_reg;
|
|
int num_slots;
|
|
struct resource leds_resource;
|
|
struct platform_device leds_pdev;
|
|
};
|
|
|
|
struct fhc {
|
|
void __iomem *pregs;
|
|
bool central;
|
|
bool jtag_master;
|
|
int board_num;
|
|
struct resource leds_resource;
|
|
struct platform_device leds_pdev;
|
|
};
|
|
|
|
static int __devinit clock_board_calc_nslots(struct clock_board *p)
|
|
{
|
|
u8 reg = upa_readb(p->clock_regs + CLOCK_STAT1) & 0xc0;
|
|
|
|
switch (reg) {
|
|
case 0x40:
|
|
return 16;
|
|
|
|
case 0xc0:
|
|
return 8;
|
|
|
|
case 0x80:
|
|
reg = 0;
|
|
if (p->clock_ver_reg)
|
|
reg = upa_readb(p->clock_ver_reg);
|
|
if (reg) {
|
|
if (reg & 0x80)
|
|
return 4;
|
|
else
|
|
return 5;
|
|
}
|
|
/* Fallthrough */
|
|
default:
|
|
return 4;
|
|
}
|
|
}
|
|
|
|
static int __devinit clock_board_probe(struct of_device *op,
|
|
const struct of_device_id *match)
|
|
{
|
|
struct clock_board *p = kzalloc(sizeof(*p), GFP_KERNEL);
|
|
int err = -ENOMEM;
|
|
|
|
if (!p) {
|
|
printk(KERN_ERR "clock_board: Cannot allocate struct clock_board\n");
|
|
goto out;
|
|
}
|
|
|
|
p->clock_freq_regs = of_ioremap(&op->resource[0], 0,
|
|
resource_size(&op->resource[0]),
|
|
"clock_board_freq");
|
|
if (!p->clock_freq_regs) {
|
|
printk(KERN_ERR "clock_board: Cannot map clock_freq_regs\n");
|
|
goto out_free;
|
|
}
|
|
|
|
p->clock_regs = of_ioremap(&op->resource[1], 0,
|
|
resource_size(&op->resource[1]),
|
|
"clock_board_regs");
|
|
if (!p->clock_regs) {
|
|
printk(KERN_ERR "clock_board: Cannot map clock_regs\n");
|
|
goto out_unmap_clock_freq_regs;
|
|
}
|
|
|
|
if (op->resource[2].flags) {
|
|
p->clock_ver_reg = of_ioremap(&op->resource[2], 0,
|
|
resource_size(&op->resource[2]),
|
|
"clock_ver_reg");
|
|
if (!p->clock_ver_reg) {
|
|
printk(KERN_ERR "clock_board: Cannot map clock_ver_reg\n");
|
|
goto out_unmap_clock_regs;
|
|
}
|
|
}
|
|
|
|
p->num_slots = clock_board_calc_nslots(p);
|
|
|
|
p->leds_resource.start = (unsigned long)
|
|
(p->clock_regs + CLOCK_CTRL);
|
|
p->leds_resource.end = p->leds_resource.start;
|
|
p->leds_resource.name = "leds";
|
|
|
|
p->leds_pdev.name = "sunfire-clockboard-leds";
|
|
p->leds_pdev.id = -1;
|
|
p->leds_pdev.resource = &p->leds_resource;
|
|
p->leds_pdev.num_resources = 1;
|
|
p->leds_pdev.dev.parent = &op->dev;
|
|
|
|
err = platform_device_register(&p->leds_pdev);
|
|
if (err) {
|
|
printk(KERN_ERR "clock_board: Could not register LEDS "
|
|
"platform device\n");
|
|
goto out_unmap_clock_ver_reg;
|
|
}
|
|
|
|
printk(KERN_INFO "clock_board: Detected %d slot Enterprise system.\n",
|
|
p->num_slots);
|
|
|
|
err = 0;
|
|
out:
|
|
return err;
|
|
|
|
out_unmap_clock_ver_reg:
|
|
if (p->clock_ver_reg)
|
|
of_iounmap(&op->resource[2], p->clock_ver_reg,
|
|
resource_size(&op->resource[2]));
|
|
|
|
out_unmap_clock_regs:
|
|
of_iounmap(&op->resource[1], p->clock_regs,
|
|
resource_size(&op->resource[1]));
|
|
|
|
out_unmap_clock_freq_regs:
|
|
of_iounmap(&op->resource[0], p->clock_freq_regs,
|
|
resource_size(&op->resource[0]));
|
|
|
|
out_free:
|
|
kfree(p);
|
|
goto out;
|
|
}
|
|
|
|
static struct of_device_id __initdata clock_board_match[] = {
|
|
{
|
|
.name = "clock-board",
|
|
},
|
|
{},
|
|
};
|
|
|
|
static struct of_platform_driver clock_board_driver = {
|
|
.match_table = clock_board_match,
|
|
.probe = clock_board_probe,
|
|
.driver = {
|
|
.name = "clock_board",
|
|
},
|
|
};
|
|
|
|
static int __devinit fhc_probe(struct of_device *op,
|
|
const struct of_device_id *match)
|
|
{
|
|
struct fhc *p = kzalloc(sizeof(*p), GFP_KERNEL);
|
|
int err = -ENOMEM;
|
|
u32 reg;
|
|
|
|
if (!p) {
|
|
printk(KERN_ERR "fhc: Cannot allocate struct fhc\n");
|
|
goto out;
|
|
}
|
|
|
|
if (!strcmp(op->node->parent->name, "central"))
|
|
p->central = true;
|
|
|
|
p->pregs = of_ioremap(&op->resource[0], 0,
|
|
resource_size(&op->resource[0]),
|
|
"fhc_pregs");
|
|
if (!p->pregs) {
|
|
printk(KERN_ERR "fhc: Cannot map pregs\n");
|
|
goto out_free;
|
|
}
|
|
|
|
if (p->central) {
|
|
reg = upa_readl(p->pregs + FHC_PREGS_BSR);
|
|
p->board_num = ((reg >> 16) & 1) | ((reg >> 12) & 0x0e);
|
|
} else {
|
|
p->board_num = of_getintprop_default(op->node, "board#", -1);
|
|
if (p->board_num == -1) {
|
|
printk(KERN_ERR "fhc: No board# property\n");
|
|
goto out_unmap_pregs;
|
|
}
|
|
if (upa_readl(p->pregs + FHC_PREGS_JCTRL) & FHC_JTAG_CTRL_MENAB)
|
|
p->jtag_master = true;
|
|
}
|
|
|
|
if (!p->central) {
|
|
p->leds_resource.start = (unsigned long)
|
|
(p->pregs + FHC_PREGS_CTRL);
|
|
p->leds_resource.end = p->leds_resource.start;
|
|
p->leds_resource.name = "leds";
|
|
|
|
p->leds_pdev.name = "sunfire-fhc-leds";
|
|
p->leds_pdev.id = p->board_num;
|
|
p->leds_pdev.resource = &p->leds_resource;
|
|
p->leds_pdev.num_resources = 1;
|
|
p->leds_pdev.dev.parent = &op->dev;
|
|
|
|
err = platform_device_register(&p->leds_pdev);
|
|
if (err) {
|
|
printk(KERN_ERR "fhc: Could not register LEDS "
|
|
"platform device\n");
|
|
goto out_unmap_pregs;
|
|
}
|
|
}
|
|
reg = upa_readl(p->pregs + FHC_PREGS_CTRL);
|
|
|
|
if (!p->central)
|
|
reg |= FHC_CONTROL_IXIST;
|
|
|
|
reg &= ~(FHC_CONTROL_AOFF |
|
|
FHC_CONTROL_BOFF |
|
|
FHC_CONTROL_SLINE);
|
|
|
|
upa_writel(reg, p->pregs + FHC_PREGS_CTRL);
|
|
upa_readl(p->pregs + FHC_PREGS_CTRL);
|
|
|
|
reg = upa_readl(p->pregs + FHC_PREGS_ID);
|
|
printk(KERN_INFO "fhc: Board #%d, Version[%x] PartID[%x] Manuf[%x] %s\n",
|
|
p->board_num,
|
|
(reg & FHC_ID_VERS) >> 28,
|
|
(reg & FHC_ID_PARTID) >> 12,
|
|
(reg & FHC_ID_MANUF) >> 1,
|
|
(p->jtag_master ?
|
|
"(JTAG Master)" :
|
|
(p->central ? "(Central)" : "")));
|
|
|
|
err = 0;
|
|
|
|
out:
|
|
return err;
|
|
|
|
out_unmap_pregs:
|
|
of_iounmap(&op->resource[0], p->pregs, resource_size(&op->resource[0]));
|
|
|
|
out_free:
|
|
kfree(p);
|
|
goto out;
|
|
}
|
|
|
|
static struct of_device_id __initdata fhc_match[] = {
|
|
{
|
|
.name = "fhc",
|
|
},
|
|
{},
|
|
};
|
|
|
|
static struct of_platform_driver fhc_driver = {
|
|
.match_table = fhc_match,
|
|
.probe = fhc_probe,
|
|
.driver = {
|
|
.name = "fhc",
|
|
},
|
|
};
|
|
|
|
static int __init sunfire_init(void)
|
|
{
|
|
(void) of_register_driver(&fhc_driver, &of_platform_bus_type);
|
|
(void) of_register_driver(&clock_board_driver, &of_platform_bus_type);
|
|
return 0;
|
|
}
|
|
|
|
subsys_initcall(sunfire_init);
|