![Tejun Heo](/assets/img/avatar_default.png)
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>
210 lines
4.9 KiB
C
210 lines
4.9 KiB
C
/*
|
|
* Copyright (C) 2009 ST-Ericsson
|
|
*
|
|
* Author: Srinidhi KASAGAR <srinidhi.kasagar@stericsson.com>
|
|
*
|
|
* This program is free software; you can redistribute it
|
|
* and/or modify it under the terms of the GNU General Public
|
|
* License version 2, as published by the Free Software Foundation.
|
|
*
|
|
* AB4500 is a companion power management chip used with U8500.
|
|
* On this platform, this is interfaced with SSP0 controller
|
|
* which is a ARM primecell pl022.
|
|
*
|
|
* At the moment the module just exports read/write features.
|
|
* Interrupt management to be added - TODO.
|
|
*/
|
|
#include <linux/kernel.h>
|
|
#include <linux/slab.h>
|
|
#include <linux/init.h>
|
|
#include <linux/module.h>
|
|
#include <linux/platform_device.h>
|
|
#include <linux/spi/spi.h>
|
|
#include <linux/mfd/ab4500.h>
|
|
|
|
/* just required if probe fails, we need to
|
|
* unregister the device
|
|
*/
|
|
static struct spi_driver ab4500_driver;
|
|
|
|
/*
|
|
* This funtion writes to any AB4500 registers using
|
|
* SPI protocol & before it writes it packs the data
|
|
* in the below 24 bit frame format
|
|
*
|
|
* *|------------------------------------|
|
|
* *| 23|22...18|17.......10|9|8|7......0|
|
|
* *| r/w bank adr data |
|
|
* * ------------------------------------
|
|
*
|
|
* This function shouldn't be called from interrupt
|
|
* context
|
|
*/
|
|
int ab4500_write(struct ab4500 *ab4500, unsigned char block,
|
|
unsigned long addr, unsigned char data)
|
|
{
|
|
struct spi_transfer xfer;
|
|
struct spi_message msg;
|
|
int err;
|
|
unsigned long spi_data =
|
|
block << 18 | addr << 10 | data;
|
|
|
|
mutex_lock(&ab4500->lock);
|
|
ab4500->tx_buf[0] = spi_data;
|
|
ab4500->rx_buf[0] = 0;
|
|
|
|
xfer.tx_buf = ab4500->tx_buf;
|
|
xfer.rx_buf = NULL;
|
|
xfer.len = sizeof(unsigned long);
|
|
|
|
spi_message_init(&msg);
|
|
spi_message_add_tail(&xfer, &msg);
|
|
|
|
err = spi_sync(ab4500->spi, &msg);
|
|
mutex_unlock(&ab4500->lock);
|
|
|
|
return err;
|
|
}
|
|
EXPORT_SYMBOL(ab4500_write);
|
|
|
|
int ab4500_read(struct ab4500 *ab4500, unsigned char block,
|
|
unsigned long addr)
|
|
{
|
|
struct spi_transfer xfer;
|
|
struct spi_message msg;
|
|
unsigned long spi_data =
|
|
1 << 23 | block << 18 | addr << 10;
|
|
|
|
mutex_lock(&ab4500->lock);
|
|
ab4500->tx_buf[0] = spi_data;
|
|
ab4500->rx_buf[0] = 0;
|
|
|
|
xfer.tx_buf = ab4500->tx_buf;
|
|
xfer.rx_buf = ab4500->rx_buf;
|
|
xfer.len = sizeof(unsigned long);
|
|
|
|
spi_message_init(&msg);
|
|
spi_message_add_tail(&xfer, &msg);
|
|
|
|
spi_sync(ab4500->spi, &msg);
|
|
mutex_unlock(&ab4500->lock);
|
|
|
|
return ab4500->rx_buf[0];
|
|
}
|
|
EXPORT_SYMBOL(ab4500_read);
|
|
|
|
/* ref: ab3100 core */
|
|
#define AB4500_DEVICE(devname, devid) \
|
|
static struct platform_device ab4500_##devname##_device = { \
|
|
.name = devid, \
|
|
.id = -1, \
|
|
}
|
|
|
|
/* list of childern devices of ab4500 - all are
|
|
* not populated here - TODO
|
|
*/
|
|
AB4500_DEVICE(charger, "ab4500-charger");
|
|
AB4500_DEVICE(audio, "ab4500-audio");
|
|
AB4500_DEVICE(usb, "ab4500-usb");
|
|
AB4500_DEVICE(tvout, "ab4500-tvout");
|
|
AB4500_DEVICE(sim, "ab4500-sim");
|
|
AB4500_DEVICE(gpadc, "ab4500-gpadc");
|
|
AB4500_DEVICE(clkmgt, "ab4500-clkmgt");
|
|
AB4500_DEVICE(misc, "ab4500-misc");
|
|
|
|
static struct platform_device *ab4500_platform_devs[] = {
|
|
&ab4500_charger_device,
|
|
&ab4500_audio_device,
|
|
&ab4500_usb_device,
|
|
&ab4500_tvout_device,
|
|
&ab4500_sim_device,
|
|
&ab4500_gpadc_device,
|
|
&ab4500_clkmgt_device,
|
|
&ab4500_misc_device,
|
|
};
|
|
|
|
static int __init ab4500_probe(struct spi_device *spi)
|
|
{
|
|
struct ab4500 *ab4500;
|
|
unsigned char revision;
|
|
int err = 0;
|
|
int i;
|
|
|
|
ab4500 = kzalloc(sizeof *ab4500, GFP_KERNEL);
|
|
if (!ab4500) {
|
|
dev_err(&spi->dev, "could not allocate AB4500\n");
|
|
err = -ENOMEM;
|
|
goto not_detect;
|
|
}
|
|
|
|
ab4500->spi = spi;
|
|
spi_set_drvdata(spi, ab4500);
|
|
|
|
mutex_init(&ab4500->lock);
|
|
|
|
/* read the revision register */
|
|
revision = ab4500_read(ab4500, AB4500_MISC, AB4500_REV_REG);
|
|
|
|
/* revision id 0x0 is for early drop, 0x10 is for cut1.0 */
|
|
if (revision == 0x0 || revision == 0x10)
|
|
dev_info(&spi->dev, "Detected chip: %s, revision = %x\n",
|
|
ab4500_driver.driver.name, revision);
|
|
else {
|
|
dev_err(&spi->dev, "unknown chip: 0x%x\n", revision);
|
|
goto not_detect;
|
|
}
|
|
|
|
for (i = 0; i < ARRAY_SIZE(ab4500_platform_devs); i++) {
|
|
ab4500_platform_devs[i]->dev.parent =
|
|
&spi->dev;
|
|
platform_set_drvdata(ab4500_platform_devs[i], ab4500);
|
|
}
|
|
|
|
/* register the ab4500 platform devices */
|
|
platform_add_devices(ab4500_platform_devs,
|
|
ARRAY_SIZE(ab4500_platform_devs));
|
|
|
|
return err;
|
|
|
|
not_detect:
|
|
spi_unregister_driver(&ab4500_driver);
|
|
kfree(ab4500);
|
|
return err;
|
|
}
|
|
|
|
static int __devexit ab4500_remove(struct spi_device *spi)
|
|
{
|
|
struct ab4500 *ab4500 =
|
|
spi_get_drvdata(spi);
|
|
|
|
kfree(ab4500);
|
|
|
|
return 0;
|
|
}
|
|
|
|
static struct spi_driver ab4500_driver = {
|
|
.driver = {
|
|
.name = "ab4500",
|
|
.owner = THIS_MODULE,
|
|
},
|
|
.probe = ab4500_probe,
|
|
.remove = __devexit_p(ab4500_remove)
|
|
};
|
|
|
|
static int __devinit ab4500_init(void)
|
|
{
|
|
return spi_register_driver(&ab4500_driver);
|
|
}
|
|
|
|
static void __exit ab4500_exit(void)
|
|
{
|
|
spi_unregister_driver(&ab4500_driver);
|
|
}
|
|
|
|
subsys_initcall(ab4500_init);
|
|
module_exit(ab4500_exit);
|
|
|
|
MODULE_AUTHOR("Srinidhi KASAGAR <srinidhi.kasagar@stericsson.com");
|
|
MODULE_DESCRIPTION("AB4500 core driver");
|
|
MODULE_LICENSE("GPL");
|