Commit 3d75095a533aa3bbad652369ffde4c129781b8ec

Authored by Sachin Kamat
Committed by Mark Brown
1 parent c1be5a5b1b

regulator: dbx500: Make local symbol static

power_state_active_get is used only in this file. Make it static.
While at it also move this function definition inside the
CONFIG_REGULATOR_DEBUG macro as it is called only from within it.
This also avoids further build warning related to unused definition.

Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>

Showing 1 changed file with 12 additions and 12 deletions Inline Diff

drivers/regulator/dbx500-prcmu.c
1 /* 1 /*
2 * Copyright (C) ST-Ericsson SA 2010 2 * Copyright (C) ST-Ericsson SA 2010
3 * 3 *
4 * License Terms: GNU General Public License v2 4 * License Terms: GNU General Public License v2
5 * Authors: Sundar Iyer <sundar.iyer@stericsson.com> for ST-Ericsson 5 * Authors: Sundar Iyer <sundar.iyer@stericsson.com> for ST-Ericsson
6 * Bengt Jonsson <bengt.g.jonsson@stericsson.com> for ST-Ericsson 6 * Bengt Jonsson <bengt.g.jonsson@stericsson.com> for ST-Ericsson
7 * 7 *
8 * UX500 common part of Power domain regulators 8 * UX500 common part of Power domain regulators
9 */ 9 */
10 10
11 #include <linux/kernel.h> 11 #include <linux/kernel.h>
12 #include <linux/err.h> 12 #include <linux/err.h>
13 #include <linux/regulator/driver.h> 13 #include <linux/regulator/driver.h>
14 #include <linux/debugfs.h> 14 #include <linux/debugfs.h>
15 #include <linux/seq_file.h> 15 #include <linux/seq_file.h>
16 #include <linux/slab.h> 16 #include <linux/slab.h>
17 #include <linux/module.h> 17 #include <linux/module.h>
18 18
19 #include "dbx500-prcmu.h" 19 #include "dbx500-prcmu.h"
20 20
21 /* 21 /*
22 * power state reference count 22 * power state reference count
23 */ 23 */
24 static int power_state_active_cnt; /* will initialize to zero */ 24 static int power_state_active_cnt; /* will initialize to zero */
25 static DEFINE_SPINLOCK(power_state_active_lock); 25 static DEFINE_SPINLOCK(power_state_active_lock);
26 26
27 int power_state_active_get(void)
28 {
29 unsigned long flags;
30 int cnt;
31
32 spin_lock_irqsave(&power_state_active_lock, flags);
33 cnt = power_state_active_cnt;
34 spin_unlock_irqrestore(&power_state_active_lock, flags);
35
36 return cnt;
37 }
38
39 void power_state_active_enable(void) 27 void power_state_active_enable(void)
40 { 28 {
41 unsigned long flags; 29 unsigned long flags;
42 30
43 spin_lock_irqsave(&power_state_active_lock, flags); 31 spin_lock_irqsave(&power_state_active_lock, flags);
44 power_state_active_cnt++; 32 power_state_active_cnt++;
45 spin_unlock_irqrestore(&power_state_active_lock, flags); 33 spin_unlock_irqrestore(&power_state_active_lock, flags);
46 } 34 }
47 35
48 int power_state_active_disable(void) 36 int power_state_active_disable(void)
49 { 37 {
50 int ret = 0; 38 int ret = 0;
51 unsigned long flags; 39 unsigned long flags;
52 40
53 spin_lock_irqsave(&power_state_active_lock, flags); 41 spin_lock_irqsave(&power_state_active_lock, flags);
54 if (power_state_active_cnt <= 0) { 42 if (power_state_active_cnt <= 0) {
55 pr_err("power state: unbalanced enable/disable calls\n"); 43 pr_err("power state: unbalanced enable/disable calls\n");
56 ret = -EINVAL; 44 ret = -EINVAL;
57 goto out; 45 goto out;
58 } 46 }
59 47
60 power_state_active_cnt--; 48 power_state_active_cnt--;
61 out: 49 out:
62 spin_unlock_irqrestore(&power_state_active_lock, flags); 50 spin_unlock_irqrestore(&power_state_active_lock, flags);
63 return ret; 51 return ret;
64 } 52 }
65 53
66 #ifdef CONFIG_REGULATOR_DEBUG 54 #ifdef CONFIG_REGULATOR_DEBUG
55
56 static int power_state_active_get(void)
57 {
58 unsigned long flags;
59 int cnt;
60
61 spin_lock_irqsave(&power_state_active_lock, flags);
62 cnt = power_state_active_cnt;
63 spin_unlock_irqrestore(&power_state_active_lock, flags);
64
65 return cnt;
66 }
67 67
68 static struct ux500_regulator_debug { 68 static struct ux500_regulator_debug {
69 struct dentry *dir; 69 struct dentry *dir;
70 struct dentry *status_file; 70 struct dentry *status_file;
71 struct dentry *power_state_cnt_file; 71 struct dentry *power_state_cnt_file;
72 struct dbx500_regulator_info *regulator_array; 72 struct dbx500_regulator_info *regulator_array;
73 int num_regulators; 73 int num_regulators;
74 u8 *state_before_suspend; 74 u8 *state_before_suspend;
75 u8 *state_after_suspend; 75 u8 *state_after_suspend;
76 } rdebug; 76 } rdebug;
77 77
78 void ux500_regulator_suspend_debug(void) 78 void ux500_regulator_suspend_debug(void)
79 { 79 {
80 int i; 80 int i;
81 for (i = 0; i < rdebug.num_regulators; i++) 81 for (i = 0; i < rdebug.num_regulators; i++)
82 rdebug.state_before_suspend[i] = 82 rdebug.state_before_suspend[i] =
83 rdebug.regulator_array[i].is_enabled; 83 rdebug.regulator_array[i].is_enabled;
84 } 84 }
85 85
86 void ux500_regulator_resume_debug(void) 86 void ux500_regulator_resume_debug(void)
87 { 87 {
88 int i; 88 int i;
89 for (i = 0; i < rdebug.num_regulators; i++) 89 for (i = 0; i < rdebug.num_regulators; i++)
90 rdebug.state_after_suspend[i] = 90 rdebug.state_after_suspend[i] =
91 rdebug.regulator_array[i].is_enabled; 91 rdebug.regulator_array[i].is_enabled;
92 } 92 }
93 93
94 static int ux500_regulator_power_state_cnt_print(struct seq_file *s, void *p) 94 static int ux500_regulator_power_state_cnt_print(struct seq_file *s, void *p)
95 { 95 {
96 struct device *dev = s->private; 96 struct device *dev = s->private;
97 int err; 97 int err;
98 98
99 /* print power state count */ 99 /* print power state count */
100 err = seq_printf(s, "ux500-regulator power state count: %i\n", 100 err = seq_printf(s, "ux500-regulator power state count: %i\n",
101 power_state_active_get()); 101 power_state_active_get());
102 if (err < 0) 102 if (err < 0)
103 dev_err(dev, "seq_printf overflow\n"); 103 dev_err(dev, "seq_printf overflow\n");
104 104
105 return 0; 105 return 0;
106 } 106 }
107 107
108 static int ux500_regulator_power_state_cnt_open(struct inode *inode, 108 static int ux500_regulator_power_state_cnt_open(struct inode *inode,
109 struct file *file) 109 struct file *file)
110 { 110 {
111 return single_open(file, ux500_regulator_power_state_cnt_print, 111 return single_open(file, ux500_regulator_power_state_cnt_print,
112 inode->i_private); 112 inode->i_private);
113 } 113 }
114 114
115 static const struct file_operations ux500_regulator_power_state_cnt_fops = { 115 static const struct file_operations ux500_regulator_power_state_cnt_fops = {
116 .open = ux500_regulator_power_state_cnt_open, 116 .open = ux500_regulator_power_state_cnt_open,
117 .read = seq_read, 117 .read = seq_read,
118 .llseek = seq_lseek, 118 .llseek = seq_lseek,
119 .release = single_release, 119 .release = single_release,
120 .owner = THIS_MODULE, 120 .owner = THIS_MODULE,
121 }; 121 };
122 122
123 static int ux500_regulator_status_print(struct seq_file *s, void *p) 123 static int ux500_regulator_status_print(struct seq_file *s, void *p)
124 { 124 {
125 struct device *dev = s->private; 125 struct device *dev = s->private;
126 int err; 126 int err;
127 int i; 127 int i;
128 128
129 /* print dump header */ 129 /* print dump header */
130 err = seq_printf(s, "ux500-regulator status:\n"); 130 err = seq_printf(s, "ux500-regulator status:\n");
131 if (err < 0) 131 if (err < 0)
132 dev_err(dev, "seq_printf overflow\n"); 132 dev_err(dev, "seq_printf overflow\n");
133 133
134 err = seq_printf(s, "%31s : %8s : %8s\n", "current", 134 err = seq_printf(s, "%31s : %8s : %8s\n", "current",
135 "before", "after"); 135 "before", "after");
136 if (err < 0) 136 if (err < 0)
137 dev_err(dev, "seq_printf overflow\n"); 137 dev_err(dev, "seq_printf overflow\n");
138 138
139 for (i = 0; i < rdebug.num_regulators; i++) { 139 for (i = 0; i < rdebug.num_regulators; i++) {
140 struct dbx500_regulator_info *info; 140 struct dbx500_regulator_info *info;
141 /* Access per-regulator data */ 141 /* Access per-regulator data */
142 info = &rdebug.regulator_array[i]; 142 info = &rdebug.regulator_array[i];
143 143
144 /* print status */ 144 /* print status */
145 err = seq_printf(s, "%20s : %8s : %8s : %8s\n", info->desc.name, 145 err = seq_printf(s, "%20s : %8s : %8s : %8s\n", info->desc.name,
146 info->is_enabled ? "enabled" : "disabled", 146 info->is_enabled ? "enabled" : "disabled",
147 rdebug.state_before_suspend[i] ? "enabled" : "disabled", 147 rdebug.state_before_suspend[i] ? "enabled" : "disabled",
148 rdebug.state_after_suspend[i] ? "enabled" : "disabled"); 148 rdebug.state_after_suspend[i] ? "enabled" : "disabled");
149 if (err < 0) 149 if (err < 0)
150 dev_err(dev, "seq_printf overflow\n"); 150 dev_err(dev, "seq_printf overflow\n");
151 } 151 }
152 152
153 return 0; 153 return 0;
154 } 154 }
155 155
156 static int ux500_regulator_status_open(struct inode *inode, struct file *file) 156 static int ux500_regulator_status_open(struct inode *inode, struct file *file)
157 { 157 {
158 return single_open(file, ux500_regulator_status_print, 158 return single_open(file, ux500_regulator_status_print,
159 inode->i_private); 159 inode->i_private);
160 } 160 }
161 161
162 static const struct file_operations ux500_regulator_status_fops = { 162 static const struct file_operations ux500_regulator_status_fops = {
163 .open = ux500_regulator_status_open, 163 .open = ux500_regulator_status_open,
164 .read = seq_read, 164 .read = seq_read,
165 .llseek = seq_lseek, 165 .llseek = seq_lseek,
166 .release = single_release, 166 .release = single_release,
167 .owner = THIS_MODULE, 167 .owner = THIS_MODULE,
168 }; 168 };
169 169
170 int __attribute__((weak)) dbx500_regulator_testcase( 170 int __attribute__((weak)) dbx500_regulator_testcase(
171 struct dbx500_regulator_info *regulator_info, 171 struct dbx500_regulator_info *regulator_info,
172 int num_regulators) 172 int num_regulators)
173 { 173 {
174 return 0; 174 return 0;
175 } 175 }
176 176
177 int 177 int
178 ux500_regulator_debug_init(struct platform_device *pdev, 178 ux500_regulator_debug_init(struct platform_device *pdev,
179 struct dbx500_regulator_info *regulator_info, 179 struct dbx500_regulator_info *regulator_info,
180 int num_regulators) 180 int num_regulators)
181 { 181 {
182 /* create directory */ 182 /* create directory */
183 rdebug.dir = debugfs_create_dir("ux500-regulator", NULL); 183 rdebug.dir = debugfs_create_dir("ux500-regulator", NULL);
184 if (!rdebug.dir) 184 if (!rdebug.dir)
185 goto exit_no_debugfs; 185 goto exit_no_debugfs;
186 186
187 /* create "status" file */ 187 /* create "status" file */
188 rdebug.status_file = debugfs_create_file("status", 188 rdebug.status_file = debugfs_create_file("status",
189 S_IRUGO, rdebug.dir, &pdev->dev, 189 S_IRUGO, rdebug.dir, &pdev->dev,
190 &ux500_regulator_status_fops); 190 &ux500_regulator_status_fops);
191 if (!rdebug.status_file) 191 if (!rdebug.status_file)
192 goto exit_destroy_dir; 192 goto exit_destroy_dir;
193 193
194 /* create "power-state-count" file */ 194 /* create "power-state-count" file */
195 rdebug.power_state_cnt_file = debugfs_create_file("power-state-count", 195 rdebug.power_state_cnt_file = debugfs_create_file("power-state-count",
196 S_IRUGO, rdebug.dir, &pdev->dev, 196 S_IRUGO, rdebug.dir, &pdev->dev,
197 &ux500_regulator_power_state_cnt_fops); 197 &ux500_regulator_power_state_cnt_fops);
198 if (!rdebug.power_state_cnt_file) 198 if (!rdebug.power_state_cnt_file)
199 goto exit_destroy_status; 199 goto exit_destroy_status;
200 200
201 rdebug.regulator_array = regulator_info; 201 rdebug.regulator_array = regulator_info;
202 rdebug.num_regulators = num_regulators; 202 rdebug.num_regulators = num_regulators;
203 203
204 rdebug.state_before_suspend = kzalloc(num_regulators, GFP_KERNEL); 204 rdebug.state_before_suspend = kzalloc(num_regulators, GFP_KERNEL);
205 if (!rdebug.state_before_suspend) { 205 if (!rdebug.state_before_suspend) {
206 dev_err(&pdev->dev, 206 dev_err(&pdev->dev,
207 "could not allocate memory for saving state\n"); 207 "could not allocate memory for saving state\n");
208 goto exit_destroy_power_state; 208 goto exit_destroy_power_state;
209 } 209 }
210 210
211 rdebug.state_after_suspend = kzalloc(num_regulators, GFP_KERNEL); 211 rdebug.state_after_suspend = kzalloc(num_regulators, GFP_KERNEL);
212 if (!rdebug.state_after_suspend) { 212 if (!rdebug.state_after_suspend) {
213 dev_err(&pdev->dev, 213 dev_err(&pdev->dev,
214 "could not allocate memory for saving state\n"); 214 "could not allocate memory for saving state\n");
215 goto exit_free; 215 goto exit_free;
216 } 216 }
217 217
218 dbx500_regulator_testcase(regulator_info, num_regulators); 218 dbx500_regulator_testcase(regulator_info, num_regulators);
219 return 0; 219 return 0;
220 220
221 exit_free: 221 exit_free:
222 kfree(rdebug.state_before_suspend); 222 kfree(rdebug.state_before_suspend);
223 exit_destroy_power_state: 223 exit_destroy_power_state:
224 debugfs_remove(rdebug.power_state_cnt_file); 224 debugfs_remove(rdebug.power_state_cnt_file);
225 exit_destroy_status: 225 exit_destroy_status:
226 debugfs_remove(rdebug.status_file); 226 debugfs_remove(rdebug.status_file);
227 exit_destroy_dir: 227 exit_destroy_dir:
228 debugfs_remove(rdebug.dir); 228 debugfs_remove(rdebug.dir);
229 exit_no_debugfs: 229 exit_no_debugfs:
230 dev_err(&pdev->dev, "failed to create debugfs entries.\n"); 230 dev_err(&pdev->dev, "failed to create debugfs entries.\n");
231 return -ENOMEM; 231 return -ENOMEM;