brcm2708: add kernel 4.14 support
[openwrt/staging/chunkeey.git] / target / linux / brcm2708 / patches-4.14 / 950-0381-staging-vc04_services-no-need-to-check-debugfs-retur.patch
1 From 5e4d56448e08a7f4bf39e1b3f4c43916ff74d337 Mon Sep 17 00:00:00 2001
2 From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
3 Date: Fri, 1 Jun 2018 13:09:59 +0200
4 Subject: [PATCH 381/454] staging: vc04_services: no need to check debugfs
5 return values
6
7 commit 0723103f8ba15a019bbcaf6f130d73d05337332f upstream
8
9 When calling debugfs functions, there is no need to ever check the
10 return value. The function can work or not, but the code logic should
11 never do something different based on this.
12
13 Clean up the vchiq_arm code by not caring about the value of debugfs
14 calls. This ends up removing a number of lines of code that are not
15 needed.
16
17 Cc: Stefan Wahren <stefan.wahren@i2se.com>
18 Cc: Kees Cook <keescook@chromium.org>
19 Cc: Dan Carpenter <dan.carpenter@oracle.com>
20 Cc: Arnd Bergmann <arnd@arndb.de>
21 Cc: Keerthi Reddy <keerthigd4990@gmail.com>
22 Cc: linux-rpi-kernel@lists.infradead.org
23 Cc: linux-arm-kernel@lists.infradead.org
24 Reviewed-by: Eric Anholt <eric@anholt.net>
25 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
26 ---
27 .../interface/vchiq_arm/vchiq_arm.c | 8 +-
28 .../interface/vchiq_arm/vchiq_debugfs.c | 73 +++----------------
29 .../interface/vchiq_arm/vchiq_debugfs.h | 4 +-
30 3 files changed, 15 insertions(+), 70 deletions(-)
31
32 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c
33 +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c
34 @@ -1753,7 +1753,7 @@ vchiq_open(struct inode *inode, struct f
35 instance->state = state;
36 instance->pid = current->tgid;
37
38 - (void)vchiq_debugfs_add_instance(instance);
39 + vchiq_debugfs_add_instance(instance);
40
41 sema_init(&instance->insert_event, 0);
42 sema_init(&instance->remove_event, 0);
43 @@ -3437,9 +3437,7 @@ static int vchiq_probe(struct platform_d
44 goto failed_device_create;
45
46 /* create debugfs entries */
47 - err = vchiq_debugfs_init();
48 - if (err != 0)
49 - goto failed_debugfs_init;
50 + vchiq_debugfs_init();
51
52 vchiq_log_info(vchiq_arm_log_level,
53 "vchiq: initialised - version %d (min %d), device %d.%d",
54 @@ -3448,8 +3446,6 @@ static int vchiq_probe(struct platform_d
55
56 return 0;
57
58 -failed_debugfs_init:
59 - device_destroy(vchiq_class, vchiq_devid);
60 failed_device_create:
61 class_destroy(vchiq_class);
62 failed_class_create:
63 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_debugfs.c
64 +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_debugfs.c
65 @@ -160,15 +160,12 @@ static const struct file_operations debu
66 };
67
68 /* create an entry under <debugfs>/vchiq/log for each log category */
69 -static int vchiq_debugfs_create_log_entries(struct dentry *top)
70 +static void vchiq_debugfs_create_log_entries(struct dentry *top)
71 {
72 struct dentry *dir;
73 size_t i;
74 - int ret = 0;
75
76 dir = debugfs_create_dir("log", vchiq_debugfs_top());
77 - if (!dir)
78 - return -ENOMEM;
79 debugfs_info.log_categories = dir;
80
81 for (i = 0; i < n_log_entries; i++) {
82 @@ -179,14 +176,8 @@ static int vchiq_debugfs_create_log_entr
83 debugfs_info.log_categories,
84 levp,
85 &debugfs_log_fops);
86 - if (!dir) {
87 - ret = -ENOMEM;
88 - break;
89 - }
90 -
91 vchiq_debugfs_log_entries[i].dir = dir;
92 }
93 - return ret;
94 }
95
96 static int debugfs_usecount_show(struct seq_file *f, void *offset)
97 @@ -270,43 +261,22 @@ static const struct file_operations debu
98 };
99
100 /* add an instance (process) to the debugfs entries */
101 -int vchiq_debugfs_add_instance(VCHIQ_INSTANCE_T instance)
102 +void vchiq_debugfs_add_instance(VCHIQ_INSTANCE_T instance)
103 {
104 char pidstr[16];
105 - struct dentry *top, *use_count, *trace;
106 + struct dentry *top;
107 struct dentry *clients = vchiq_clients_top();
108
109 snprintf(pidstr, sizeof(pidstr), "%d",
110 vchiq_instance_get_pid(instance));
111
112 top = debugfs_create_dir(pidstr, clients);
113 - if (!top)
114 - goto fail_top;
115
116 - use_count = debugfs_create_file("use_count",
117 - 0444, top,
118 - instance,
119 - &debugfs_usecount_fops);
120 - if (!use_count)
121 - goto fail_use_count;
122 -
123 - trace = debugfs_create_file("trace",
124 - 0644, top,
125 - instance,
126 - &debugfs_trace_fops);
127 - if (!trace)
128 - goto fail_trace;
129 + debugfs_create_file("use_count", 0444, top, instance,
130 + &debugfs_usecount_fops);
131 + debugfs_create_file("trace", 0644, top, instance, &debugfs_trace_fops);
132
133 vchiq_instance_get_debugfs_node(instance)->dentry = top;
134 -
135 - return 0;
136 -
137 -fail_trace:
138 - debugfs_remove(use_count);
139 -fail_use_count:
140 - debugfs_remove(top);
141 -fail_top:
142 - return -ENOMEM;
143 }
144
145 void vchiq_debugfs_remove_instance(VCHIQ_INSTANCE_T instance)
146 @@ -316,32 +286,13 @@ void vchiq_debugfs_remove_instance(VCHIQ
147 debugfs_remove_recursive(node->dentry);
148 }
149
150 -
151 -int vchiq_debugfs_init(void)
152 +void vchiq_debugfs_init(void)
153 {
154 - BUG_ON(debugfs_info.vchiq_cfg_dir != NULL);
155 -
156 debugfs_info.vchiq_cfg_dir = debugfs_create_dir("vchiq", NULL);
157 - if (debugfs_info.vchiq_cfg_dir == NULL)
158 - goto fail;
159 -
160 debugfs_info.clients = debugfs_create_dir("clients",
161 vchiq_debugfs_top());
162 - if (!debugfs_info.clients)
163 - goto fail;
164
165 - if (vchiq_debugfs_create_log_entries(vchiq_debugfs_top()) != 0)
166 - goto fail;
167 -
168 - return 0;
169 -
170 -fail:
171 - vchiq_debugfs_deinit();
172 - vchiq_log_error(vchiq_arm_log_level,
173 - "%s: failed to create debugfs directory",
174 - __func__);
175 -
176 - return -ENOMEM;
177 + vchiq_debugfs_create_log_entries(vchiq_debugfs_top());
178 }
179
180 /* remove all the debugfs entries */
181 @@ -363,18 +314,16 @@ static struct dentry *vchiq_debugfs_top(
182
183 #else /* CONFIG_DEBUG_FS */
184
185 -int vchiq_debugfs_init(void)
186 +void vchiq_debugfs_init(void)
187 {
188 - return 0;
189 }
190
191 void vchiq_debugfs_deinit(void)
192 {
193 }
194
195 -int vchiq_debugfs_add_instance(VCHIQ_INSTANCE_T instance)
196 +void vchiq_debugfs_add_instance(VCHIQ_INSTANCE_T instance)
197 {
198 - return 0;
199 }
200
201 void vchiq_debugfs_remove_instance(VCHIQ_INSTANCE_T instance)
202 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_debugfs.h
203 +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_debugfs.h
204 @@ -40,11 +40,11 @@ typedef struct vchiq_debugfs_node_struct
205 struct dentry *dentry;
206 } VCHIQ_DEBUGFS_NODE_T;
207
208 -int vchiq_debugfs_init(void);
209 +void vchiq_debugfs_init(void);
210
211 void vchiq_debugfs_deinit(void);
212
213 -int vchiq_debugfs_add_instance(VCHIQ_INSTANCE_T instance);
214 +void vchiq_debugfs_add_instance(VCHIQ_INSTANCE_T instance);
215
216 void vchiq_debugfs_remove_instance(VCHIQ_INSTANCE_T instance);
217