lib: Import OnePlus Changes

Signed-off-by: Cyber Knight <cyberknight755@gmail.com>
This commit is contained in:
Cyber Knight 2021-09-26 02:16:59 +08:00
parent 0e312025a7
commit 2843fe50cf
No known key found for this signature in database
GPG Key ID: 23BD4CCD326E9D64
20 changed files with 88 additions and 91 deletions

View File

@ -327,7 +327,7 @@ static inline u32 __pure crc32_be_generic(u32 crc, unsigned char const *p,
return crc;
}
#if CRC_BE_BITS == 1
#if CRC_LE_BITS == 1
u32 __pure crc32_be(u32 crc, unsigned char const *p, size_t len)
{
return crc32_be_generic(crc, p, len, NULL, CRCPOLY_BE);

View File

@ -683,6 +683,7 @@ static int __init crc32c_test(void)
/* reduce OS noise */
local_irq_save(flags);
local_irq_disable();
nsec = ktime_get_ns();
for (i = 0; i < 100; i++) {
@ -693,6 +694,7 @@ static int __init crc32c_test(void)
nsec = ktime_get_ns() - nsec;
local_irq_restore(flags);
local_irq_enable();
pr_info("crc32c: CRC_LE_BITS = %d\n", CRC_LE_BITS);
@ -766,6 +768,7 @@ static int __init crc32_test(void)
/* reduce OS noise */
local_irq_save(flags);
local_irq_disable();
nsec = ktime_get_ns();
for (i = 0; i < 100; i++) {
@ -780,6 +783,7 @@ static int __init crc32_test(void)
nsec = ktime_get_ns() - nsec;
local_irq_restore(flags);
local_irq_enable();
pr_info("crc32: CRC_LE_BITS = %d, CRC_BE BITS = %d\n",
CRC_LE_BITS, CRC_BE_BITS);

View File

@ -85,22 +85,22 @@ static struct { unsigned flag:8; char opt_char; } opt_array[] = {
{ _DPRINTK_FLAGS_NONE, '_' },
};
struct flagsbuf { char buf[ARRAY_SIZE(opt_array)+1]; };
/* format a string into buf[] which describes the _ddebug's flags */
static char *ddebug_describe_flags(unsigned int flags, struct flagsbuf *fb)
static char *ddebug_describe_flags(struct _ddebug *dp, char *buf,
size_t maxlen)
{
char *p = fb->buf;
char *p = buf;
int i;
BUG_ON(maxlen < 6);
for (i = 0; i < ARRAY_SIZE(opt_array); ++i)
if (flags & opt_array[i].flag)
if (dp->flags & opt_array[i].flag)
*p++ = opt_array[i].opt_char;
if (p == fb->buf)
if (p == buf)
*p++ = '_';
*p = '\0';
return fb->buf;
return buf;
}
#define vpr_info(fmt, ...) \
@ -142,7 +142,7 @@ static int ddebug_change(const struct ddebug_query *query,
struct ddebug_table *dt;
unsigned int newflags;
unsigned int nfound = 0;
struct flagsbuf fbuf;
char flagbuf[10];
/* search for matching ddebugs */
mutex_lock(&ddebug_lock);
@ -199,7 +199,8 @@ static int ddebug_change(const struct ddebug_query *query,
vpr_info("changed %s:%d [%s]%s =%s\n",
trim_prefix(dp->filename), dp->lineno,
dt->mod_name, dp->function,
ddebug_describe_flags(dp->flags, &fbuf));
ddebug_describe_flags(dp, flagbuf,
sizeof(flagbuf)));
}
}
mutex_unlock(&ddebug_lock);
@ -778,7 +779,7 @@ static int ddebug_proc_show(struct seq_file *m, void *p)
{
struct ddebug_iter *iter = m->private;
struct _ddebug *dp = p;
struct flagsbuf flags;
char flagsbuf[10];
vpr_info("called m=%p p=%p\n", m, p);
@ -791,7 +792,7 @@ static int ddebug_proc_show(struct seq_file *m, void *p)
seq_printf(m, "%s:%u [%s]%s =%s \"",
trim_prefix(dp->filename), dp->lineno,
iter->table->mod_name, dp->function,
ddebug_describe_flags(dp->flags, &flags));
ddebug_describe_flags(dp, flagsbuf, sizeof(flagsbuf)));
seq_escape(m, dp->format, "\t\r\n\"");
seq_puts(m, "\"\n");

View File

@ -8,8 +8,8 @@
#define FONTDATAMAX 9216
static const struct font_data fontdata_10x18 = {
{ 0, 0, FONTDATAMAX, 0 }, {
static const unsigned char fontdata_10x18[FONTDATAMAX] = {
/* 0 0x00 '^@' */
0x00, 0x00, /* 0000000000 */
0x00, 0x00, /* 0000000000 */
@ -5129,7 +5129,8 @@ static const struct font_data fontdata_10x18 = {
0x00, 0x00, /* 0000000000 */
0x00, 0x00, /* 0000000000 */
0x00, 0x00, /* 0000000000 */
} };
};
const struct font_desc font_10x18 = {
@ -5137,7 +5138,7 @@ const struct font_desc font_10x18 = {
.name = "10x18",
.width = 10,
.height = 18,
.data = fontdata_10x18.data,
.data = fontdata_10x18,
#ifdef __sparc__
.pref = 5,
#else

View File

@ -1,10 +1,8 @@
// SPDX-License-Identifier: GPL-2.0
#include <linux/font.h>
#define FONTDATAMAX 2560
static const unsigned char fontdata_6x10[] = {
static const struct font_data fontdata_6x10 = {
{ 0, 0, FONTDATAMAX, 0 }, {
/* 0 0x00 '^@' */
0x00, /* 00000000 */
0x00, /* 00000000 */
@ -3076,13 +3074,14 @@ static const struct font_data fontdata_6x10 = {
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
} };
};
const struct font_desc font_6x10 = {
.idx = FONT6x10_IDX,
.name = "6x10",
.width = 6,
.height = 10,
.data = fontdata_6x10.data,
.data = fontdata_6x10,
.pref = 0,
};

View File

@ -9,8 +9,8 @@
#define FONTDATAMAX (11*256)
static const struct font_data fontdata_6x11 = {
{ 0, 0, FONTDATAMAX, 0 }, {
static const unsigned char fontdata_6x11[FONTDATAMAX] = {
/* 0 0x00 '^@' */
0x00, /* 00000000 */
0x00, /* 00000000 */
@ -3338,7 +3338,8 @@ static const struct font_data fontdata_6x11 = {
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
} };
};
const struct font_desc font_vga_6x11 = {
@ -3346,7 +3347,7 @@ const struct font_desc font_vga_6x11 = {
.name = "ProFont6x11",
.width = 6,
.height = 11,
.data = fontdata_6x11.data,
.data = fontdata_6x11,
/* Try avoiding this font if possible unless on MAC */
.pref = -2000,
};

View File

@ -8,8 +8,8 @@
#define FONTDATAMAX 3584
static const struct font_data fontdata_7x14 = {
{ 0, 0, FONTDATAMAX, 0 }, {
static const unsigned char fontdata_7x14[FONTDATAMAX] = {
/* 0 0x00 '^@' */
0x00, /* 0000000 */
0x00, /* 0000000 */
@ -4105,7 +4105,8 @@ static const struct font_data fontdata_7x14 = {
0x00, /* 0000000 */
0x00, /* 0000000 */
0x00, /* 0000000 */
} };
};
const struct font_desc font_7x14 = {
@ -4113,6 +4114,6 @@ const struct font_desc font_7x14 = {
.name = "7x14",
.width = 7,
.height = 14,
.data = fontdata_7x14.data,
.data = fontdata_7x14,
.pref = 0,
};

View File

@ -10,8 +10,8 @@
#define FONTDATAMAX 4096
static const struct font_data fontdata_8x16 = {
{ 0, 0, FONTDATAMAX, 0 }, {
static const unsigned char fontdata_8x16[FONTDATAMAX] = {
/* 0 0x00 '^@' */
0x00, /* 00000000 */
0x00, /* 00000000 */
@ -4619,7 +4619,8 @@ static const struct font_data fontdata_8x16 = {
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
} };
};
const struct font_desc font_vga_8x16 = {
@ -4627,7 +4628,7 @@ const struct font_desc font_vga_8x16 = {
.name = "VGA8x16",
.width = 8,
.height = 16,
.data = fontdata_8x16.data,
.data = fontdata_8x16,
.pref = 0,
};
EXPORT_SYMBOL(font_vga_8x16);

View File

@ -9,8 +9,8 @@
#define FONTDATAMAX 2048
static const struct font_data fontdata_8x8 = {
{ 0, 0, FONTDATAMAX, 0 }, {
static const unsigned char fontdata_8x8[FONTDATAMAX] = {
/* 0 0x00 '^@' */
0x00, /* 00000000 */
0x00, /* 00000000 */
@ -2570,7 +2570,8 @@ static const struct font_data fontdata_8x8 = {
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
} };
};
const struct font_desc font_vga_8x8 = {
@ -2578,6 +2579,6 @@ const struct font_desc font_vga_8x8 = {
.name = "VGA8x8",
.width = 8,
.height = 8,
.data = fontdata_8x8.data,
.data = fontdata_8x8,
.pref = 0,
};

View File

@ -3,10 +3,7 @@
#include <linux/font.h>
#define FONTDATAMAX 2048
static const struct font_data acorndata_8x8 = {
{ 0, 0, FONTDATAMAX, 0 }, {
static const unsigned char acorndata_8x8[] = {
/* 00 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ^@ */
/* 01 */ 0x7e, 0x81, 0xa5, 0x81, 0xbd, 0x99, 0x81, 0x7e, /* ^A */
/* 02 */ 0x7e, 0xff, 0xbd, 0xff, 0xc3, 0xe7, 0xff, 0x7e, /* ^B */
@ -263,14 +260,14 @@ static const struct font_data acorndata_8x8 = {
/* FD */ 0x38, 0x04, 0x18, 0x20, 0x3c, 0x00, 0x00, 0x00,
/* FE */ 0x00, 0x00, 0x3c, 0x3c, 0x3c, 0x3c, 0x00, 0x00,
/* FF */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
} };
};
const struct font_desc font_acorn_8x8 = {
.idx = ACORN8x8_IDX,
.name = "Acorn8x8",
.width = 8,
.height = 8,
.data = acorndata_8x8.data,
.data = acorndata_8x8,
#ifdef CONFIG_ARCH_ACORN
.pref = 20,
#else

View File

@ -43,8 +43,8 @@ __END__;
#define FONTDATAMAX 1536
static const struct font_data fontdata_mini_4x6 = {
{ 0, 0, FONTDATAMAX, 0 }, {
static const unsigned char fontdata_mini_4x6[FONTDATAMAX] = {
/*{*/
/* Char 0: ' ' */
0xee, /*= [*** ] */
@ -2145,14 +2145,14 @@ static const struct font_data fontdata_mini_4x6 = {
0xee, /*= [*** ] */
0x00, /*= [ ] */
/*}*/
} };
};
const struct font_desc font_mini_4x6 = {
.idx = MINI4x6_IDX,
.name = "MINI4x6",
.width = 4,
.height = 6,
.data = fontdata_mini_4x6.data,
.data = fontdata_mini_4x6,
.pref = 3,
};

View File

@ -14,8 +14,8 @@
#define FONTDATAMAX 2048
static const struct font_data fontdata_pearl8x8 = {
{ 0, 0, FONTDATAMAX, 0 }, {
static const unsigned char fontdata_pearl8x8[FONTDATAMAX] = {
/* 0 0x00 '^@' */
0x00, /* 00000000 */
0x00, /* 00000000 */
@ -2575,13 +2575,14 @@ static const struct font_data fontdata_pearl8x8 = {
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
} };
};
const struct font_desc font_pearl_8x8 = {
.idx = PEARL8x8_IDX,
.name = "PEARL8x8",
.width = 8,
.height = 8,
.data = fontdata_pearl8x8.data,
.data = fontdata_pearl8x8,
.pref = 2,
};

View File

@ -3,8 +3,8 @@
#define FONTDATAMAX 11264
static const struct font_data fontdata_sun12x22 = {
{ 0, 0, FONTDATAMAX, 0 }, {
static const unsigned char fontdata_sun12x22[FONTDATAMAX] = {
/* 0 0x00 '^@' */
0x00, 0x00, /* 000000000000 */
0x00, 0x00, /* 000000000000 */
@ -6148,7 +6148,8 @@ static const struct font_data fontdata_sun12x22 = {
0x00, 0x00, /* 000000000000 */
0x00, 0x00, /* 000000000000 */
0x00, 0x00, /* 000000000000 */
} };
};
const struct font_desc font_sun_12x22 = {
@ -6156,7 +6157,7 @@ const struct font_desc font_sun_12x22 = {
.name = "SUN12x22",
.width = 12,
.height = 22,
.data = fontdata_sun12x22.data,
.data = fontdata_sun12x22,
#ifdef __sparc__
.pref = 5,
#else

View File

@ -3,8 +3,7 @@
#define FONTDATAMAX 4096
static const struct font_data fontdata_sun8x16 = {
{ 0, 0, FONTDATAMAX, 0 }, {
static const unsigned char fontdata_sun8x16[FONTDATAMAX] = {
/* */ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
/* */ 0x00,0x00,0x7e,0x81,0xa5,0x81,0x81,0xbd,0x99,0x81,0x81,0x7e,0x00,0x00,0x00,0x00,
/* */ 0x00,0x00,0x7e,0xff,0xdb,0xff,0xff,0xc3,0xe7,0xff,0xff,0x7e,0x00,0x00,0x00,0x00,
@ -261,14 +260,14 @@ static const struct font_data fontdata_sun8x16 = {
/* */ 0x00,0x70,0xd8,0x30,0x60,0xc8,0xf8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
/* */ 0x00,0x00,0x00,0x00,0x7c,0x7c,0x7c,0x7c,0x7c,0x7c,0x7c,0x00,0x00,0x00,0x00,0x00,
/* */ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
} };
};
const struct font_desc font_sun_8x16 = {
.idx = SUN8x16_IDX,
.name = "SUN8x16",
.width = 8,
.height = 16,
.data = fontdata_sun8x16.data,
.data = fontdata_sun8x16,
#ifdef __sparc__
.pref = 10,
#else

View File

@ -17,6 +17,9 @@
#include <linux/lzo.h>
#include "lzodefs.h"
#define OVERFLOW_ADD_CHECK(a, b) \
(((a) + (b)) < (a))
static noinline size_t
lzo1x_1_do_compress(const unsigned char *in, size_t in_len,
unsigned char *out, size_t *out_len,
@ -39,6 +42,8 @@ lzo1x_1_do_compress(const unsigned char *in, size_t in_len,
size_t t, m_len, m_off;
u32 dv;
literal:
if (unlikely(OVERFLOW_ADD_CHECK(ip, 1 + ((ip - ii) >> 5))))
break;
ip += 1 + ((ip - ii) >> 5);
next:
if (unlikely(ip >= ip_end))
@ -99,7 +104,8 @@ next:
m_len += 8;
v = get_unaligned((const u64 *) (ip + m_len)) ^
get_unaligned((const u64 *) (m_pos + m_len));
if (unlikely(ip + m_len >= ip_end))
if (unlikely(OVERFLOW_ADD_CHECK(ip, m_len)
|| (ip + m_len >= ip_end)))
goto m_len_done;
} while (v == 0);
}
@ -124,7 +130,8 @@ next:
m_len += 4;
v = get_unaligned((const u32 *) (ip + m_len)) ^
get_unaligned((const u32 *) (m_pos + m_len));
if (unlikely(ip + m_len >= ip_end))
if (unlikely(OVERFLOW_ADD_CHECK(ip, m_len)
|| (ip + m_len >= ip_end)))
goto m_len_done;
} while (v == 0);
}
@ -160,7 +167,8 @@ next:
if (ip[m_len] != m_pos[m_len])
break;
m_len += 1;
if (unlikely(ip + m_len >= ip_end))
if (unlikely(OVERFLOW_ADD_CHECK(ip, m_len)
|| (ip + m_len >= ip_end)))
goto m_len_done;
} while (ip[m_len] == m_pos[m_len]);
}
@ -224,8 +232,8 @@ int lzo1x_1_compress(const unsigned char *in, size_t in_len,
while (l > 20) {
size_t ll = l <= (M4_MAX_OFFSET + 1) ? l : (M4_MAX_OFFSET + 1);
uintptr_t ll_end = (uintptr_t) ip + ll;
if ((ll_end + ((t + ll) >> 5)) <= ll_end)
// check for address space wraparound
if (((uintptr_t) ip + ll + ((t + ll) >> 5)) <= (uintptr_t) ip)
break;
BUILD_BUG_ON(D_SIZE * sizeof(lzo_dict_t) > LZO1X_1_MEM_COMPRESS);
memset(wrkmem, 0, D_SIZE * sizeof(lzo_dict_t));

View File

@ -48,7 +48,7 @@ static inline void prandom_state_selftest(void)
}
#endif
DEFINE_PER_CPU(struct rnd_state, net_rand_state) __latent_entropy;
static DEFINE_PER_CPU(struct rnd_state, net_rand_state) __latent_entropy;
/**
* prandom_u32_state - seeded pseudo-random number generator.

View File

@ -477,7 +477,7 @@ struct scatterlist *sgl_alloc_order(unsigned long long length,
elem_len = min_t(u64, length, PAGE_SIZE << order);
page = alloc_pages(gfp, order);
if (!page) {
sgl_free_order(sgl, order);
sgl_free(sgl);
return NULL;
}

View File

@ -8,6 +8,9 @@
#include <linux/mm.h>
#include <linux/quicklist.h>
#include <linux/cma.h>
#ifdef CONFIG_ONEPLUS_HEALTHINFO
#include <linux/oem/oneplus_ion.h>
#endif
void show_mem(unsigned int filter, nodemask_t *nodemask)
{
@ -49,4 +52,7 @@ void show_mem(unsigned int filter, nodemask_t *nodemask)
#ifdef CONFIG_MEMORY_FAILURE
printk("%lu pages hwpoisoned\n", atomic_long_read(&num_poisoned_pages));
#endif
#ifdef CONFIG_ONEPLUS_HEALTHINFO
printk("%lu pages ion total used\n", ion_total() >> PAGE_SHIFT);
#endif
}

View File

@ -236,30 +236,6 @@ ssize_t strscpy(char *dest, const char *src, size_t count)
EXPORT_SYMBOL(strscpy);
#endif
/**
* stpcpy - copy a string from src to dest returning a pointer to the new end
* of dest, including src's %NUL-terminator. May overrun dest.
* @dest: pointer to end of string being copied into. Must be large enough
* to receive copy.
* @src: pointer to the beginning of string being copied from. Must not overlap
* dest.
*
* stpcpy differs from strcpy in a key way: the return value is a pointer
* to the new %NUL-terminating character in @dest. (For strcpy, the return
* value is a pointer to the start of @dest). This interface is considered
* unsafe as it doesn't perform bounds checking of the inputs. As such it's
* not recommended for usage. Instead, its definition is provided in case
* the compiler lowers other libcalls to stpcpy.
*/
char *stpcpy(char *__restrict__ dest, const char *__restrict__ src);
char *stpcpy(char *__restrict__ dest, const char *__restrict__ src)
{
while ((*dest++ = *src++) != '\0')
/* nothing */;
return --dest;
}
EXPORT_SYMBOL(stpcpy);
#ifndef __HAVE_ARCH_STRCAT
/**
* strcat - Append one %NUL-terminated string to another

View File

@ -747,7 +747,7 @@ static int trigger_config_run_type(struct kmod_test_device *test_dev,
break;
case TEST_KMOD_FS_TYPE:
kfree_const(config->test_fs);
config->test_fs = NULL;
config->test_driver = NULL;
copied = config_copy_test_fs(config, test_str,
strlen(test_str));
break;