2 * Dynamic Binary Instrumentation Module based on KProbes
3 * energy/lcd/lcd_debugfs.c
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 * Copyright (C) Samsung Electronics, 2013
21 * 2013 Vyacheslav Cherkashin <v.cherkashin@samsung.com>
26 #include <linux/debugfs.h>
27 #include <linux/module.h>
28 #include <linux/slab.h>
29 #include <energy/lcd/lcd_base.h>
30 #include <energy/debugfs_energy.h>
31 #include <energy/rational_debugfs.h>
34 static int get_system(void *data, u64 *val)
36 struct lcd_ops *ops = (struct lcd_ops *)data;
37 const size_t size = get_lcd_size_array(ops);
38 const size_t size_1 = size - 1;
39 u64 i_max, j_min, t, e = 0;
43 array_time = kmalloc(sizeof(*array_time) * size, GFP_KERNEL);
44 if (array_time == NULL)
47 get_lcd_array_time(ops, array_time);
49 for (i = 0; i < size; ++i) {
52 /* e = (i * max + (k - i) * min) * t / k */
54 i_max = div_u64(i * ops->max_coef.num * t,
56 j_min = div_u64(j * ops->min_coef.num * t,
58 e += div_u64(i_max + j_min, size_1);
68 SWAP_DEFINE_SIMPLE_ATTRIBUTE(fops_get_system, get_system, NULL, "%llu\n");
71 static struct dentry *lcd_dir;
74 * @brief Register LCD in debugfs
76 * @param ops LCD operations
79 int register_lcd_debugfs(struct lcd_ops *ops)
82 struct dentry *dentry, *system;
87 dentry = debugfs_create_dir(ops->name, lcd_dir);
91 ret = create_rational_files(dentry, &ops->min_coef,
92 "min_num", "min_denom");
96 ret = create_rational_files(dentry, &ops->max_coef,
97 "max_num", "max_denom");
101 system = debugfs_create_file("system", 0600, dentry, (void *)ops,
106 ops->dentry = dentry;
110 debugfs_remove_recursive(dentry);
115 * @brief Unregister LCD in debugfs
117 * @param ops LCD operations
120 void unregister_lcd_debugfs(struct lcd_ops *ops)
122 debugfs_remove_recursive(ops->dentry);
126 * @brief Destroy debugfs for LCD
130 void exit_lcd_debugfs(void)
133 debugfs_remove_recursive(lcd_dir);
139 * @brief Create debugfs for LCD
141 * @param dentry Dentry
144 int init_lcd_debugfs(struct dentry *energy_dir)
146 lcd_dir = debugfs_create_dir("lcd", energy_dir);