2013-07-19 40 views
0

我想知道我怎么可以访问名成员在我的司机/ driver.c 这里是在include/linux/cpufreq.h如何导出结构成员

struct cpufreq_governor { 
    char name[CPUFREQ_NAME_LEN]; 
    int  (*governor) (struct cpufreq_policy *policy, 
       unsigned int event); 
    ssize_t (*show_setspeed) (struct cpufreq_policy *policy, 
        char *buf); 
    int  (*store_setspeed) (struct cpufreq_policy *policy, 
        unsigned int freq); 
    unsigned int max_transition_latency; /* HW must be able to switch to 
      next freq faster than this value in nano secs or we 
      will fallback to performance governor */ 
    struct list_head governor_list; 
    struct module  *owner; 
}; 

driver.c有码一个函数取决于主动调速器。所以如何把它作为驱动程序中的变量。c

+0

你需要什么活跃的州长的名字? (如果CPU有不同的调节器呢?) –

+0

@CL。只有一个CPU.btw这样做的原因是,在我的驱动程序中,有些功能会在特殊情况下增加CPU频率。但它在powersave调速器上的表现也一样,其中CPU频率必须最小,但它会增加它。这就是为什么我需要它。 – user2578525

回答

0

Cpufreq导出符号cpufreq_get_policy,您可以通过它获取策略。 cpufreq_policy有会员governor。这是你正在寻找的。

+0

我在驱动程序 [格式化链接到pastebin](http://pastebin.com/m3GVviB6) 中添加了以下行,但驱动程序在执行该函数时挂起。没有打印在dmesg上。 – user2578525

+0

如何在'gov_info'中获取数据?我想,你正在访问未分配的区域 –

+0

我做了一些错误的。不过,我没有多少经验。我只是添加了这些lines.I会很高兴,如果你建议我一种方法来保存正确的值在is_powersave变量。 – user2578525