.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
---|
1 | 2 | /* |
---|
2 | 3 | * Copyright (C) ST-Ericsson SA 2010 |
---|
3 | 4 | * |
---|
4 | | - * License Terms: GNU General Public License v2 |
---|
5 | 5 | * Authors: Sundar Iyer <sundar.iyer@stericsson.com> for ST-Ericsson |
---|
6 | 6 | * Bengt Jonsson <bengt.g.jonsson@stericsson.com> for ST-Ericsson |
---|
7 | 7 | * |
---|
.. | .. |
---|
67 | 67 | |
---|
68 | 68 | static struct ux500_regulator_debug { |
---|
69 | 69 | struct dentry *dir; |
---|
70 | | - struct dentry *status_file; |
---|
71 | | - struct dentry *power_state_cnt_file; |
---|
72 | 70 | struct dbx500_regulator_info *regulator_array; |
---|
73 | 71 | int num_regulators; |
---|
74 | 72 | u8 *state_before_suspend; |
---|
75 | 73 | u8 *state_after_suspend; |
---|
76 | 74 | } rdebug; |
---|
77 | 75 | |
---|
78 | | -static int ux500_regulator_power_state_cnt_print(struct seq_file *s, void *p) |
---|
| 76 | +static int ux500_regulator_power_state_cnt_show(struct seq_file *s, void *p) |
---|
79 | 77 | { |
---|
80 | 78 | /* print power state count */ |
---|
81 | 79 | seq_printf(s, "ux500-regulator power state count: %i\n", |
---|
.. | .. |
---|
83 | 81 | |
---|
84 | 82 | return 0; |
---|
85 | 83 | } |
---|
| 84 | +DEFINE_SHOW_ATTRIBUTE(ux500_regulator_power_state_cnt); |
---|
86 | 85 | |
---|
87 | | -static int ux500_regulator_power_state_cnt_open(struct inode *inode, |
---|
88 | | - struct file *file) |
---|
89 | | -{ |
---|
90 | | - return single_open(file, ux500_regulator_power_state_cnt_print, |
---|
91 | | - inode->i_private); |
---|
92 | | -} |
---|
93 | | - |
---|
94 | | -static const struct file_operations ux500_regulator_power_state_cnt_fops = { |
---|
95 | | - .open = ux500_regulator_power_state_cnt_open, |
---|
96 | | - .read = seq_read, |
---|
97 | | - .llseek = seq_lseek, |
---|
98 | | - .release = single_release, |
---|
99 | | - .owner = THIS_MODULE, |
---|
100 | | -}; |
---|
101 | | - |
---|
102 | | -static int ux500_regulator_status_print(struct seq_file *s, void *p) |
---|
| 86 | +static int ux500_regulator_status_show(struct seq_file *s, void *p) |
---|
103 | 87 | { |
---|
104 | 88 | int i; |
---|
105 | 89 | |
---|
.. | .. |
---|
122 | 106 | |
---|
123 | 107 | return 0; |
---|
124 | 108 | } |
---|
125 | | - |
---|
126 | | -static int ux500_regulator_status_open(struct inode *inode, struct file *file) |
---|
127 | | -{ |
---|
128 | | - return single_open(file, ux500_regulator_status_print, |
---|
129 | | - inode->i_private); |
---|
130 | | -} |
---|
131 | | - |
---|
132 | | -static const struct file_operations ux500_regulator_status_fops = { |
---|
133 | | - .open = ux500_regulator_status_open, |
---|
134 | | - .read = seq_read, |
---|
135 | | - .llseek = seq_lseek, |
---|
136 | | - .release = single_release, |
---|
137 | | - .owner = THIS_MODULE, |
---|
138 | | -}; |
---|
139 | | - |
---|
140 | | -int __attribute__((weak)) dbx500_regulator_testcase( |
---|
141 | | - struct dbx500_regulator_info *regulator_info, |
---|
142 | | - int num_regulators) |
---|
143 | | -{ |
---|
144 | | - return 0; |
---|
145 | | -} |
---|
| 109 | +DEFINE_SHOW_ATTRIBUTE(ux500_regulator_status); |
---|
146 | 110 | |
---|
147 | 111 | int |
---|
148 | 112 | ux500_regulator_debug_init(struct platform_device *pdev, |
---|
.. | .. |
---|
151 | 115 | { |
---|
152 | 116 | /* create directory */ |
---|
153 | 117 | rdebug.dir = debugfs_create_dir("ux500-regulator", NULL); |
---|
154 | | - if (!rdebug.dir) |
---|
155 | | - goto exit_no_debugfs; |
---|
156 | 118 | |
---|
157 | 119 | /* create "status" file */ |
---|
158 | | - rdebug.status_file = debugfs_create_file("status", |
---|
159 | | - S_IRUGO, rdebug.dir, &pdev->dev, |
---|
160 | | - &ux500_regulator_status_fops); |
---|
161 | | - if (!rdebug.status_file) |
---|
162 | | - goto exit_destroy_dir; |
---|
| 120 | + debugfs_create_file("status", S_IRUGO, rdebug.dir, &pdev->dev, |
---|
| 121 | + &ux500_regulator_status_fops); |
---|
163 | 122 | |
---|
164 | 123 | /* create "power-state-count" file */ |
---|
165 | | - rdebug.power_state_cnt_file = debugfs_create_file("power-state-count", |
---|
166 | | - S_IRUGO, rdebug.dir, &pdev->dev, |
---|
167 | | - &ux500_regulator_power_state_cnt_fops); |
---|
168 | | - if (!rdebug.power_state_cnt_file) |
---|
169 | | - goto exit_destroy_status; |
---|
| 124 | + debugfs_create_file("power-state-count", S_IRUGO, rdebug.dir, |
---|
| 125 | + &pdev->dev, &ux500_regulator_power_state_cnt_fops); |
---|
170 | 126 | |
---|
171 | 127 | rdebug.regulator_array = regulator_info; |
---|
172 | 128 | rdebug.num_regulators = num_regulators; |
---|
.. | .. |
---|
179 | 135 | if (!rdebug.state_after_suspend) |
---|
180 | 136 | goto exit_free; |
---|
181 | 137 | |
---|
182 | | - dbx500_regulator_testcase(regulator_info, num_regulators); |
---|
183 | 138 | return 0; |
---|
184 | 139 | |
---|
185 | 140 | exit_free: |
---|
186 | 141 | kfree(rdebug.state_before_suspend); |
---|
187 | 142 | exit_destroy_power_state: |
---|
188 | | - debugfs_remove(rdebug.power_state_cnt_file); |
---|
189 | | -exit_destroy_status: |
---|
190 | | - debugfs_remove(rdebug.status_file); |
---|
191 | | -exit_destroy_dir: |
---|
192 | | - debugfs_remove(rdebug.dir); |
---|
193 | | -exit_no_debugfs: |
---|
194 | | - dev_err(&pdev->dev, "failed to create debugfs entries.\n"); |
---|
| 143 | + debugfs_remove_recursive(rdebug.dir); |
---|
195 | 144 | return -ENOMEM; |
---|
196 | 145 | } |
---|
197 | 146 | |
---|