Android 如何修复未知字段';暂停';编译smartass调控器时在初始值设定项中指定?
我一直在试图弄清楚为什么当我试图编译我的android内核时,smarts governor会出现以下错误:Android 如何修复未知字段';暂停';编译smartass调控器时在初始值设定项中指定?,android,c++,c,kernel,Android,C++,C,Kernel,我一直在试图弄清楚为什么当我试图编译我的android内核时,smarts governor会出现以下错误: drivers/cpufreq/cpufreq_smartass2.c:844:2: error: unknown field 'suspend' specified in initializer .suspend = smartass_early_suspend, ^ drivers/cpufreq/cpufreq_smartass2.c:844:13:
drivers/cpufreq/cpufreq_smartass2.c:844:2: error: unknown field 'suspend' specified in initializer
.suspend = smartass_early_suspend,
^
drivers/cpufreq/cpufreq_smartass2.c:844:13: warning: excess elements in struct initializer
error, forbidden warning: cpufreq_smartass2.c:844
make[2]: *** [drivers/cpufreq/cpufreq_smartass2.o] Error 1
make[1]: *** [drivers/cpufreq] Error 2
make: *** [drivers] Error 2
make: *** Waiting for unfinished jobs....
我检查了给出错误的行,这是一个初始化的变量,它是一个结构数据结构的成员。代码如下:
static struct early_suspend smartass_power_suspend = {
.suspend = smartass_early_suspend,
.resume = smartass_late_resume,
#ifdef CONFIG_MACH_HERO
.level = EARLY_SUSPEND_LEVEL_DISABLE_FB + 1,
#endif
};
以下是完整代码:
static void smartass_suspend(int cpu, int suspend)
{
struct smartass_info_s *this_smartass = &per_cpu(smartass_info, smp_processor_id());
struct cpufreq_policy *policy = this_smartass->cur_policy;
unsigned int new_freq;
if (!this_smartass->enable)
return;
smartass_update_min_max(this_smartass,policy,suspend);
if (!suspend) { // resume at max speed:
new_freq = validate_freq(policy,sleep_wakeup_freq);
dprintk(SMARTASS_DEBUG_JUMPS,"SmartassS: awaking at %d\n",new_freq);
__cpufreq_driver_target(policy, new_freq,
CPUFREQ_RELATION_L);
} else {
// to avoid wakeup issues with quick sleep/wakeup don't change actual frequency when entering sleep
// to allow some time to settle down. Instead we just reset our statistics (and reset the timer).
// Eventually, the timer will adjust the frequency if necessary.
this_smartass->freq_change_time_in_idle =
get_cpu_idle_time_us(cpu,&this_smartass->freq_change_time);
dprintk(SMARTASS_DEBUG_JUMPS,"SmartassS: suspending at %d\n",policy->cur);
}
reset_timer(smp_processor_id(),this_smartass);
}
static void smartass_early_suspend(struct early_suspend *handler) {
int i;
if (suspended || sleep_ideal_freq==0) // disable behavior for sleep_ideal_freq==0
return;
suspended = 1;
for_each_online_cpu(i)
smartass_suspend(i,1);
}
static void smartass_late_resume(struct early_suspend *handler) {
int i;
if (!suspended) // already not suspended so nothing to do
return;
suspended = 0;
for_each_online_cpu(i)
smartass_suspend(i,0);
}
static struct early_suspend smartass_power_suspend = {
.suspend = smartass_early_suspend,
.resume = smartass_late_resume,
#ifdef CONFIG_MACH_HERO
.level = EARLY_SUSPEND_LEVEL_DISABLE_FB + 1,
#endif
};
代码在语法上似乎是正确的,我遇到了这个问题。有人能帮忙吗?多亏了@Tsyvarev,我解决了“初始化器中指定的未知字段‘suspend’的问题” 在尝试添加其他调控器并尝试编译之后,我收到我添加的新调控器的此错误消息
drivers/built-in.o: In function cpufreq_smartass_init':
/home/nick/android/LGD722LKernel/drivers/cpufreq/cpufreq_smartass2.c:898: undefined reference to `register_early_suspend'
我已经检查了函数寄存器_eary _suspend,它的调用方式和参数传递给函数的方式看起来是正确的。我想它可能是来自makefile,但这只是我的观点。如果有人对这个问题有任何其他想法,请分享我在内核开发方面没有太多经验,你的想法/建议会对我很有帮助。你能展示一下
struct early\u suspend
的定义吗?错误消息说此结构没有名为suspend
的成员。找到它:CONFIG\u HAS\u EARLYSUSPEND
的值是多少?我四处查看了一下,它没有用值初始化。它被设置为#define,即defined(CONFIG_HAS_EARLYSUSPEND)它被定义了吗?你确定吗?它看起来像一个内核配置选项,是否在配置中设置?将\ifndef CONFIG\u HAS#EARLYSUSPEND#error“oops”#endif
和每个
一起添加到该文件的某个新行中,然后再次编译。我使用配置的初始化搜索函数查看我的git\u HAS#EARLYSUSPEND没有看到类似的内容。