mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-11-26 00:20:51 +07: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>
233 lines
4.8 KiB
C
233 lines
4.8 KiB
C
/* rtc-bq4802.c: TI BQ4802 RTC driver.
|
|
*
|
|
* Copyright (C) 2008 David S. Miller <davem@davemloft.net>
|
|
*/
|
|
|
|
#include <linux/kernel.h>
|
|
#include <linux/module.h>
|
|
#include <linux/init.h>
|
|
#include <linux/io.h>
|
|
#include <linux/platform_device.h>
|
|
#include <linux/rtc.h>
|
|
#include <linux/bcd.h>
|
|
#include <linux/slab.h>
|
|
|
|
MODULE_AUTHOR("David S. Miller <davem@davemloft.net>");
|
|
MODULE_DESCRIPTION("TI BQ4802 RTC driver");
|
|
MODULE_LICENSE("GPL");
|
|
|
|
struct bq4802 {
|
|
void __iomem *regs;
|
|
unsigned long ioport;
|
|
struct rtc_device *rtc;
|
|
spinlock_t lock;
|
|
struct resource *r;
|
|
u8 (*read)(struct bq4802 *, int);
|
|
void (*write)(struct bq4802 *, int, u8);
|
|
};
|
|
|
|
static u8 bq4802_read_io(struct bq4802 *p, int off)
|
|
{
|
|
return inb(p->ioport + off);
|
|
}
|
|
|
|
static void bq4802_write_io(struct bq4802 *p, int off, u8 val)
|
|
{
|
|
outb(val, p->ioport + off);
|
|
}
|
|
|
|
static u8 bq4802_read_mem(struct bq4802 *p, int off)
|
|
{
|
|
return readb(p->regs + off);
|
|
}
|
|
|
|
static void bq4802_write_mem(struct bq4802 *p, int off, u8 val)
|
|
{
|
|
writeb(val, p->regs + off);
|
|
}
|
|
|
|
static int bq4802_read_time(struct device *dev, struct rtc_time *tm)
|
|
{
|
|
struct platform_device *pdev = to_platform_device(dev);
|
|
struct bq4802 *p = platform_get_drvdata(pdev);
|
|
unsigned long flags;
|
|
unsigned int century;
|
|
u8 val;
|
|
|
|
spin_lock_irqsave(&p->lock, flags);
|
|
|
|
val = p->read(p, 0x0e);
|
|
p->write(p, 0xe, val | 0x08);
|
|
|
|
tm->tm_sec = p->read(p, 0x00);
|
|
tm->tm_min = p->read(p, 0x02);
|
|
tm->tm_hour = p->read(p, 0x04);
|
|
tm->tm_mday = p->read(p, 0x06);
|
|
tm->tm_mon = p->read(p, 0x09);
|
|
tm->tm_year = p->read(p, 0x0a);
|
|
tm->tm_wday = p->read(p, 0x08);
|
|
century = p->read(p, 0x0f);
|
|
|
|
p->write(p, 0x0e, val);
|
|
|
|
spin_unlock_irqrestore(&p->lock, flags);
|
|
|
|
tm->tm_sec = bcd2bin(tm->tm_sec);
|
|
tm->tm_min = bcd2bin(tm->tm_min);
|
|
tm->tm_hour = bcd2bin(tm->tm_hour);
|
|
tm->tm_mday = bcd2bin(tm->tm_mday);
|
|
tm->tm_mon = bcd2bin(tm->tm_mon);
|
|
tm->tm_year = bcd2bin(tm->tm_year);
|
|
tm->tm_wday = bcd2bin(tm->tm_wday);
|
|
century = bcd2bin(century);
|
|
|
|
tm->tm_year += (century * 100);
|
|
tm->tm_year -= 1900;
|
|
|
|
tm->tm_mon--;
|
|
|
|
return 0;
|
|
}
|
|
|
|
static int bq4802_set_time(struct device *dev, struct rtc_time *tm)
|
|
{
|
|
struct platform_device *pdev = to_platform_device(dev);
|
|
struct bq4802 *p = platform_get_drvdata(pdev);
|
|
u8 sec, min, hrs, day, mon, yrs, century, val;
|
|
unsigned long flags;
|
|
unsigned int year;
|
|
|
|
year = tm->tm_year + 1900;
|
|
century = year / 100;
|
|
yrs = year % 100;
|
|
|
|
mon = tm->tm_mon + 1; /* tm_mon starts at zero */
|
|
day = tm->tm_mday;
|
|
hrs = tm->tm_hour;
|
|
min = tm->tm_min;
|
|
sec = tm->tm_sec;
|
|
|
|
sec = bin2bcd(sec);
|
|
min = bin2bcd(min);
|
|
hrs = bin2bcd(hrs);
|
|
day = bin2bcd(day);
|
|
mon = bin2bcd(mon);
|
|
yrs = bin2bcd(yrs);
|
|
century = bin2bcd(century);
|
|
|
|
spin_lock_irqsave(&p->lock, flags);
|
|
|
|
val = p->read(p, 0x0e);
|
|
p->write(p, 0x0e, val | 0x08);
|
|
|
|
p->write(p, 0x00, sec);
|
|
p->write(p, 0x02, min);
|
|
p->write(p, 0x04, hrs);
|
|
p->write(p, 0x06, day);
|
|
p->write(p, 0x09, mon);
|
|
p->write(p, 0x0a, yrs);
|
|
p->write(p, 0x0f, century);
|
|
|
|
p->write(p, 0x0e, val);
|
|
|
|
spin_unlock_irqrestore(&p->lock, flags);
|
|
|
|
return 0;
|
|
}
|
|
|
|
static const struct rtc_class_ops bq4802_ops = {
|
|
.read_time = bq4802_read_time,
|
|
.set_time = bq4802_set_time,
|
|
};
|
|
|
|
static int __devinit bq4802_probe(struct platform_device *pdev)
|
|
{
|
|
struct bq4802 *p = kzalloc(sizeof(*p), GFP_KERNEL);
|
|
int err = -ENOMEM;
|
|
|
|
if (!p)
|
|
goto out;
|
|
|
|
spin_lock_init(&p->lock);
|
|
|
|
p->r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
|
|
if (!p->r) {
|
|
p->r = platform_get_resource(pdev, IORESOURCE_IO, 0);
|
|
err = -EINVAL;
|
|
if (!p->r)
|
|
goto out_free;
|
|
}
|
|
if (p->r->flags & IORESOURCE_IO) {
|
|
p->ioport = p->r->start;
|
|
p->read = bq4802_read_io;
|
|
p->write = bq4802_write_io;
|
|
} else if (p->r->flags & IORESOURCE_MEM) {
|
|
p->regs = ioremap(p->r->start, resource_size(p->r));
|
|
p->read = bq4802_read_mem;
|
|
p->write = bq4802_write_mem;
|
|
} else {
|
|
err = -EINVAL;
|
|
goto out_free;
|
|
}
|
|
|
|
platform_set_drvdata(pdev, p);
|
|
|
|
p->rtc = rtc_device_register("bq4802", &pdev->dev,
|
|
&bq4802_ops, THIS_MODULE);
|
|
if (IS_ERR(p->rtc)) {
|
|
err = PTR_ERR(p->rtc);
|
|
goto out_iounmap;
|
|
}
|
|
|
|
err = 0;
|
|
out:
|
|
return err;
|
|
|
|
out_iounmap:
|
|
if (p->r->flags & IORESOURCE_MEM)
|
|
iounmap(p->regs);
|
|
out_free:
|
|
kfree(p);
|
|
goto out;
|
|
}
|
|
|
|
static int __devexit bq4802_remove(struct platform_device *pdev)
|
|
{
|
|
struct bq4802 *p = platform_get_drvdata(pdev);
|
|
|
|
rtc_device_unregister(p->rtc);
|
|
if (p->r->flags & IORESOURCE_MEM)
|
|
iounmap(p->regs);
|
|
|
|
platform_set_drvdata(pdev, NULL);
|
|
|
|
kfree(p);
|
|
|
|
return 0;
|
|
}
|
|
|
|
/* work with hotplug and coldplug */
|
|
MODULE_ALIAS("platform:rtc-bq4802");
|
|
|
|
static struct platform_driver bq4802_driver = {
|
|
.driver = {
|
|
.name = "rtc-bq4802",
|
|
.owner = THIS_MODULE,
|
|
},
|
|
.probe = bq4802_probe,
|
|
.remove = __devexit_p(bq4802_remove),
|
|
};
|
|
|
|
static int __init bq4802_init(void)
|
|
{
|
|
return platform_driver_register(&bq4802_driver);
|
|
}
|
|
|
|
static void __exit bq4802_exit(void)
|
|
{
|
|
platform_driver_unregister(&bq4802_driver);
|
|
}
|
|
|
|
module_init(bq4802_init);
|
|
module_exit(bq4802_exit);
|