diff --git a/prefetch_mod.c b/prefetch_mod.c index c8dd790020f9b04ed5c8a67653c8c3b8e97052b0..d8dfe950ad365ea89ada345b45a40ac2d1db88e1 100644 --- a/prefetch_mod.c +++ b/prefetch_mod.c @@ -83,7 +83,7 @@ static struct miscdevice misc = { static ssize_t read_unique_store(struct device* dev, struct device_attribute* attr, const char* buf, size_t count) { - ssize_t ret; + ssize_t ret = -1; int value = -1; ret = kstrtouint(buf, 0, &value); @@ -102,7 +102,7 @@ static ssize_t read_unique_store(struct device* dev, static ssize_t read_unique_show(struct device* dev, struct device_attribute* attr, char* buf) { - int cpu; + int cpu = -1; int count = 0; int __percpu *cur = alloc_percpu(int); @@ -127,7 +127,7 @@ static ssize_t read_unique_show(struct device* dev, static ssize_t prefetch_store(struct device* dev, struct device_attribute* attr, const char* buf, size_t count) { - ssize_t ret; + ssize_t ret = -1; int policy = -1; ret = kstrtouint(buf, 0, &policy); @@ -150,7 +150,8 @@ static ssize_t prefetch_store(struct device* dev, static ssize_t prefetch_show(struct device* dev, struct device_attribute* attr, char* buf) { - int cpu, policy; + int cpu = -1; + int policy = -1; int count = 0; mutex_lock(&prefetch_mtx); @@ -172,7 +173,7 @@ static ssize_t prefetch_show(struct device* dev, static ssize_t prefetch_mask_store(struct device* dev, struct device_attribute* attr, const char* buf, size_t count) { - int ret; + int ret = -1; mutex_lock(&prefetch_mtx); ret = cpulist_parse(buf, prefetch_cpumask_value); @@ -194,7 +195,7 @@ prefetch_mask_end: static ssize_t prefetch_mask_show(struct device* dev, struct device_attribute* attr, char* buf) { - ssize_t ret; + ssize_t ret = -1; mutex_lock(&prefetch_mtx); ret = cpumap_print_to_pagebuf(true, buf, prefetch_cpumask_value); mutex_unlock(&prefetch_mtx); @@ -209,8 +210,8 @@ static ssize_t prefetch_mask_show(struct device* dev, static int __init prefetch_init(void) { - int ret; - int cpu; + int ret = -1; + int cpu = -1; /* mask: initial a mask */ if (!alloc_cpumask_var(&prefetch_cpumask_value, GFP_KERNEL)) { ret = -ENOMEM; diff --git a/prefetch_mod.h b/prefetch_mod.h index 485ef19db457bba00826a273f06799309e820dd3..2f2a6dfbadd296961516c0ce6e61d24f482baff2 100644 --- a/prefetch_mod.h +++ b/prefetch_mod.h @@ -6,8 +6,7 @@ enum { ENABLE }; -#define CACHE_READUNIQ_OFFSET 40 -#define CACHE_READUNIQ_CTRL (1L << CACHE_READUNIQ_OFFSET) +#define CACHE_READUNIQ_CTRL (1L << 40) #ifdef CONFIG_ARCH_HISI typedef struct { diff --git a/prefetch_reg.c b/prefetch_reg.c index 8a06d6dc5faa7685026d37dd059b1e4bbb28b290..11c137a68bb57343c81a4d8bc5774aedc1f0307a 100644 --- a/prefetch_reg.c +++ b/prefetch_reg.c @@ -118,11 +118,12 @@ void read_unique_set(void *dummy) return; } +static const u64 readUniqueOffset = 40; void read_unique_get(void *dummy) { int *value = this_cpu_ptr((int __percpu *)dummy); u64 reg_value = read_sysreg(S3_1_c15_c6_4); - *value = (reg_value >> CACHE_READUNIQ_OFFSET) & 0x1; + *value = (reg_value >> readUniqueOffset) & 0x1; return; } #else