Пример #1
0
static int __init msm_sleep_info_init(void)
{
	int err = 0, cpu = 0;
	struct sleep_data *sleep_info = NULL;
	struct hrtimer *timer;

	//printk(KERN_INFO "msm_sleep_stats: Initializing sleep stats ");
	sleep_info = &core_sleep_info;
	adaptive_wq = create_singlethread_workqueue("adaptive");
	INIT_WORK(&sleep_info->work, notify_uspace_work_fn);

	sleep_info->notifier.notifier_call = msm_idle_stats_notified;

	for_each_possible_cpu(cpu) {
		timer = &per_cpu(core_sleep_timer, cpu);
		hrtimer_init(timer,  CLOCK_MONOTONIC,
			HRTIMER_MODE_REL);
		timer->function = timer_func;
		err = msm_cpuidle_register_notifier(cpu,
					&sleep_info->notifier);
		if (err) {
			/*pr_err("%s: failed to register idle notification\n", __func__)*/;
		}
	}

	
	err = add_sysfs_objects(sleep_info);
	if (err) {
		//printk(KERN_INFO "msm_sleep_stats: Failed to initialize sleep stats");
		remove_sysfs_objects(sleep_info);
	}

	return 0;
}
static int __init msm_sleep_info_init(void)
{
	int err = 0;
	int cpu;
	struct sleep_data *sleep_info = NULL;

	msm_stats_wq = create_workqueue("msm_stats_wq");
	if (!msm_stats_wq) {
		printk(KERN_ERR "Creation of msm_stats_wq failed!!\n");
		return -EINVAL;
	}
	

	/* Register callback from idle for all cpus */
	msm_idle_register_cb(idle_enter, idle_exit);
	INIT_DELAYED_WORK_DEFERRABLE(&rq_info.rq_work, rq_work_fn);
	INIT_DELAYED_WORK_DEFERRABLE(&rq_info.def_timer_work, def_work_fn);
	init_rq_attribs();

	for_each_possible_cpu(cpu) {
		printk(KERN_INFO "msm_sleep_stats: Initializing sleep stats "
				"for CPU[%d]\n", cpu);
		sleep_info = &per_cpu(core_sleep_info, cpu);
		sleep_info->cpu = cpu;
		INIT_WORK(&sleep_info->work, notify_uspace_work_fn);

		/* Initialize high resolution timer */
		hrtimer_init(&sleep_info->timer, CLOCK_MONOTONIC,
				HRTIMER_MODE_REL);
		sleep_info->timer.function = timer_func;

		/* Register for cpufreq policy changes */
		sleep_info->nb.notifier_call = policy_change_notifier;
		err = cpufreq_register_notifier(&sleep_info->nb,
					CPUFREQ_POLICY_NOTIFIER);
		if (err)
			goto cleanup;

		/* Create sysfs object */
		err = add_sysfs_objects(sleep_info);
		if (err)
			goto cleanup;

		continue;
cleanup:
		printk(KERN_INFO "msm_sleep_stats: Failed to initialize sleep "
				"stats for CPU[%d]\n", cpu);
		sleep_info->cpu = -1;
		cpufreq_unregister_notifier(&sleep_info->nb,
				CPUFREQ_POLICY_NOTIFIER);
		remove_sysfs_objects(sleep_info);
	}

	return 0;
}