hc
2023-12-11 d2ccde1c8e90d38cee87a1b0309ad2827f3fd30d
kernel/drivers/regulator/dbx500-prcmu.c
....@@ -1,7 +1,7 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * Copyright (C) ST-Ericsson SA 2010
34 *
4
- * License Terms: GNU General Public License v2
55 * Authors: Sundar Iyer <sundar.iyer@stericsson.com> for ST-Ericsson
66 * Bengt Jonsson <bengt.g.jonsson@stericsson.com> for ST-Ericsson
77 *
....@@ -67,15 +67,13 @@
6767
6868 static struct ux500_regulator_debug {
6969 struct dentry *dir;
70
- struct dentry *status_file;
71
- struct dentry *power_state_cnt_file;
7270 struct dbx500_regulator_info *regulator_array;
7371 int num_regulators;
7472 u8 *state_before_suspend;
7573 u8 *state_after_suspend;
7674 } rdebug;
7775
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)
7977 {
8078 /* print power state count */
8179 seq_printf(s, "ux500-regulator power state count: %i\n",
....@@ -83,23 +81,9 @@
8381
8482 return 0;
8583 }
84
+DEFINE_SHOW_ATTRIBUTE(ux500_regulator_power_state_cnt);
8685
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)
10387 {
10488 int i;
10589
....@@ -122,27 +106,7 @@
122106
123107 return 0;
124108 }
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);
146110
147111 int
148112 ux500_regulator_debug_init(struct platform_device *pdev,
....@@ -151,22 +115,14 @@
151115 {
152116 /* create directory */
153117 rdebug.dir = debugfs_create_dir("ux500-regulator", NULL);
154
- if (!rdebug.dir)
155
- goto exit_no_debugfs;
156118
157119 /* 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);
163122
164123 /* 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);
170126
171127 rdebug.regulator_array = regulator_info;
172128 rdebug.num_regulators = num_regulators;
....@@ -179,19 +135,12 @@
179135 if (!rdebug.state_after_suspend)
180136 goto exit_free;
181137
182
- dbx500_regulator_testcase(regulator_info, num_regulators);
183138 return 0;
184139
185140 exit_free:
186141 kfree(rdebug.state_before_suspend);
187142 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);
195144 return -ENOMEM;
196145 }
197146