Skip to content

Commit ccade68

Browse files
committed
foo
2 parents 672ddb8 + a0c266c commit ccade68

File tree

7 files changed

+39
-31
lines changed

7 files changed

+39
-31
lines changed

arch/alpha/kernel/core_marvel.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include <linux/vmalloc.h>
1818
#include <linux/mc146818rtc.h>
1919
#include <linux/rtc.h>
20+
#include <linux/string.h>
2021
#include <linux/module.h>
2122
#include <linux/memblock.h>
2223

@@ -79,10 +80,12 @@ mk_resource_name(int pe, int port, char *str)
7980
{
8081
char tmp[80];
8182
char *name;
82-
83-
sprintf(tmp, "PCI %s PE %d PORT %d", str, pe, port);
84-
name = memblock_alloc_or_panic(strlen(tmp) + 1, SMP_CACHE_BYTES);
85-
strcpy(name, tmp);
83+
size_t sz;
84+
85+
sz = scnprintf(tmp, sizeof(tmp), "PCI %s PE %d PORT %d", str, pe, port);
86+
sz += 1; /* NUL terminator */
87+
name = memblock_alloc_or_panic(sz, SMP_CACHE_BYTES);
88+
strscpy(name, tmp, sz);
8689

8790
return name;
8891
}

arch/riscv/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ config RISCV
9696
select CLINT_TIMER if RISCV_M_MODE
9797
select CLONE_BACKWARDS
9898
select COMMON_CLK
99+
select CPU_NO_EFFICIENT_FFS if !RISCV_ISA_ZBB
99100
select CPU_PM if CPU_IDLE || HIBERNATION || SUSPEND
100101
select EDAC_SUPPORT
101102
select FRAME_POINTER if PERF_EVENTS || (FUNCTION_TRACER && !DYNAMIC_FTRACE)

arch/riscv/kernel/setup.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
#include <linux/efi.h>
2222
#include <linux/crash_dump.h>
2323
#include <linux/panic_notifier.h>
24+
#include <linux/jump_label.h>
25+
#include <linux/gcd.h>
2426

2527
#include <asm/acpi.h>
2628
#include <asm/alternative.h>
@@ -361,6 +363,9 @@ void __init setup_arch(char **cmdline_p)
361363

362364
riscv_user_isa_enable();
363365
riscv_spinlock_init();
366+
367+
if (!IS_ENABLED(CONFIG_RISCV_ISA_ZBB) || !riscv_isa_extension_available(NULL, ZBB))
368+
static_branch_disable(&efficient_ffs_key);
364369
}
365370

366371
bool arch_cpu_is_hotpluggable(int cpu)

