2 * Copyright (c) 2012 NVIDIA CORPORATION. All rights reserved.
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 2 of the License.
8 * This program is distributed in the hope that it will be useful, but WITHOUT
9 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 * You should have received a copy of the GNU General Public License along
14 * with this program; if not, write to the Free Software Foundation, Inc.,
15 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 #include <linux/kernel.h>
20 #include <linux/module.h>
21 #include <linux/string.h>
22 #include <linux/mutex.h>
23 #include <linux/errno.h>
24 #include <linux/edp.h>
26 DEFINE_MUTEX(edp_lock);
27 static LIST_HEAD(edp_managers);
29 static struct edp_manager *find_manager(const char *name)
31 struct edp_manager *mgr;
36 list_for_each_entry(mgr, &edp_managers, link)
37 if (!strcmp(mgr->name, name))
43 int edp_register_manager(struct edp_manager *mgr)
50 mutex_lock(&edp_lock);
51 if (!find_manager(mgr->name)) {
52 list_add_tail(&mgr->link, &edp_managers);
53 mgr->registered = true;
56 mutex_unlock(&edp_lock);
60 EXPORT_SYMBOL(edp_register_manager);
62 int edp_unregister_manager(struct edp_manager *mgr)
69 mutex_lock(&edp_lock);
70 if (mgr->registered) {
72 mgr->registered = false;
75 mutex_unlock(&edp_lock);
79 EXPORT_SYMBOL(edp_unregister_manager);
81 struct edp_manager *edp_get_manager(const char *name)
83 struct edp_manager *mgr;
85 mutex_lock(&edp_lock);
86 mgr = find_manager(name);
87 mutex_unlock(&edp_lock);
91 EXPORT_SYMBOL(edp_get_manager);