mirror of
https://github.com/edk2-porting/linux-next.git
synced 2024-12-27 14:43:58 +08:00
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>
218 lines
5.2 KiB
C
218 lines
5.2 KiB
C
/*
|
|
* A driver for the RTC embedded in the Cirrus Logic EP93XX processors
|
|
* Copyright (c) 2006 Tower Technologies
|
|
*
|
|
* Author: Alessandro Zummo <a.zummo@towertech.it>
|
|
*
|
|
* 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.
|
|
*/
|
|
|
|
#include <linux/module.h>
|
|
#include <linux/rtc.h>
|
|
#include <linux/platform_device.h>
|
|
#include <linux/io.h>
|
|
#include <linux/gfp.h>
|
|
|
|
#define EP93XX_RTC_DATA 0x000
|
|
#define EP93XX_RTC_MATCH 0x004
|
|
#define EP93XX_RTC_STATUS 0x008
|
|
#define EP93XX_RTC_STATUS_INTR (1<<0)
|
|
#define EP93XX_RTC_LOAD 0x00C
|
|
#define EP93XX_RTC_CONTROL 0x010
|
|
#define EP93XX_RTC_CONTROL_MIE (1<<0)
|
|
#define EP93XX_RTC_SWCOMP 0x108
|
|
#define EP93XX_RTC_SWCOMP_DEL_MASK 0x001f0000
|
|
#define EP93XX_RTC_SWCOMP_DEL_SHIFT 16
|
|
#define EP93XX_RTC_SWCOMP_INT_MASK 0x0000ffff
|
|
#define EP93XX_RTC_SWCOMP_INT_SHIFT 0
|
|
|
|
#define DRV_VERSION "0.3"
|
|
|
|
/*
|
|
* struct device dev.platform_data is used to store our private data
|
|
* because struct rtc_device does not have a variable to hold it.
|
|
*/
|
|
struct ep93xx_rtc {
|
|
void __iomem *mmio_base;
|
|
};
|
|
|
|
static int ep93xx_rtc_get_swcomp(struct device *dev, unsigned short *preload,
|
|
unsigned short *delete)
|
|
{
|
|
struct ep93xx_rtc *ep93xx_rtc = dev->platform_data;
|
|
unsigned long comp;
|
|
|
|
comp = __raw_readl(ep93xx_rtc->mmio_base + EP93XX_RTC_SWCOMP);
|
|
|
|
if (preload)
|
|
*preload = (comp & EP93XX_RTC_SWCOMP_INT_MASK)
|
|
>> EP93XX_RTC_SWCOMP_INT_SHIFT;
|
|
|
|
if (delete)
|
|
*delete = (comp & EP93XX_RTC_SWCOMP_DEL_MASK)
|
|
>> EP93XX_RTC_SWCOMP_DEL_SHIFT;
|
|
|
|
return 0;
|
|
}
|
|
|
|
static int ep93xx_rtc_read_time(struct device *dev, struct rtc_time *tm)
|
|
{
|
|
struct ep93xx_rtc *ep93xx_rtc = dev->platform_data;
|
|
unsigned long time;
|
|
|
|
time = __raw_readl(ep93xx_rtc->mmio_base + EP93XX_RTC_DATA);
|
|
|
|
rtc_time_to_tm(time, tm);
|
|
return 0;
|
|
}
|
|
|
|
static int ep93xx_rtc_set_mmss(struct device *dev, unsigned long secs)
|
|
{
|
|
struct ep93xx_rtc *ep93xx_rtc = dev->platform_data;
|
|
|
|
__raw_writel(secs + 1, ep93xx_rtc->mmio_base + EP93XX_RTC_LOAD);
|
|
return 0;
|
|
}
|
|
|
|
static int ep93xx_rtc_proc(struct device *dev, struct seq_file *seq)
|
|
{
|
|
unsigned short preload, delete;
|
|
|
|
ep93xx_rtc_get_swcomp(dev, &preload, &delete);
|
|
|
|
seq_printf(seq, "preload\t\t: %d\n", preload);
|
|
seq_printf(seq, "delete\t\t: %d\n", delete);
|
|
|
|
return 0;
|
|
}
|
|
|
|
static const struct rtc_class_ops ep93xx_rtc_ops = {
|
|
.read_time = ep93xx_rtc_read_time,
|
|
.set_mmss = ep93xx_rtc_set_mmss,
|
|
.proc = ep93xx_rtc_proc,
|
|
};
|
|
|
|
static ssize_t ep93xx_rtc_show_comp_preload(struct device *dev,
|
|
struct device_attribute *attr, char *buf)
|
|
{
|
|
unsigned short preload;
|
|
|
|
ep93xx_rtc_get_swcomp(dev, &preload, NULL);
|
|
|
|
return sprintf(buf, "%d\n", preload);
|
|
}
|
|
static DEVICE_ATTR(comp_preload, S_IRUGO, ep93xx_rtc_show_comp_preload, NULL);
|
|
|
|
static ssize_t ep93xx_rtc_show_comp_delete(struct device *dev,
|
|
struct device_attribute *attr, char *buf)
|
|
{
|
|
unsigned short delete;
|
|
|
|
ep93xx_rtc_get_swcomp(dev, NULL, &delete);
|
|
|
|
return sprintf(buf, "%d\n", delete);
|
|
}
|
|
static DEVICE_ATTR(comp_delete, S_IRUGO, ep93xx_rtc_show_comp_delete, NULL);
|
|
|
|
static struct attribute *ep93xx_rtc_attrs[] = {
|
|
&dev_attr_comp_preload.attr,
|
|
&dev_attr_comp_delete.attr,
|
|
NULL
|
|
};
|
|
|
|
static const struct attribute_group ep93xx_rtc_sysfs_files = {
|
|
.attrs = ep93xx_rtc_attrs,
|
|
};
|
|
|
|
static int __init ep93xx_rtc_probe(struct platform_device *pdev)
|
|
{
|
|
struct ep93xx_rtc *ep93xx_rtc;
|
|
struct resource *res;
|
|
struct rtc_device *rtc;
|
|
int err;
|
|
|
|
ep93xx_rtc = devm_kzalloc(&pdev->dev, sizeof(*ep93xx_rtc), GFP_KERNEL);
|
|
if (!ep93xx_rtc)
|
|
return -ENOMEM;
|
|
|
|
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
|
|
if (!res)
|
|
return -ENXIO;
|
|
|
|
if (!devm_request_mem_region(&pdev->dev, res->start,
|
|
resource_size(res), pdev->name))
|
|
return -EBUSY;
|
|
|
|
ep93xx_rtc->mmio_base = devm_ioremap(&pdev->dev, res->start,
|
|
resource_size(res));
|
|
if (!ep93xx_rtc->mmio_base)
|
|
return -ENXIO;
|
|
|
|
pdev->dev.platform_data = ep93xx_rtc;
|
|
|
|
rtc = rtc_device_register(pdev->name,
|
|
&pdev->dev, &ep93xx_rtc_ops, THIS_MODULE);
|
|
if (IS_ERR(rtc)) {
|
|
err = PTR_ERR(rtc);
|
|
goto exit;
|
|
}
|
|
|
|
platform_set_drvdata(pdev, rtc);
|
|
|
|
err = sysfs_create_group(&pdev->dev.kobj, &ep93xx_rtc_sysfs_files);
|
|
if (err)
|
|
goto fail;
|
|
|
|
return 0;
|
|
|
|
fail:
|
|
platform_set_drvdata(pdev, NULL);
|
|
rtc_device_unregister(rtc);
|
|
exit:
|
|
pdev->dev.platform_data = NULL;
|
|
return err;
|
|
}
|
|
|
|
static int __exit ep93xx_rtc_remove(struct platform_device *pdev)
|
|
{
|
|
struct rtc_device *rtc = platform_get_drvdata(pdev);
|
|
|
|
sysfs_remove_group(&pdev->dev.kobj, &ep93xx_rtc_sysfs_files);
|
|
platform_set_drvdata(pdev, NULL);
|
|
rtc_device_unregister(rtc);
|
|
pdev->dev.platform_data = NULL;
|
|
|
|
return 0;
|
|
}
|
|
|
|
/* work with hotplug and coldplug */
|
|
MODULE_ALIAS("platform:ep93xx-rtc");
|
|
|
|
static struct platform_driver ep93xx_rtc_driver = {
|
|
.driver = {
|
|
.name = "ep93xx-rtc",
|
|
.owner = THIS_MODULE,
|
|
},
|
|
.remove = __exit_p(ep93xx_rtc_remove),
|
|
};
|
|
|
|
static int __init ep93xx_rtc_init(void)
|
|
{
|
|
return platform_driver_probe(&ep93xx_rtc_driver, ep93xx_rtc_probe);
|
|
}
|
|
|
|
static void __exit ep93xx_rtc_exit(void)
|
|
{
|
|
platform_driver_unregister(&ep93xx_rtc_driver);
|
|
}
|
|
|
|
MODULE_AUTHOR("Alessandro Zummo <a.zummo@towertech.it>");
|
|
MODULE_DESCRIPTION("EP93XX RTC driver");
|
|
MODULE_LICENSE("GPL");
|
|
MODULE_VERSION(DRV_VERSION);
|
|
|
|
module_init(ep93xx_rtc_init);
|
|
module_exit(ep93xx_rtc_exit);
|