fs/ocfs2/stack_user.c

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,6 @@ static int ocfs2_control_do_setnode_msg(struct file *file,
360360
struct ocfs2_control_message_setn *msg)
361361
{
362362
long nodenum;
363-
char *ptr = NULL;
364363
struct ocfs2_control_private *p = file->private_data;
365364

366365
if (ocfs2_control_get_handshake_state(file) !=
@@ -375,8 +374,7 @@ static int ocfs2_control_do_setnode_msg(struct file *file,
375374
return -EINVAL;
376375
msg->space = msg->newline = '\0';
377376

378-
nodenum = simple_strtol(msg->nodestr, &ptr, 16);
379-
if (!ptr || *ptr)
377+
if (kstrtol(msg->nodestr, 16, &nodenum))
380378
return -EINVAL;
381379

382380
if ((nodenum == LONG_MIN) || (nodenum == LONG_MAX) ||
@@ -391,7 +389,6 @@ static int ocfs2_control_do_setversion_msg(struct file *file,
391389
struct ocfs2_control_message_setv *msg)
392390
{
393391
long major, minor;
394-
char *ptr = NULL;
395392
struct ocfs2_control_private *p = file->private_data;
396393
struct ocfs2_protocol_version *max =
397394
&ocfs2_user_plugin.sp_max_proto;
@@ -409,11 +406,9 @@ static int ocfs2_control_do_setversion_msg(struct file *file,
409406
return -EINVAL;
410407
msg->space1 = msg->space2 = msg->newline = '\0';
411408

412-
major = simple_strtol(msg->major, &ptr, 16);
413-
if (!ptr || *ptr)
409+
if (kstrtol(msg->major, 16, &major))
414410
return -EINVAL;
415-
minor = simple_strtol(msg->minor, &ptr, 16);
416-
if (!ptr || *ptr)
411+
if (kstrtol(msg->minor, 16, &minor))
417412
return -EINVAL;
418413

419414
/*
@@ -441,7 +436,6 @@ static int ocfs2_control_do_down_msg(struct file *file,
441436
struct ocfs2_control_message_down *msg)
442437
{
443438
long nodenum;
444-
char *p = NULL;
445439

446440
if (ocfs2_control_get_handshake_state(file) !=
447441
OCFS2_CONTROL_HANDSHAKE_VALID)
@@ -456,8 +450,7 @@ static int ocfs2_control_do_down_msg(struct file *file,
456450
return -EINVAL;
457451
msg->space1 = msg->space2 = msg->newline = '\0';
458452

459-
nodenum = simple_strtol(msg->nodestr, &p, 16);
460-
if (!p || *p)
453+
if (kstrtol(msg->nodestr, 16, &nodenum))
461454
return -EINVAL;
462455

463456
if ((nodenum == LONG_MIN) || (nodenum == LONG_MAX) ||

include/linux/gcd.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
#define _GCD_H
44

55
#include <linux/compiler.h>
6+
#include <linux/jump_label.h>
7+
8+
DECLARE_STATIC_KEY_TRUE(efficient_ffs_key);
69

710
unsigned long gcd(unsigned long a, unsigned long b) __attribute_const__;
811

include/linux/jhash.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
* Jozsef
2525
*/
2626
#include <linux/bitops.h>
27-
#include <linux/unaligned/packed_struct.h>
27+
#include <linux/unaligned.h>
2828

2929
/* Best hash sizes are of power of two */
3030
#define jhash_size(n) ((u32)1<<(n))
@@ -77,9 +77,9 @@ static inline u32 jhash(const void *key, u32 length, u32 initval)
7777

7878
/* All but the last block: affect some 32 bits of (a,b,c) */
7979
while (length > 12) {
80-
a += __get_unaligned_cpu32(k);
81-
b += __get_unaligned_cpu32(k + 4);
82-
c += __get_unaligned_cpu32(k + 8);
80+
a += get_unaligned((u32 *)k);
81+
b += get_unaligned((u32 *)(k + 4));
82+
c += get_unaligned((u32 *)(k + 8));
8383
__jhash_mix(a, b, c);
8484
length -= 12;
8585
k += 12;

lib/math/gcd.c

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,22 +11,16 @@
1111
* has decent hardware division.
1212
*/
1313

14+
DEFINE_STATIC_KEY_TRUE(efficient_ffs_key);
15+
1416
#if !defined(CONFIG_CPU_NO_EFFICIENT_FFS)
1517

1618
/* If __ffs is available, the even/odd algorithm benchmarks slower. */
1719

18-
/**
19-
* gcd - calculate and return the greatest common divisor of 2 unsigned longs
20-
* @a: first value
21-
* @b: second value
22-
*/
23-
unsigned long gcd(unsigned long a, unsigned long b)
20+
static unsigned long binary_gcd(unsigned long a, unsigned long b)
2421
{
2522
unsigned long r = a | b;
2623

27-
if (!a || !b)
28-
return r;
29-
3024
b >>= __ffs(b);
3125
if (b == 1)
3226
return r & -r;
@@ -44,16 +38,27 @@ unsigned long gcd(unsigned long a, unsigned long b)
4438
}
4539
}
4640

47-
#else
41+
#endif
4842

4943
/* If normalization is done by loops, the even/odd algorithm is a win. */
44+
45+
/**
46+
* gcd - calculate and return the greatest common divisor of 2 unsigned longs
47+
* @a: first value
48+
* @b: second value
49+
*/
5050
unsigned long gcd(unsigned long a, unsigned long b)
5151
{
5252
unsigned long r = a | b;
5353

5454
if (!a || !b)
5555
return r;
5656

57+
#if !defined(CONFIG_CPU_NO_EFFICIENT_FFS)
58+
if (static_branch_likely(&efficient_ffs_key))
59+
return binary_gcd(a, b);
60+
#endif
61+
5762
/* Isolate lsbit of r */
5863
r &= -r;
5964

@@ -80,6 +85,4 @@ unsigned long gcd(unsigned long a, unsigned long b)
8085
}
8186
}
8287

83-
#endif
84-
8588
EXPORT_SYMBOL_GPL(gcd);

0 commit comments

Comments
 (0)