Merge tag 'v3.10.54' into linux-linaro-lsk
[firefly-linux-kernel-4.4.55.git] / drivers / gator / gator_events_mali_common.c
1 /**
2  * Copyright (C) ARM Limited 2012-2014. All rights reserved.
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License version 2 as
6  * published by the Free Software Foundation.
7  *
8  */
9 #include "gator_events_mali_common.h"
10
11 extern int gator_mali_create_file_system(const char *mali_name, const char *event_name, struct super_block *sb, struct dentry *root, mali_counter *counter, unsigned long *event)
12 {
13         int err;
14         char buf[255];
15         struct dentry *dir;
16
17         /* If the counter name is empty ignore it */
18         if (strlen(event_name) != 0) {
19                 /* Set up the filesystem entry for this event. */
20                 snprintf(buf, sizeof(buf), "ARM_%s_%s", mali_name, event_name);
21
22                 dir = gatorfs_mkdir(sb, root, buf);
23
24                 if (dir == NULL) {
25                         pr_debug("gator: %s: error creating file system for: %s (%s)", mali_name, event_name, buf);
26                         return -1;
27                 }
28
29                 err = gatorfs_create_ulong(sb, dir, "enabled", &counter->enabled);
30                 if (err != 0) {
31                         pr_debug("gator: %s: error calling gatorfs_create_ulong for: %s (%s)", mali_name, event_name, buf);
32                         return -1;
33                 }
34                 err = gatorfs_create_ro_ulong(sb, dir, "key", &counter->key);
35                 if (err != 0) {
36                         pr_debug("gator: %s: error calling gatorfs_create_ro_ulong for: %s (%s)", mali_name, event_name, buf);
37                         return -1;
38                 }
39                 if (counter->cores != -1) {
40                         err = gatorfs_create_ro_ulong(sb, dir, "cores", &counter->cores);
41                         if (err != 0) {
42                                 pr_debug("gator: %s: error calling gatorfs_create_ro_ulong for: %s (%s)", mali_name, event_name, buf);
43                                 return -1;
44                         }
45                 }
46                 if (event != NULL) {
47                         err = gatorfs_create_ulong(sb, dir, "event", event);
48                         if (err != 0) {
49                                 pr_debug("gator: %s: error calling gatorfs_create_ro_ulong for: %s (%s)", mali_name, event_name, buf);
50                                 return -1;
51                         }
52                 }
53         }
54
55         return 0;
56 }
57
58 extern void gator_mali_initialise_counters(mali_counter counters[], unsigned int n_counters)
59 {
60         unsigned int cnt;
61
62         for (cnt = 0; cnt < n_counters; cnt++) {
63                 mali_counter *counter = &counters[cnt];
64
65                 counter->key = gator_events_get_key();
66                 counter->enabled = 0;
67                 counter->cores = -1;
68         }
69 }