mirror of
https://github.com/edk2-porting/linux-next.git
synced 2024-12-25 13:43:55 +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>
226 lines
5.6 KiB
C
226 lines
5.6 KiB
C
/*
|
|
* pcap rtc code for Motorola EZX phones
|
|
*
|
|
* Copyright (c) 2008 guiming zhuo <gmzhuo@gmail.com>
|
|
* Copyright (c) 2009 Daniel Ribeiro <drwyrm@gmail.com>
|
|
*
|
|
* Based on Motorola's rtc.c Copyright (c) 2003-2005 Motorola
|
|
*
|
|
* 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/kernel.h>
|
|
#include <linux/module.h>
|
|
#include <linux/init.h>
|
|
#include <linux/mfd/ezx-pcap.h>
|
|
#include <linux/rtc.h>
|
|
#include <linux/slab.h>
|
|
#include <linux/platform_device.h>
|
|
|
|
struct pcap_rtc {
|
|
struct pcap_chip *pcap;
|
|
struct rtc_device *rtc;
|
|
};
|
|
|
|
static irqreturn_t pcap_rtc_irq(int irq, void *_pcap_rtc)
|
|
{
|
|
struct pcap_rtc *pcap_rtc = _pcap_rtc;
|
|
unsigned long rtc_events;
|
|
|
|
if (irq == pcap_to_irq(pcap_rtc->pcap, PCAP_IRQ_1HZ))
|
|
rtc_events = RTC_IRQF | RTC_UF;
|
|
else if (irq == pcap_to_irq(pcap_rtc->pcap, PCAP_IRQ_TODA))
|
|
rtc_events = RTC_IRQF | RTC_AF;
|
|
else
|
|
rtc_events = 0;
|
|
|
|
rtc_update_irq(pcap_rtc->rtc, 1, rtc_events);
|
|
return IRQ_HANDLED;
|
|
}
|
|
|
|
static int pcap_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm)
|
|
{
|
|
struct platform_device *pdev = to_platform_device(dev);
|
|
struct pcap_rtc *pcap_rtc = platform_get_drvdata(pdev);
|
|
struct rtc_time *tm = &alrm->time;
|
|
unsigned long secs;
|
|
u32 tod; /* time of day, seconds since midnight */
|
|
u32 days; /* days since 1/1/1970 */
|
|
|
|
ezx_pcap_read(pcap_rtc->pcap, PCAP_REG_RTC_TODA, &tod);
|
|
secs = tod & PCAP_RTC_TOD_MASK;
|
|
|
|
ezx_pcap_read(pcap_rtc->pcap, PCAP_REG_RTC_DAYA, &days);
|
|
secs += (days & PCAP_RTC_DAY_MASK) * SEC_PER_DAY;
|
|
|
|
rtc_time_to_tm(secs, tm);
|
|
|
|
return 0;
|
|
}
|
|
|
|
static int pcap_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm)
|
|
{
|
|
struct platform_device *pdev = to_platform_device(dev);
|
|
struct pcap_rtc *pcap_rtc = platform_get_drvdata(pdev);
|
|
struct rtc_time *tm = &alrm->time;
|
|
unsigned long secs;
|
|
u32 tod, days;
|
|
|
|
rtc_tm_to_time(tm, &secs);
|
|
|
|
tod = secs % SEC_PER_DAY;
|
|
ezx_pcap_write(pcap_rtc->pcap, PCAP_REG_RTC_TODA, tod);
|
|
|
|
days = secs / SEC_PER_DAY;
|
|
ezx_pcap_write(pcap_rtc->pcap, PCAP_REG_RTC_DAYA, days);
|
|
|
|
return 0;
|
|
}
|
|
|
|
static int pcap_rtc_read_time(struct device *dev, struct rtc_time *tm)
|
|
{
|
|
struct platform_device *pdev = to_platform_device(dev);
|
|
struct pcap_rtc *pcap_rtc = platform_get_drvdata(pdev);
|
|
unsigned long secs;
|
|
u32 tod, days;
|
|
|
|
ezx_pcap_read(pcap_rtc->pcap, PCAP_REG_RTC_TOD, &tod);
|
|
secs = tod & PCAP_RTC_TOD_MASK;
|
|
|
|
ezx_pcap_read(pcap_rtc->pcap, PCAP_REG_RTC_DAY, &days);
|
|
secs += (days & PCAP_RTC_DAY_MASK) * SEC_PER_DAY;
|
|
|
|
rtc_time_to_tm(secs, tm);
|
|
|
|
return rtc_valid_tm(tm);
|
|
}
|
|
|
|
static int pcap_rtc_set_mmss(struct device *dev, unsigned long secs)
|
|
{
|
|
struct platform_device *pdev = to_platform_device(dev);
|
|
struct pcap_rtc *pcap_rtc = platform_get_drvdata(pdev);
|
|
u32 tod, days;
|
|
|
|
tod = secs % SEC_PER_DAY;
|
|
ezx_pcap_write(pcap_rtc->pcap, PCAP_REG_RTC_TOD, tod);
|
|
|
|
days = secs / SEC_PER_DAY;
|
|
ezx_pcap_write(pcap_rtc->pcap, PCAP_REG_RTC_DAY, days);
|
|
|
|
return 0;
|
|
}
|
|
|
|
static int pcap_rtc_irq_enable(struct device *dev, int pirq, unsigned int en)
|
|
{
|
|
struct platform_device *pdev = to_platform_device(dev);
|
|
struct pcap_rtc *pcap_rtc = platform_get_drvdata(pdev);
|
|
|
|
if (en)
|
|
enable_irq(pcap_to_irq(pcap_rtc->pcap, pirq));
|
|
else
|
|
disable_irq(pcap_to_irq(pcap_rtc->pcap, pirq));
|
|
|
|
return 0;
|
|
}
|
|
|
|
static int pcap_rtc_alarm_irq_enable(struct device *dev, unsigned int en)
|
|
{
|
|
return pcap_rtc_irq_enable(dev, PCAP_IRQ_TODA, en);
|
|
}
|
|
|
|
static int pcap_rtc_update_irq_enable(struct device *dev, unsigned int en)
|
|
{
|
|
return pcap_rtc_irq_enable(dev, PCAP_IRQ_1HZ, en);
|
|
}
|
|
|
|
static const struct rtc_class_ops pcap_rtc_ops = {
|
|
.read_time = pcap_rtc_read_time,
|
|
.read_alarm = pcap_rtc_read_alarm,
|
|
.set_alarm = pcap_rtc_set_alarm,
|
|
.set_mmss = pcap_rtc_set_mmss,
|
|
.alarm_irq_enable = pcap_rtc_alarm_irq_enable,
|
|
.update_irq_enable = pcap_rtc_update_irq_enable,
|
|
};
|
|
|
|
static int __devinit pcap_rtc_probe(struct platform_device *pdev)
|
|
{
|
|
struct pcap_rtc *pcap_rtc;
|
|
int timer_irq, alarm_irq;
|
|
int err = -ENOMEM;
|
|
|
|
pcap_rtc = kmalloc(sizeof(struct pcap_rtc), GFP_KERNEL);
|
|
if (!pcap_rtc)
|
|
return err;
|
|
|
|
pcap_rtc->pcap = dev_get_drvdata(pdev->dev.parent);
|
|
|
|
pcap_rtc->rtc = rtc_device_register("pcap", &pdev->dev,
|
|
&pcap_rtc_ops, THIS_MODULE);
|
|
if (IS_ERR(pcap_rtc->rtc)) {
|
|
err = PTR_ERR(pcap_rtc->rtc);
|
|
goto fail_rtc;
|
|
}
|
|
|
|
platform_set_drvdata(pdev, pcap_rtc);
|
|
|
|
timer_irq = pcap_to_irq(pcap_rtc->pcap, PCAP_IRQ_1HZ);
|
|
alarm_irq = pcap_to_irq(pcap_rtc->pcap, PCAP_IRQ_TODA);
|
|
|
|
err = request_irq(timer_irq, pcap_rtc_irq, 0, "RTC Timer", pcap_rtc);
|
|
if (err)
|
|
goto fail_timer;
|
|
|
|
err = request_irq(alarm_irq, pcap_rtc_irq, 0, "RTC Alarm", pcap_rtc);
|
|
if (err)
|
|
goto fail_alarm;
|
|
|
|
return 0;
|
|
fail_alarm:
|
|
free_irq(timer_irq, pcap_rtc);
|
|
fail_timer:
|
|
rtc_device_unregister(pcap_rtc->rtc);
|
|
fail_rtc:
|
|
kfree(pcap_rtc);
|
|
return err;
|
|
}
|
|
|
|
static int __devexit pcap_rtc_remove(struct platform_device *pdev)
|
|
{
|
|
struct pcap_rtc *pcap_rtc = platform_get_drvdata(pdev);
|
|
|
|
free_irq(pcap_to_irq(pcap_rtc->pcap, PCAP_IRQ_1HZ), pcap_rtc);
|
|
free_irq(pcap_to_irq(pcap_rtc->pcap, PCAP_IRQ_TODA), pcap_rtc);
|
|
rtc_device_unregister(pcap_rtc->rtc);
|
|
kfree(pcap_rtc);
|
|
|
|
return 0;
|
|
}
|
|
|
|
static struct platform_driver pcap_rtc_driver = {
|
|
.remove = __devexit_p(pcap_rtc_remove),
|
|
.driver = {
|
|
.name = "pcap-rtc",
|
|
.owner = THIS_MODULE,
|
|
},
|
|
};
|
|
|
|
static int __init rtc_pcap_init(void)
|
|
{
|
|
return platform_driver_probe(&pcap_rtc_driver, pcap_rtc_probe);
|
|
}
|
|
|
|
static void __exit rtc_pcap_exit(void)
|
|
{
|
|
platform_driver_unregister(&pcap_rtc_driver);
|
|
}
|
|
|
|
module_init(rtc_pcap_init);
|
|
module_exit(rtc_pcap_exit);
|
|
|
|
MODULE_DESCRIPTION("Motorola pcap rtc driver");
|
|
MODULE_AUTHOR("guiming zhuo <gmzhuo@gmail.com>");
|
|
MODULE_LICENSE("GPL");
|