From 8a4553d3a9ff0ad49360ee5ac210d870e5c272e2 Mon Sep 17 00:00:00 2001 From: "Sergey Semyonov (Serge)" Date: Thu, 27 Jul 2017 10:22:14 +0000 Subject: [PATCH] ddk: v4.4.78 git-svn-id: svn://kolibrios.org@6934 a494cfbc-eb01-0410-851d-a64ba20cac60 --- drivers/ddk/linux/ctype.c | 3 +- drivers/ddk/linux/div64.c | 162 ++++++++++ drivers/ddk/linux/dmapool.c | 4 +- drivers/ddk/linux/dmi.c | 117 +++++-- drivers/ddk/linux/hdmi.c | 23 +- drivers/ddk/linux/idr.c | 1 + drivers/ddk/linux/interval_tree.c | 4 +- drivers/ddk/linux/list_sort.c | 6 +- drivers/ddk/linux/rbtree.c | 76 +++-- drivers/ddk/linux/string.c | 6 +- drivers/ddk/linux/time.c | 19 -- drivers/include/asm/timex.h | 12 + drivers/include/asm/vga.h | 20 ++ drivers/include/drm/drmP.h | 3 +- drivers/include/linux/clocksource.h | 1 + drivers/include/linux/compiler-gcc.h | 4 +- drivers/include/linux/cpumask.h | 8 +- drivers/include/linux/export.h | 9 + drivers/include/linux/file.h | 6 + drivers/include/linux/hash.h | 20 +- drivers/include/linux/interrupt.h | 1 + drivers/include/linux/io.h | 28 +- drivers/include/linux/jiffies.h | 2 +- drivers/include/linux/kernel.h | 42 +-- drivers/include/linux/list.h | 5 +- drivers/include/linux/log2.h | 26 +- drivers/include/linux/module.h | 1 + drivers/include/linux/moduleparam.h | 1 + drivers/include/linux/pci.h | 6 + drivers/include/linux/pci_ids.h | 7 + drivers/include/linux/personality.h | 36 --- drivers/include/linux/pm.h | 2 +- drivers/include/linux/scatterlist.h | 1 + drivers/include/linux/seqlock.h | 2 +- drivers/include/linux/string.h | 6 +- drivers/include/linux/swap.h | 3 + drivers/include/linux/sysfs.h | 1 + drivers/include/linux/time.h | 26 ++ drivers/include/linux/timer.h | 16 + drivers/include/linux/timex.h | 6 +- drivers/include/linux/uaccess.h | 20 ++ drivers/include/linux/vgaarb.h | 2 +- drivers/include/linux/vmalloc.h | 2 + drivers/include/linux/workqueue.h | 2 +- drivers/include/uapi/linux/timex.h | 166 ++++++++++ drivers/include/video/vga.h | 459 +++++++++++++++++++++++++++ 46 files changed, 1204 insertions(+), 169 deletions(-) create mode 100644 drivers/include/asm/timex.h create mode 100644 drivers/include/asm/vga.h create mode 100644 drivers/include/linux/timer.h create mode 100644 drivers/include/linux/uaccess.h create mode 100644 drivers/include/uapi/linux/timex.h create mode 100644 drivers/include/video/vga.h diff --git a/drivers/ddk/linux/ctype.c b/drivers/ddk/linux/ctype.c index 2242d4d5ee..1926f0ddc3 100644 --- a/drivers/ddk/linux/ctype.c +++ b/drivers/ddk/linux/ctype.c @@ -5,7 +5,8 @@ */ #include -#include +#include +#include const unsigned char _ctype[] = { _C,_C,_C,_C,_C,_C,_C,_C, /* 0-7 */ diff --git a/drivers/ddk/linux/div64.c b/drivers/ddk/linux/div64.c index c9d67f8e2c..7a96b80a66 100644 --- a/drivers/ddk/linux/div64.c +++ b/drivers/ddk/linux/div64.c @@ -1,7 +1,64 @@ +/* + * Copyright (C) 2003 Bernardo Innocenti + * + * Based on former do_div() implementation from asm-parisc/div64.h: + * Copyright (C) 1999 Hewlett-Packard Co + * Copyright (C) 1999 David Mosberger-Tang + * + * + * Generic C version of 64bit/32bit division and modulo, with + * 64bit result and 32bit remainder. + * + * The fast case for (n>>32 == 0) is handled inline by do_div(). + * + * Code generated for this function might be very inefficient + * for some CPUs. __div64_32() can be overridden by linking arch-specific + * assembly versions such as arch/ppc/lib/div64.S and arch/sh/lib/div64.S. + */ + #include #include #include +/* Not needed on 64bit architectures */ +#if BITS_PER_LONG == 32 + +uint32_t __attribute__((weak)) __div64_32(uint64_t *n, uint32_t base) +{ + uint64_t rem = *n; + uint64_t b = base; + uint64_t res, d = 1; + uint32_t high = rem >> 32; + + /* Reduce the thing a bit first */ + res = 0; + if (high >= base) { + high /= base; + res = (uint64_t) high << 32; + rem -= (uint64_t) (high*base) << 32; + } + + while ((int64_t)b > 0 && b < rem) { + b = b+b; + d = d+d; + } + + do { + if (rem >= b) { + rem -= b; + res += d; + } + b >>= 1; + d >>= 1; + } while (d); + + *n = res; + return rem; +} + +EXPORT_SYMBOL(__div64_32); + +#ifndef div_s64_rem s64 div_s64_rem(s64 dividend, s32 divisor, s32 *remainder) { u64 quotient; @@ -18,4 +75,109 @@ s64 div_s64_rem(s64 dividend, s32 divisor, s32 *remainder) } return quotient; } +EXPORT_SYMBOL(div_s64_rem); +#endif +/** + * div64_u64_rem - unsigned 64bit divide with 64bit divisor and remainder + * @dividend: 64bit dividend + * @divisor: 64bit divisor + * @remainder: 64bit remainder + * + * This implementation is a comparable to algorithm used by div64_u64. + * But this operation, which includes math for calculating the remainder, + * is kept distinct to avoid slowing down the div64_u64 operation on 32bit + * systems. + */ +#ifndef div64_u64_rem +u64 div64_u64_rem(u64 dividend, u64 divisor, u64 *remainder) +{ + u32 high = divisor >> 32; + u64 quot; + + if (high == 0) { + u32 rem32; + quot = div_u64_rem(dividend, divisor, &rem32); + *remainder = rem32; + } else { + int n = 1 + fls(high); + quot = div_u64(dividend >> n, divisor >> n); + + if (quot != 0) + quot--; + + *remainder = dividend - quot * divisor; + if (*remainder >= divisor) { + quot++; + *remainder -= divisor; + } + } + + return quot; +} +EXPORT_SYMBOL(div64_u64_rem); +#endif + +/** + * div64_u64 - unsigned 64bit divide with 64bit divisor + * @dividend: 64bit dividend + * @divisor: 64bit divisor + * + * This implementation is a modified version of the algorithm proposed + * by the book 'Hacker's Delight'. The original source and full proof + * can be found here and is available for use without restriction. + * + * 'http://www.hackersdelight.org/hdcodetxt/divDouble.c.txt' + */ +#ifndef div64_u64 +u64 div64_u64(u64 dividend, u64 divisor) +{ + u32 high = divisor >> 32; + u64 quot; + + if (high == 0) { + quot = div_u64(dividend, divisor); + } else { + int n = 1 + fls(high); + quot = div_u64(dividend >> n, divisor >> n); + + if (quot != 0) + quot--; + if ((dividend - quot * divisor) >= divisor) + quot++; + } + + return quot; +} +EXPORT_SYMBOL(div64_u64); +#endif + +/** + * div64_s64 - signed 64bit divide with 64bit divisor + * @dividend: 64bit dividend + * @divisor: 64bit divisor + */ +#ifndef div64_s64 +s64 div64_s64(s64 dividend, s64 divisor) +{ + s64 quot, t; + + quot = div64_u64(abs(dividend), abs(divisor)); + t = (dividend ^ divisor) >> 63; + + return (quot ^ t) - t; +} +EXPORT_SYMBOL(div64_s64); +#endif + +#endif /* BITS_PER_LONG == 32 */ + +/* + * Iterative div/mod for use when dividend is not expected to be much + * bigger than divisor. + */ +u32 iter_div_u64_rem(u64 dividend, u32 divisor, u64 *remainder) +{ + return __iter_div_u64_rem(dividend, divisor, remainder); +} +EXPORT_SYMBOL(iter_div_u64_rem); diff --git a/drivers/ddk/linux/dmapool.c b/drivers/ddk/linux/dmapool.c index 3e06d3e85c..ecc8919984 100644 --- a/drivers/ddk/linux/dmapool.c +++ b/drivers/ddk/linux/dmapool.c @@ -26,14 +26,16 @@ #include #include #include +#include #include #include #include +#include #include +#include #include -#include #include diff --git a/drivers/ddk/linux/dmi.c b/drivers/ddk/linux/dmi.c index ddb207faf5..7b5a5c6f40 100644 --- a/drivers/ddk/linux/dmi.c +++ b/drivers/ddk/linux/dmi.c @@ -1,11 +1,12 @@ - #include #include -#include +#include #include #include #include +#include #include +struct kobject *dmi_kobj; static void *dmi_alloc(unsigned len) { @@ -19,14 +20,19 @@ static void *dmi_alloc(unsigned len) */ static const char dmi_empty_string[] = " "; -static u16 dmi_ver; +static u32 dmi_ver __initdata; +static u32 dmi_len; +static u16 dmi_num; +static u8 smbios_entry_point[32]; +static int smbios_entry_point_size; + /* * Catch too early calls to dmi_check_system(): */ static int dmi_initialized; /* DMI system identification string used during boot */ -static char dmi_ids_string[128]; +static char dmi_ids_string[128] __initdata; static struct dmi_memdev_info { const char *device; @@ -80,7 +86,7 @@ static const char * __init dmi_string(const struct dmi_header *dm, u8 s) * We have to be cautious here. We have seen BIOSes with DMI pointers * pointing to completely the wrong place for example */ -static void dmi_table(u8 *buf, int len, int num, +static void dmi_decode_table(u8 *buf, void (*decode)(const struct dmi_header *, void *), void *private_data) { @@ -88,10 +94,13 @@ static void dmi_table(u8 *buf, int len, int num, int i = 0; /* - * Stop when we see all the items the table claimed to have - * OR we run off the end of the table (also happens) + * Stop when we have seen all the items the table claimed to have + * (SMBIOS < 3.0 only) OR we reach an end-of-table marker (SMBIOS + * >= 3.0 only) OR we run off the end of the table (should never + * happen but sometimes does on bogus implementations.) */ - while ((i < num) && (data - buf + sizeof(struct dmi_header)) <= len) { + while ((!dmi_num || i < dmi_num) && + (data - buf + sizeof(struct dmi_header)) <= dmi_len) { const struct dmi_header *dm = (const struct dmi_header *)data; /* @@ -100,29 +109,44 @@ static void dmi_table(u8 *buf, int len, int num, * table in dmi_decode or dmi_string */ data += dm->length; - while ((data - buf < len - 1) && (data[0] || data[1])) + while ((data - buf < dmi_len - 1) && (data[0] || data[1])) data++; - if (data - buf < len - 1) + if (data - buf < dmi_len - 1) decode(dm, private_data); + data += 2; i++; + + /* + * 7.45 End-of-Table (Type 127) [SMBIOS reference spec v3.0.0] + * For tables behind a 64-bit entry point, we have no item + * count and no exact table length, so stop on end-of-table + * marker. For tables behind a 32-bit entry point, we have + * seen OEM structures behind the end-of-table marker on + * some systems, so don't trust it. + */ + if (!dmi_num && dm->type == DMI_ENTRY_END_OF_TABLE) + break; } + + /* Trim DMI table length if needed */ + if (dmi_len > data - buf) + dmi_len = data - buf; } -static u32 dmi_base; -static u16 dmi_len; -static u16 dmi_num; +static phys_addr_t dmi_base; static int __init dmi_walk_early(void (*decode)(const struct dmi_header *, void *)) { u8 *buf; + u32 orig_dmi_len = dmi_len; buf = (u8*)MapIoMem(dmi_base, dmi_len, PG_SW); if (buf == NULL) return -1; - dmi_table(buf, dmi_len, dmi_num, decode, NULL); + dmi_decode_table(buf, decode, NULL); FreeKernelSpace(buf); @@ -192,7 +216,7 @@ static void __init dmi_save_uuid(const struct dmi_header *dm, int slot, * the UUID are supposed to be little-endian encoded. The specification * says that this is the defacto standard. */ - if (dmi_ver >= 0x0206) + if (dmi_ver >= 0x020600) sprintf(s, "%pUL", d); else sprintf(s, "%pUB", d); @@ -329,7 +353,13 @@ static void __init dmi_save_extended_devices(const struct dmi_header *dm) dmi_save_dev_onboard(*(d+1), *(u16 *)(d+2), *(d+4), *(d+5), dmi_string_nosave(dm, *(d-1))); dmi_save_one_device(*d & 0x7f, dmi_string_nosave(dm, *(d - 1))); +} +static void __init count_mem_devices(const struct dmi_header *dm, void *v) +{ + if (dm->type != DMI_ENTRY_MEM_DEVICE) + return; + dmi_memdev_nr++; } /* @@ -429,11 +459,13 @@ static void __init dmi_format_ids(char *buf, size_t len) */ static int __init dmi_present(const u8 *buf) { - int smbios_ver; + u32 smbios_ver; if (memcmp(buf, "_SM_", 4) == 0 && buf[5] < 32 && dmi_checksum(buf, buf[5])) { - smbios_ver = (buf[6] << 8) + buf[7]; + smbios_ver = get_unaligned_be16(buf + 6); + smbios_entry_point_size = buf[5]; + memcpy(smbios_entry_point, buf, smbios_entry_point_size); /* Some BIOS report weird SMBIOS version, fix that up */ switch (smbios_ver) { @@ -455,21 +487,25 @@ static int __init dmi_present(const u8 *buf) buf += 16; if (memcmp(buf, "_DMI_", 5) == 0 && dmi_checksum(buf, 15)) { - dmi_num = (buf[13] << 8) | buf[12]; - dmi_len = (buf[7] << 8) | buf[6]; - dmi_base = (buf[11] << 24) | (buf[10] << 16) | - (buf[9] << 8) | buf[8]; + if (smbios_ver) + dmi_ver = smbios_ver; + else + dmi_ver = (buf[14] & 0xF0) << 4 | (buf[14] & 0x0F); + dmi_ver <<= 8; + dmi_num = get_unaligned_le16(buf + 12); + dmi_len = get_unaligned_le16(buf + 6); + dmi_base = get_unaligned_le32(buf + 8); if (dmi_walk_early(dmi_decode) == 0) { if (smbios_ver) { - dmi_ver = smbios_ver; pr_info("SMBIOS %d.%d present.\n", - dmi_ver >> 8, dmi_ver & 0xFF); + dmi_ver >> 16, (dmi_ver >> 8) & 0xFF); } else { - dmi_ver = (buf[14] & 0xF0) << 4 | - (buf[14] & 0x0F); + smbios_entry_point_size = 15; + memcpy(smbios_entry_point, buf, + smbios_entry_point_size); pr_info("Legacy DMI %d.%d present.\n", - dmi_ver >> 8, dmi_ver & 0xFF); + dmi_ver >> 16, (dmi_ver >> 8) & 0xFF); } dmi_format_ids(dmi_ids_string, sizeof(dmi_ids_string)); printk(KERN_DEBUG "DMI: %s\n", dmi_ids_string); @@ -480,6 +516,33 @@ static int __init dmi_present(const u8 *buf) return 1; } +/* + * Check for the SMBIOS 3.0 64-bit entry point signature. Unlike the legacy + * 32-bit entry point, there is no embedded DMI header (_DMI_) in here. + */ +static int __init dmi_smbios3_present(const u8 *buf) +{ + if (memcmp(buf, "_SM3_", 5) == 0 && + buf[6] < 32 && dmi_checksum(buf, buf[6])) { + dmi_ver = get_unaligned_be32(buf + 6) & 0xFFFFFF; + dmi_num = 0; /* No longer specified */ + dmi_len = get_unaligned_le32(buf + 12); + dmi_base = get_unaligned_le64(buf + 16); + smbios_entry_point_size = buf[6]; + memcpy(smbios_entry_point, buf, smbios_entry_point_size); + + if (dmi_walk_early(dmi_decode) == 0) { + pr_info("SMBIOS %d.%d.%d present.\n", + dmi_ver >> 16, (dmi_ver >> 8) & 0xFF, + dmi_ver & 0xFF); + dmi_format_ids(dmi_ids_string, sizeof(dmi_ids_string)); + pr_debug("DMI: %s\n", dmi_ids_string); + return 0; + } + } + return 1; +} + void __init dmi_scan_machine(void) { char __iomem *p, *q; @@ -499,7 +562,7 @@ void __init dmi_scan_machine(void) memset(buf, 0, 16); for (q = p; q < p + 0x10000; q += 16) { memcpy(buf + 16, q, 16); - if (!dmi_present(buf)) { + if (!dmi_smbios3_present(buf) || !dmi_present(buf)) { dmi_available = 1; goto out; } diff --git a/drivers/ddk/linux/hdmi.c b/drivers/ddk/linux/hdmi.c index 9e758a8f89..b2406a72c8 100644 --- a/drivers/ddk/linux/hdmi.c +++ b/drivers/ddk/linux/hdmi.c @@ -27,10 +27,12 @@ #include #include #include +#include -static void hdmi_infoframe_checksum(void *buffer, size_t size) +#define hdmi_log(fmt, ...) dev_printk(level, dev, fmt, ##__VA_ARGS__) + +static u8 hdmi_infoframe_checksum(u8 *ptr, size_t size) { - u8 *ptr = buffer; u8 csum = 0; size_t i; @@ -38,7 +40,14 @@ static void hdmi_infoframe_checksum(void *buffer, size_t size) for (i = 0; i < size; i++) csum += ptr[i]; - ptr[3] = 256 - csum; + return 256 - csum; +} + +static void hdmi_infoframe_set_checksum(void *buffer, size_t size) +{ + u8 *ptr = buffer; + + ptr[3] = hdmi_infoframe_checksum(buffer, size); } /** @@ -136,7 +145,7 @@ ssize_t hdmi_avi_infoframe_pack(struct hdmi_avi_infoframe *frame, void *buffer, ptr[11] = frame->right_bar & 0xff; ptr[12] = (frame->right_bar >> 8) & 0xff; - hdmi_infoframe_checksum(buffer, length); + hdmi_infoframe_set_checksum(buffer, length); return length; } @@ -206,7 +215,7 @@ ssize_t hdmi_spd_infoframe_pack(struct hdmi_spd_infoframe *frame, void *buffer, ptr[24] = frame->sdi; - hdmi_infoframe_checksum(buffer, length); + hdmi_infoframe_set_checksum(buffer, length); return length; } @@ -281,7 +290,7 @@ ssize_t hdmi_audio_infoframe_pack(struct hdmi_audio_infoframe *frame, if (frame->downmix_inhibit) ptr[4] |= BIT(7); - hdmi_infoframe_checksum(buffer, length); + hdmi_infoframe_set_checksum(buffer, length); return length; } @@ -373,7 +382,7 @@ ssize_t hdmi_vendor_infoframe_pack(struct hdmi_vendor_infoframe *frame, ptr[9] = (frame->s3d_ext_data & 0xf) << 4; } - hdmi_infoframe_checksum(buffer, length); + hdmi_infoframe_set_checksum(buffer, length); return length; } diff --git a/drivers/ddk/linux/idr.c b/drivers/ddk/linux/idr.c index 0c2f4cf8b9..86670310f0 100644 --- a/drivers/ddk/linux/idr.c +++ b/drivers/ddk/linux/idr.c @@ -22,6 +22,7 @@ #ifndef TEST // to test in user space... #include +#include #include #endif #include diff --git a/drivers/ddk/linux/interval_tree.c b/drivers/ddk/linux/interval_tree.c index b6a785818b..c85f6600a5 100644 --- a/drivers/ddk/linux/interval_tree.c +++ b/drivers/ddk/linux/interval_tree.c @@ -1,7 +1,7 @@ -//#include #include #include -#include +#include +#include #define START(node) ((node)->start) #define LAST(node) ((node)->last) diff --git a/drivers/ddk/linux/list_sort.c b/drivers/ddk/linux/list_sort.c index 6a51fc5e9a..981827c6da 100644 --- a/drivers/ddk/linux/list_sort.c +++ b/drivers/ddk/linux/list_sort.c @@ -2,9 +2,11 @@ #define pr_fmt(fmt) "list_sort_test: " fmt #include -#include +#include +#include +#include +#include #include -#include #include #define MAX_LIST_LENGTH_BITS 20 diff --git a/drivers/ddk/linux/rbtree.c b/drivers/ddk/linux/rbtree.c index c16c81a3d4..1356454e36 100644 --- a/drivers/ddk/linux/rbtree.c +++ b/drivers/ddk/linux/rbtree.c @@ -44,6 +44,30 @@ * parentheses and have some accompanying text comment. */ +/* + * Notes on lockless lookups: + * + * All stores to the tree structure (rb_left and rb_right) must be done using + * WRITE_ONCE(). And we must not inadvertently cause (temporary) loops in the + * tree structure as seen in program order. + * + * These two requirements will allow lockless iteration of the tree -- not + * correct iteration mind you, tree rotations are not atomic so a lookup might + * miss entire subtrees. + * + * But they do guarantee that any such traversal will only see valid elements + * and that it will indeed complete -- does not get stuck in a loop. + * + * It also guarantees that if the lookup returns an element it is the 'correct' + * one. But not returning an element does _NOT_ mean it's not present. + * + * NOTE: + * + * Stores to __rb_parent_color are not important for simple lookups so those + * are left undone as of now. Nor did I check for loops involving parent + * pointers. + */ + static inline void rb_set_black(struct rb_node *rb) { rb->__rb_parent_color |= RB_BLACK; @@ -129,8 +153,9 @@ __rb_insert(struct rb_node *node, struct rb_root *root, * This still leaves us in violation of 4), the * continuation into Case 3 will fix that. */ - parent->rb_right = tmp = node->rb_left; - node->rb_left = parent; + tmp = node->rb_left; + WRITE_ONCE(parent->rb_right, tmp); + WRITE_ONCE(node->rb_left, parent); if (tmp) rb_set_parent_color(tmp, parent, RB_BLACK); @@ -149,8 +174,8 @@ __rb_insert(struct rb_node *node, struct rb_root *root, * / \ * n U */ - gparent->rb_left = tmp; /* == parent->rb_right */ - parent->rb_right = gparent; + WRITE_ONCE(gparent->rb_left, tmp); /* == parent->rb_right */ + WRITE_ONCE(parent->rb_right, gparent); if (tmp) rb_set_parent_color(tmp, gparent, RB_BLACK); __rb_rotate_set_parents(gparent, parent, root, RB_RED); @@ -171,8 +196,9 @@ __rb_insert(struct rb_node *node, struct rb_root *root, tmp = parent->rb_left; if (node == tmp) { /* Case 2 - right rotate at parent */ - parent->rb_left = tmp = node->rb_right; - node->rb_right = parent; + tmp = node->rb_right; + WRITE_ONCE(parent->rb_left, tmp); + WRITE_ONCE(node->rb_right, parent); if (tmp) rb_set_parent_color(tmp, parent, RB_BLACK); @@ -183,8 +209,8 @@ __rb_insert(struct rb_node *node, struct rb_root *root, } /* Case 3 - left rotate at gparent */ - gparent->rb_right = tmp; /* == parent->rb_left */ - parent->rb_left = gparent; + WRITE_ONCE(gparent->rb_right, tmp); /* == parent->rb_left */ + WRITE_ONCE(parent->rb_left, gparent); if (tmp) rb_set_parent_color(tmp, gparent, RB_BLACK); __rb_rotate_set_parents(gparent, parent, root, RB_RED); @@ -224,8 +250,9 @@ ____rb_erase_color(struct rb_node *parent, struct rb_root *root, * / \ / \ * Sl Sr N Sl */ - parent->rb_right = tmp1 = sibling->rb_left; - sibling->rb_left = parent; + tmp1 = sibling->rb_left; + WRITE_ONCE(parent->rb_right, tmp1); + WRITE_ONCE(sibling->rb_left, parent); rb_set_parent_color(tmp1, parent, RB_BLACK); __rb_rotate_set_parents(parent, sibling, root, RB_RED); @@ -275,9 +302,10 @@ ____rb_erase_color(struct rb_node *parent, struct rb_root *root, * \ * Sr */ - sibling->rb_left = tmp1 = tmp2->rb_right; - tmp2->rb_right = sibling; - parent->rb_right = tmp2; + tmp1 = tmp2->rb_right; + WRITE_ONCE(sibling->rb_left, tmp1); + WRITE_ONCE(tmp2->rb_right, sibling); + WRITE_ONCE(parent->rb_right, tmp2); if (tmp1) rb_set_parent_color(tmp1, sibling, RB_BLACK); @@ -297,8 +325,9 @@ ____rb_erase_color(struct rb_node *parent, struct rb_root *root, * / \ / \ * (sl) sr N (sl) */ - parent->rb_right = tmp2 = sibling->rb_left; - sibling->rb_left = parent; + tmp2 = sibling->rb_left; + WRITE_ONCE(parent->rb_right, tmp2); + WRITE_ONCE(sibling->rb_left, parent); rb_set_parent_color(tmp1, sibling, RB_BLACK); if (tmp2) rb_set_parent(tmp2, parent); @@ -310,8 +339,9 @@ ____rb_erase_color(struct rb_node *parent, struct rb_root *root, sibling = parent->rb_left; if (rb_is_red(sibling)) { /* Case 1 - right rotate at parent */ - parent->rb_left = tmp1 = sibling->rb_right; - sibling->rb_right = parent; + tmp1 = sibling->rb_right; + WRITE_ONCE(parent->rb_left, tmp1); + WRITE_ONCE(sibling->rb_right, parent); rb_set_parent_color(tmp1, parent, RB_BLACK); __rb_rotate_set_parents(parent, sibling, root, RB_RED); @@ -336,9 +366,10 @@ ____rb_erase_color(struct rb_node *parent, struct rb_root *root, break; } /* Case 3 - right rotate at sibling */ - sibling->rb_right = tmp1 = tmp2->rb_left; - tmp2->rb_left = sibling; - parent->rb_left = tmp2; + tmp1 = tmp2->rb_left; + WRITE_ONCE(sibling->rb_right, tmp1); + WRITE_ONCE(tmp2->rb_left, sibling); + WRITE_ONCE(parent->rb_left, tmp2); if (tmp1) rb_set_parent_color(tmp1, sibling, RB_BLACK); @@ -347,8 +378,9 @@ ____rb_erase_color(struct rb_node *parent, struct rb_root *root, sibling = tmp2; } /* Case 4 - left rotate at parent + color flips */ - parent->rb_left = tmp2 = sibling->rb_right; - sibling->rb_right = parent; + tmp2 = sibling->rb_right; + WRITE_ONCE(parent->rb_left, tmp2); + WRITE_ONCE(sibling->rb_right, parent); rb_set_parent_color(tmp1, sibling, RB_BLACK); if (tmp2) rb_set_parent(tmp2, parent); diff --git a/drivers/ddk/linux/string.c b/drivers/ddk/linux/string.c index edbfbd28fc..30f04ffc94 100644 --- a/drivers/ddk/linux/string.c +++ b/drivers/ddk/linux/string.c @@ -22,7 +22,11 @@ #include #include #include -#include +#include +#include +#include +#include + #ifndef __HAVE_ARCH_STRLCPY diff --git a/drivers/ddk/linux/time.c b/drivers/ddk/linux/time.c index 427e77a64a..97b75cf2b6 100644 --- a/drivers/ddk/linux/time.c +++ b/drivers/ddk/linux/time.c @@ -592,25 +592,6 @@ struct timespec timespec_add_safe(const struct timespec lhs, return res; } -s64 div_s64_rem(s64 dividend, s32 divisor, s32 *remainder) -{ - u64 quotient; - - if (dividend < 0) { - quotient = div_u64_rem(-dividend, abs(divisor), (u32 *)remainder); - *remainder = -*remainder; - if (divisor > 0) - quotient = -quotient; - } else { - quotient = div_u64_rem(dividend, abs(divisor), (u32 *)remainder); - if (divisor < 0) - quotient = -quotient; - } - return quotient; -} - - - diff --git a/drivers/include/asm/timex.h b/drivers/include/asm/timex.h new file mode 100644 index 0000000000..cedd1c78b5 --- /dev/null +++ b/drivers/include/asm/timex.h @@ -0,0 +1,12 @@ +#ifndef _ASM_X86_TIMEX_H +#define _ASM_X86_TIMEX_H + +//#include +//#include + +/* Assume we use the PIT time source for the clock tick */ +#define CLOCK_TICK_RATE PIT_TICK_RATE + +#define ARCH_HAS_READ_CURRENT_TIMER + +#endif /* _ASM_X86_TIMEX_H */ diff --git a/drivers/include/asm/vga.h b/drivers/include/asm/vga.h new file mode 100644 index 0000000000..c4b9dc2f67 --- /dev/null +++ b/drivers/include/asm/vga.h @@ -0,0 +1,20 @@ +/* + * Access to VGA videoram + * + * (c) 1998 Martin Mares + */ + +#ifndef _ASM_X86_VGA_H +#define _ASM_X86_VGA_H + +/* + * On the PC, we can just recalculate addresses and then + * access the videoram directly without any black magic. + */ + +#define VGA_MAP_MEM(x, s) (unsigned long)phys_to_virt(x) + +#define vga_readb(x) (*(x)) +#define vga_writeb(x, y) (*(y) = (x)) + +#endif /* _ASM_X86_VGA_H */ diff --git a/drivers/include/drm/drmP.h b/drivers/include/drm/drmP.h index a06cd4d8eb..c86bede8b5 100644 --- a/drivers/include/drm/drmP.h +++ b/drivers/include/drm/drmP.h @@ -919,7 +919,8 @@ static inline int drm_debugfs_remove_files(const struct drm_info_list *files, #endif extern struct dma_buf *drm_gem_prime_export(struct drm_device *dev, - struct drm_gem_object *obj, int flags); + struct drm_gem_object *obj, + int flags); extern int drm_gem_prime_handle_to_fd(struct drm_device *dev, struct drm_file *file_priv, uint32_t handle, uint32_t flags, int *prime_fd); diff --git a/drivers/include/linux/clocksource.h b/drivers/include/linux/clocksource.h index 6862f238dc..7784b597e9 100644 --- a/drivers/include/linux/clocksource.h +++ b/drivers/include/linux/clocksource.h @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include diff --git a/drivers/include/linux/compiler-gcc.h b/drivers/include/linux/compiler-gcc.h index 4af9b47b97..7d153abfdb 100644 --- a/drivers/include/linux/compiler-gcc.h +++ b/drivers/include/linux/compiler-gcc.h @@ -251,7 +251,9 @@ #endif #endif /* CONFIG_ARCH_USE_BUILTIN_BSWAP */ -#if GCC_VERSION >= 50000 +#if GCC_VERSION >= 70000 +#define KASAN_ABI_VERSION 5 +#elif GCC_VERSION >= 50000 #define KASAN_ABI_VERSION 4 #elif GCC_VERSION >= 40902 #define KASAN_ABI_VERSION 3 diff --git a/drivers/include/linux/cpumask.h b/drivers/include/linux/cpumask.h index 59915ea537..a91b3b75da 100644 --- a/drivers/include/linux/cpumask.h +++ b/drivers/include/linux/cpumask.h @@ -556,7 +556,7 @@ static inline void cpumask_copy(struct cpumask *dstp, static inline int cpumask_parse_user(const char __user *buf, int len, struct cpumask *dstp) { - return bitmap_parse_user(buf, len, cpumask_bits(dstp), nr_cpu_ids); + return bitmap_parse_user(buf, len, cpumask_bits(dstp), nr_cpumask_bits); } /** @@ -571,7 +571,7 @@ static inline int cpumask_parselist_user(const char __user *buf, int len, struct cpumask *dstp) { return bitmap_parselist_user(buf, len, cpumask_bits(dstp), - nr_cpu_ids); + nr_cpumask_bits); } /** @@ -586,7 +586,7 @@ static inline int cpumask_parse(const char *buf, struct cpumask *dstp) char *nl = strchr(buf, '\n'); unsigned int len = nl ? (unsigned int)(nl - buf) : strlen(buf); - return bitmap_parse(buf, len, cpumask_bits(dstp), nr_cpu_ids); + return bitmap_parse(buf, len, cpumask_bits(dstp), nr_cpumask_bits); } /** @@ -598,7 +598,7 @@ static inline int cpumask_parse(const char *buf, struct cpumask *dstp) */ static inline int cpulist_parse(const char *buf, struct cpumask *dstp) { - return bitmap_parselist(buf, cpumask_bits(dstp), nr_cpu_ids); + return bitmap_parselist(buf, cpumask_bits(dstp), nr_cpumask_bits); } /** diff --git a/drivers/include/linux/export.h b/drivers/include/linux/export.h index 7a0e4a27ee..5bacd5c6e3 100644 --- a/drivers/include/linux/export.h +++ b/drivers/include/linux/export.h @@ -8,6 +8,15 @@ * Try not to add #includes here. It slows compilation and makes kernel * hackers place grumpy comments in header files. */ + +/* Some toolchains use a `_' prefix for all user symbols. */ +#ifdef CONFIG_HAVE_UNDERSCORE_SYMBOL_PREFIX +#define __VMLINUX_SYMBOL(x) _##x +#define __VMLINUX_SYMBOL_STR(x) "_" #x +#else +#define __VMLINUX_SYMBOL(x) x +#define __VMLINUX_SYMBOL_STR(x) #x +#endif #define EXPORT_SYMBOL(sym) #define EXPORT_SYMBOL_GPL(sym) #define EXPORT_SYMBOL_GPL_FUTURE(sym) diff --git a/drivers/include/linux/file.h b/drivers/include/linux/file.h index 452c93e4f0..23ab01118d 100644 --- a/drivers/include/linux/file.h +++ b/drivers/include/linux/file.h @@ -12,5 +12,11 @@ struct file; extern void fput(struct file *); +struct fd { + struct file *file; + unsigned int flags; +}; +#define FDPUT_FPUT 1 +#define FDPUT_POS_UNLOCK 2 extern struct file *fget(unsigned int fd); #endif /* __LINUX_FILE_H */ diff --git a/drivers/include/linux/hash.h b/drivers/include/linux/hash.h index 1afde47e15..79c52fa81c 100644 --- a/drivers/include/linux/hash.h +++ b/drivers/include/linux/hash.h @@ -32,12 +32,28 @@ #error Wordsize not 32 or 64 #endif +/* + * The above primes are actively bad for hashing, since they are + * too sparse. The 32-bit one is mostly ok, the 64-bit one causes + * real problems. Besides, the "prime" part is pointless for the + * multiplicative hash. + * + * Although a random odd number will do, it turns out that the golden + * ratio phi = (sqrt(5)-1)/2, or its negative, has particularly nice + * properties. + * + * These are the negative, (1 - phi) = (phi^2) = (3 - sqrt(5))/2. + * (See Knuth vol 3, section 6.4, exercise 9.) + */ +#define GOLDEN_RATIO_32 0x61C88647 +#define GOLDEN_RATIO_64 0x61C8864680B583EBull + static __always_inline u64 hash_64(u64 val, unsigned int bits) { u64 hash = val; -#if defined(CONFIG_ARCH_HAS_FAST_MULTIPLIER) && BITS_PER_LONG == 64 - hash = hash * GOLDEN_RATIO_PRIME_64; +#if BITS_PER_LONG == 64 + hash = hash * GOLDEN_RATIO_64; #else /* Sigh, gcc can't optimise this alone like it does for 32 bits. */ u64 n = hash; diff --git a/drivers/include/linux/interrupt.h b/drivers/include/linux/interrupt.h index 1b8675853f..12ddc7d532 100644 --- a/drivers/include/linux/interrupt.h +++ b/drivers/include/linux/interrupt.h @@ -6,6 +6,7 @@ #include #include #include +#include /* * These correspond to the IORESOURCE_IRQ_* defines in * linux/ioport.h to select the interrupt line behaviour. When diff --git a/drivers/include/linux/io.h b/drivers/include/linux/io.h index 39fe75e9fa..f571c8433d 100644 --- a/drivers/include/linux/io.h +++ b/drivers/include/linux/io.h @@ -1 +1,27 @@ -//stub +/* + * Copyright 2006 PathScale, Inc. All Rights Reserved. + * + * This file is free software; you can redistribute it and/or modify + * it under the terms of version 2 of the GNU General Public License + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#ifndef _LINUX_IO_H +#define _LINUX_IO_H + +#include +#include +#include +#include +struct device; +struct resource; +#endif /* _LINUX_IO_H */ diff --git a/drivers/include/linux/jiffies.h b/drivers/include/linux/jiffies.h index 610dd88e4f..400090a14b 100644 --- a/drivers/include/linux/jiffies.h +++ b/drivers/include/linux/jiffies.h @@ -354,7 +354,7 @@ static inline unsigned long _msecs_to_jiffies(const unsigned int m) * directly here and from __msecs_to_jiffies() in the case where * constant folding is not possible. */ -static inline unsigned long msecs_to_jiffies(const unsigned int m) +static __always_inline unsigned long msecs_to_jiffies(const unsigned int m) { if (__builtin_constant_p(m)) { if ((int)m < 0) diff --git a/drivers/include/linux/kernel.h b/drivers/include/linux/kernel.h index cdc0b515cf..a39a709441 100644 --- a/drivers/include/linux/kernel.h +++ b/drivers/include/linux/kernel.h @@ -201,26 +201,26 @@ extern int _cond_resched(void); /** * abs - return absolute value of an argument - * @x: the value. If it is unsigned type, it is converted to signed type first - * (s64, long or int depending on its size). + * @x: the value. If it is unsigned type, it is converted to signed type first. + * char is treated as if it was signed (regardless of whether it really is) + * but the macro's return type is preserved as char. * - * Return: an absolute value of x. If x is 64-bit, macro's return type is s64, - * otherwise it is signed long. + * Return: an absolute value of x. */ -#define abs(x) __builtin_choose_expr(sizeof(x) == sizeof(s64), ({ \ - s64 __x = (x); \ - (__x < 0) ? -__x : __x; \ - }), ({ \ - long ret; \ - if (sizeof(x) == sizeof(long)) { \ - long __x = (x); \ - ret = (__x < 0) ? -__x : __x; \ - } else { \ - int __x = (x); \ - ret = (__x < 0) ? -__x : __x; \ - } \ - ret; \ - })) +#define abs(x) __abs_choose_expr(x, long long, \ + __abs_choose_expr(x, long, \ + __abs_choose_expr(x, int, \ + __abs_choose_expr(x, short, \ + __abs_choose_expr(x, char, \ + __builtin_choose_expr( \ + __builtin_types_compatible_p(typeof(x), char), \ + (char)({ signed char __x = (x); __x<0?-__x:__x; }), \ + ((void)0))))))) + +#define __abs_choose_expr(x, type, other) __builtin_choose_expr( \ + __builtin_types_compatible_p(typeof(x), signed type) || \ + __builtin_types_compatible_p(typeof(x), unsigned type), \ + ({ signed type __x = (x); __x < 0 ? -__x : __x; }), other) /** * reciprocal_scale - "scale" a value into range [0, ep_ro) @@ -440,7 +440,7 @@ do { \ #define do_trace_printk(fmt, args...) \ do { \ - static const char *trace_printk_fmt \ + static const char *trace_printk_fmt __used \ __attribute__((section("__trace_printk_fmt"))) = \ __builtin_constant_p(fmt) ? fmt : NULL; \ \ @@ -484,7 +484,7 @@ int __trace_printk(unsigned long ip, const char *fmt, ...); */ #define trace_puts(str) ({ \ - static const char *trace_printk_fmt \ + static const char *trace_printk_fmt __used \ __attribute__((section("__trace_printk_fmt"))) = \ __builtin_constant_p(str) ? str : NULL; \ \ @@ -506,7 +506,7 @@ extern void trace_dump_stack(int skip); #define ftrace_vprintk(fmt, vargs) \ do { \ if (__builtin_constant_p(fmt)) { \ - static const char *trace_printk_fmt \ + static const char *trace_printk_fmt __used \ __attribute__((section("__trace_printk_fmt"))) = \ __builtin_constant_p(fmt) ? fmt : NULL; \ \ diff --git a/drivers/include/linux/list.h b/drivers/include/linux/list.h index 9579ff0265..ecd961ad3f 100644 --- a/drivers/include/linux/list.h +++ b/drivers/include/linux/list.h @@ -87,7 +87,7 @@ static inline void list_add_tail(struct list_head *new, struct list_head *head) static inline void __list_del(struct list_head * prev, struct list_head * next) { next->prev = prev; - prev->next = next; + WRITE_ONCE(prev->next, next); } /** @@ -615,7 +615,8 @@ static inline void __hlist_del(struct hlist_node *n) { struct hlist_node *next = n->next; struct hlist_node **pprev = n->pprev; - *pprev = next; + + WRITE_ONCE(*pprev, next); if (next) next->pprev = pprev; } diff --git a/drivers/include/linux/log2.h b/drivers/include/linux/log2.h index fd7ff3d91e..c373295f35 100644 --- a/drivers/include/linux/log2.h +++ b/drivers/include/linux/log2.h @@ -15,12 +15,6 @@ #include #include -/* - * deal with unrepresentable constant logarithms - */ -extern __attribute__((const, noreturn)) -int ____ilog2_NaN(void); - /* * non-constant log of base 2 calculators * - the arch may override these in asm/bitops.h if they can be implemented @@ -85,7 +79,7 @@ unsigned long __rounddown_pow_of_two(unsigned long n) #define ilog2(n) \ ( \ __builtin_constant_p(n) ? ( \ - (n) < 1 ? ____ilog2_NaN() : \ + (n) < 2 ? 0 : \ (n) & (1ULL << 63) ? 63 : \ (n) & (1ULL << 62) ? 62 : \ (n) & (1ULL << 61) ? 61 : \ @@ -148,10 +142,7 @@ unsigned long __rounddown_pow_of_two(unsigned long n) (n) & (1ULL << 4) ? 4 : \ (n) & (1ULL << 3) ? 3 : \ (n) & (1ULL << 2) ? 2 : \ - (n) & (1ULL << 1) ? 1 : \ - (n) & (1ULL << 0) ? 0 : \ - ____ilog2_NaN() \ - ) : \ + 1 ) : \ (sizeof(n) <= 4) ? \ __ilog2_u32(n) : \ __ilog2_u64(n) \ @@ -203,6 +194,17 @@ unsigned long __rounddown_pow_of_two(unsigned long n) * ... and so on. */ -#define order_base_2(n) ilog2(roundup_pow_of_two(n)) +static inline __attribute_const__ +int __order_base_2(unsigned long n) +{ + return n > 1 ? ilog2(n - 1) + 1 : 0; +} +#define order_base_2(n) \ +( \ + __builtin_constant_p(n) ? ( \ + ((n) == 0 || (n) == 1) ? 0 : \ + ilog2((n) - 1) + 1) : \ + __order_base_2(n) \ +) #endif /* _LINUX_LOG2_H */ diff --git a/drivers/include/linux/module.h b/drivers/include/linux/module.h index 10e354647a..c26e9ef864 100644 --- a/drivers/include/linux/module.h +++ b/drivers/include/linux/module.h @@ -9,6 +9,7 @@ #include #include #include +#include #include #include diff --git a/drivers/include/linux/moduleparam.h b/drivers/include/linux/moduleparam.h index a51cd59663..4a273ef79c 100644 --- a/drivers/include/linux/moduleparam.h +++ b/drivers/include/linux/moduleparam.h @@ -1,6 +1,7 @@ #ifndef _LINUX_MODULE_PARAMS_H #define _LINUX_MODULE_PARAMS_H /* (C) Copyright 2001, 2002 Rusty Russell IBM Corporation */ +#include #include /** * module_param - typesafe helper for a module/cmdline parameter diff --git a/drivers/include/linux/pci.h b/drivers/include/linux/pci.h index 924cfd73a1..b2470faa20 100644 --- a/drivers/include/linux/pci.h +++ b/drivers/include/linux/pci.h @@ -59,6 +59,11 @@ struct pci_slot { struct kobject kobj; }; +static inline const char *pci_slot_name(const struct pci_slot *slot) +{ + return kobject_name(&slot->kobj); +} + /* File state for mmap()s on /proc/bus/pci/X/Y */ enum pci_mmap_state { pci_mmap_io, @@ -352,6 +357,7 @@ struct pci_dev { unsigned int io_window_1k:1; /* Intel P2P bridge 1K I/O windows */ unsigned int irq_managed:1; unsigned int has_secondary_link:1; + unsigned int non_compliant_bars:1; /* broken BARs; ignore them */ pci_dev_flags_t dev_flags; atomic_t enable_cnt; /* pci_enable_device has been called */ diff --git a/drivers/include/linux/pci_ids.h b/drivers/include/linux/pci_ids.h index d9ba49cedc..37f05cb1df 100644 --- a/drivers/include/linux/pci_ids.h +++ b/drivers/include/linux/pci_ids.h @@ -2495,6 +2495,13 @@ #define PCI_DEVICE_ID_KORENIX_JETCARDF2 0x1700 #define PCI_DEVICE_ID_KORENIX_JETCARDF3 0x17ff +#define PCI_VENDOR_ID_NETRONOME 0x19ee +#define PCI_DEVICE_ID_NETRONOME_NFP3200 0x3200 +#define PCI_DEVICE_ID_NETRONOME_NFP3240 0x3240 +#define PCI_DEVICE_ID_NETRONOME_NFP4000 0x4000 +#define PCI_DEVICE_ID_NETRONOME_NFP6000 0x6000 +#define PCI_DEVICE_ID_NETRONOME_NFP6000_VF 0x6003 + #define PCI_VENDOR_ID_QMI 0x1a32 #define PCI_VENDOR_ID_AZWAVE 0x1a3b diff --git a/drivers/include/linux/personality.h b/drivers/include/linux/personality.h index 709f49f19e..aeb7892b24 100644 --- a/drivers/include/linux/personality.h +++ b/drivers/include/linux/personality.h @@ -3,42 +3,6 @@ #include - -/* - * Handling of different ABIs (personalities). - */ - -struct exec_domain; -struct pt_regs; - -extern int register_exec_domain(struct exec_domain *); -extern int unregister_exec_domain(struct exec_domain *); -extern int __set_personality(unsigned int); - - -/* - * Description of an execution domain. - * - * The first two members are refernced from assembly source - * and should stay where they are unless explicitly needed. - */ -typedef void (*handler_t)(int, struct pt_regs *); - -struct exec_domain { - const char *name; /* name of the execdomain */ - handler_t handler; /* handler for syscalls */ - unsigned char pers_low; /* lowest personality */ - unsigned char pers_high; /* highest personality */ - unsigned long *signal_map; /* signal mapping */ - unsigned long *signal_invmap; /* reverse signal mapping */ - struct map_segment *err_map; /* error mapping */ - struct map_segment *socktype_map; /* socket type mapping */ - struct map_segment *sockopt_map; /* socket option mapping */ - struct map_segment *af_map; /* address family mapping */ - struct module *module; /* module context of the ed. */ - struct exec_domain *next; /* linked list (internal) */ -}; - /* * Return the base personality without flags. */ diff --git a/drivers/include/linux/pm.h b/drivers/include/linux/pm.h index 08b3d34696..528be67877 100644 --- a/drivers/include/linux/pm.h +++ b/drivers/include/linux/pm.h @@ -25,7 +25,7 @@ #include #include #include -//#include +#include #include /* diff --git a/drivers/include/linux/scatterlist.h b/drivers/include/linux/scatterlist.h index 75f495aebc..cba16ab95b 100644 --- a/drivers/include/linux/scatterlist.h +++ b/drivers/include/linux/scatterlist.h @@ -5,6 +5,7 @@ #include #include #include +#include struct scatterlist { #ifdef CONFIG_DEBUG_SG diff --git a/drivers/include/linux/seqlock.h b/drivers/include/linux/seqlock.h index d97f93aa3a..e623c6f971 100644 --- a/drivers/include/linux/seqlock.h +++ b/drivers/include/linux/seqlock.h @@ -33,7 +33,7 @@ */ #include -//#include +#include #include #include #include diff --git a/drivers/include/linux/string.h b/drivers/include/linux/string.h index 6778fd916a..2398aaea3e 100644 --- a/drivers/include/linux/string.h +++ b/drivers/include/linux/string.h @@ -127,7 +127,11 @@ extern char **argv_split(gfp_t gfp, const char *str, int *argcp); extern void argv_free(char **argv); extern bool sysfs_streq(const char *s1, const char *s2); -extern int strtobool(const char *s, bool *res); +extern int kstrtobool(const char *s, bool *res); +static inline int strtobool(const char *s, bool *res) +{ + return kstrtobool(s, res); +} #ifdef CONFIG_BINARY_PRINTF int vbin_printf(u32 *bin_buf, size_t size, const char *fmt, va_list args); diff --git a/drivers/include/linux/swap.h b/drivers/include/linux/swap.h index efedac1aef..9a3eb66cb4 100644 --- a/drivers/include/linux/swap.h +++ b/drivers/include/linux/swap.h @@ -2,6 +2,9 @@ #define _LINUX_SWAP_H #include +#include +#include +#include struct notifier_block; diff --git a/drivers/include/linux/sysfs.h b/drivers/include/linux/sysfs.h index 7fc507bda5..9992e1a126 100644 --- a/drivers/include/linux/sysfs.h +++ b/drivers/include/linux/sysfs.h @@ -14,6 +14,7 @@ #include #include #include +#include #include struct kobject; diff --git a/drivers/include/linux/time.h b/drivers/include/linux/time.h index beebe3a02d..297f09f238 100644 --- a/drivers/include/linux/time.h +++ b/drivers/include/linux/time.h @@ -125,6 +125,32 @@ static inline bool timeval_valid(const struct timeval *tv) extern struct timespec timespec_trunc(struct timespec t, unsigned gran); +/* + * Validates if a timespec/timeval used to inject a time offset is valid. + * Offsets can be postive or negative. The value of the timeval/timespec + * is the sum of its fields, but *NOTE*: the field tv_usec/tv_nsec must + * always be non-negative. + */ +static inline bool timeval_inject_offset_valid(const struct timeval *tv) +{ + /* We don't check the tv_sec as it can be positive or negative */ + + /* Can't have more microseconds then a second */ + if (tv->tv_usec < 0 || tv->tv_usec >= USEC_PER_SEC) + return false; + return true; +} + +static inline bool timespec_inject_offset_valid(const struct timespec *ts) +{ + /* We don't check the tv_sec as it can be positive or negative */ + + /* Can't have more nanoseconds then a second */ + if (ts->tv_nsec < 0 || ts->tv_nsec >= NSEC_PER_SEC) + return false; + return true; +} + #define CURRENT_TIME (current_kernel_time()) #define CURRENT_TIME_SEC ((struct timespec) { get_seconds(), 0 }) diff --git a/drivers/include/linux/timer.h b/drivers/include/linux/timer.h new file mode 100644 index 0000000000..03ce2630f5 --- /dev/null +++ b/drivers/include/linux/timer.h @@ -0,0 +1,16 @@ +#ifndef _LINUX_TIMER_H +#define _LINUX_TIMER_H + +#include + +unsigned long __round_jiffies(unsigned long j, int cpu); +unsigned long __round_jiffies_relative(unsigned long j, int cpu); +unsigned long round_jiffies(unsigned long j); +unsigned long round_jiffies_relative(unsigned long j); + +unsigned long __round_jiffies_up(unsigned long j, int cpu); +unsigned long __round_jiffies_up_relative(unsigned long j, int cpu); +unsigned long round_jiffies_up(unsigned long j); +unsigned long round_jiffies_up_relative(unsigned long j); + +#endif diff --git a/drivers/include/linux/timex.h b/drivers/include/linux/timex.h index 84dd8c6c8f..94bf29773f 100644 --- a/drivers/include/linux/timex.h +++ b/drivers/include/linux/timex.h @@ -53,12 +53,15 @@ #ifndef _LINUX_TIMEX_H #define _LINUX_TIMEX_H +#include + #define ADJ_ADJTIME 0x8000 /* switch between adjtime/adjtimex modes */ #define ADJ_OFFSET_SINGLESHOT 0x0001 /* old-fashioned adjtime */ #define ADJ_OFFSET_READONLY 0x2000 /* read-only adjtime */ #include #include +#include #ifndef random_get_entropy /* @@ -147,7 +150,8 @@ extern unsigned long tick_nsec; /* SHIFTED_HZ period (nsec) */ #define NTP_INTERVAL_FREQ (HZ) #define NTP_INTERVAL_LENGTH (NSEC_PER_SEC/NTP_INTERVAL_FREQ) - +extern int do_adjtimex(struct timex *); +extern void hardpps(const struct timespec64 *, const struct timespec64 *); int read_current_timer(unsigned long *timer_val); void ntp_notify_cmos_timer(void); diff --git a/drivers/include/linux/uaccess.h b/drivers/include/linux/uaccess.h new file mode 100644 index 0000000000..a63be2db8b --- /dev/null +++ b/drivers/include/linux/uaccess.h @@ -0,0 +1,20 @@ +#ifndef __LINUX_UACCESS_H__ +#define __LINUX_UACCESS_H__ + +#include +/* + * These routines enable/disable the pagefault handler. If disabled, it will + * not take any locks and go straight to the fixup table. + * + * User access methods will not sleep when called from a pagefault_disabled() + * environment. + */ +static inline void pagefault_disable(void) +{ +} + +static inline void pagefault_enable(void) +{ +} + +#endif /* __LINUX_UACCESS_H__ */ diff --git a/drivers/include/linux/vgaarb.h b/drivers/include/linux/vgaarb.h index 7ae1d82c90..8c3b412d84 100644 --- a/drivers/include/linux/vgaarb.h +++ b/drivers/include/linux/vgaarb.h @@ -31,7 +31,7 @@ #ifndef LINUX_VGA_H #define LINUX_VGA_H -//#include