HID: usbhid: fix inconsistent reset/resume/reset-resume behavior
[linux/fpc-iii.git] / kernel / sched / cpufreq.c
blob928c4ba32f683022be6388c99b4df418e9db3ca8
1 /*
2 * Scheduler code and data structures related to cpufreq.
4 * Copyright (C) 2016, Intel Corporation
5 * Author: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
12 #include "sched.h"
14 DEFINE_PER_CPU(struct update_util_data *, cpufreq_update_util_data);
16 /**
17 * cpufreq_set_update_util_data - Populate the CPU's update_util_data pointer.
18 * @cpu: The CPU to set the pointer for.
19 * @data: New pointer value.
21 * Set and publish the update_util_data pointer for the given CPU. That pointer
22 * points to a struct update_util_data object containing a callback function
23 * to call from cpufreq_update_util(). That function will be called from an RCU
24 * read-side critical section, so it must not sleep.
26 * Callers must use RCU-sched callbacks to free any memory that might be
27 * accessed via the old update_util_data pointer or invoke synchronize_sched()
28 * right after this function to avoid use-after-free.
30 void cpufreq_set_update_util_data(int cpu, struct update_util_data *data)
32 if (WARN_ON(data && !data->func))
33 return;
35 rcu_assign_pointer(per_cpu(cpufreq_update_util_data, cpu), data);
37 EXPORT_SYMBOL_GPL(cpufreq_set_update_util_data);