如何在多个驱动程序中使用函数?

问题描述 投票:1回答:1

我想在另一个驱动程序中调用do_input_boost函数,但我找不到调用该函数的方法。

static void do_input_boost(struct kthread_work *work)
{
    unsigned int i, ret;
    struct cpu_sync *i_sync_info;

    /* Set the input_boost_min for all CPUs in the system */
    pr_debug("Setting input boost min for all CPUs\n");
    for_each_possible_cpu(i) {
        i_sync_info = &per_cpu(sync_info, i);
        i_sync_info->input_boost_min = i_sync_info->input_boost_freq;
    }

    queue_delayed_work(system_power_efficient_wq,
        &input_boost_rem, msecs_to_jiffies(input_boost_ms));
}

我还添加了EXPORT_SYMBOL(do_input_boost)但找不到调用此函数的正确原型定义,比如

do_input_boost();

编辑:我添加了一个心脏和linkedin目标驱动程序

#ifdef CONFIG_CPU_BOOST
extern void do_input_boost(void);
#else
extern void do_input_boost(void)
{
}
#endif
c function prototype
1个回答
1
投票

IMO你必须删除static,因为它限制了这个函数对当前转换单元的可见性(假设另一个驱动程序不在同一个.c文件中)。

删除static将使该函数成为全局函数,并且可以使用.c声明从其他extern文件中访问它。

让我们说我们的do_input_boost的这个功能是在a.c文件中定义的,你的驱动程序是在b.c文件中(你要调用那个函数),然后:

b.c你会声明这个函数:extern void do_input_boost(struct kthread_work*);然后你可以调用它。

© www.soinside.com 2019 - 2024. All rights reserved.