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
7 commit 0723103f8ba15a019bbcaf6f130d73d05337332f upstream
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.
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
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>
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(-)
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;
38 - (void)vchiq_debugfs_add_instance(instance);
39 + vchiq_debugfs_add_instance(instance);
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;
46 /* create debugfs entries */
47 - err = vchiq_debugfs_init();
49 - goto failed_debugfs_init;
50 + vchiq_debugfs_init();
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
59 - device_destroy(vchiq_class, vchiq_devid);
61 class_destroy(vchiq_class);
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
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)
76 dir = debugfs_create_dir("log", vchiq_debugfs_top());
79 debugfs_info.log_categories = dir;
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,
91 vchiq_debugfs_log_entries[i].dir = dir;
96 static int debugfs_usecount_show(struct seq_file *f, void *offset)
97 @@ -270,43 +261,22 @@ static const struct file_operations debu
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)
105 - struct dentry *top, *use_count, *trace;
106 + struct dentry *top;
107 struct dentry *clients = vchiq_clients_top();
109 snprintf(pidstr, sizeof(pidstr), "%d",
110 vchiq_instance_get_pid(instance));
112 top = debugfs_create_dir(pidstr, clients);
116 - use_count = debugfs_create_file("use_count",
119 - &debugfs_usecount_fops);
121 - goto fail_use_count;
123 - trace = debugfs_create_file("trace",
126 - &debugfs_trace_fops);
129 + debugfs_create_file("use_count", 0444, top, instance,
130 + &debugfs_usecount_fops);
131 + debugfs_create_file("trace", 0644, top, instance, &debugfs_trace_fops);
133 vchiq_instance_get_debugfs_node(instance)->dentry = top;
138 - debugfs_remove(use_count);
140 - debugfs_remove(top);
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);
151 -int vchiq_debugfs_init(void)
152 +void vchiq_debugfs_init(void)
154 - BUG_ON(debugfs_info.vchiq_cfg_dir != NULL);
156 debugfs_info.vchiq_cfg_dir = debugfs_create_dir("vchiq", NULL);
157 - if (debugfs_info.vchiq_cfg_dir == NULL)
160 debugfs_info.clients = debugfs_create_dir("clients",
161 vchiq_debugfs_top());
162 - if (!debugfs_info.clients)
165 - if (vchiq_debugfs_create_log_entries(vchiq_debugfs_top()) != 0)
171 - vchiq_debugfs_deinit();
172 - vchiq_log_error(vchiq_arm_log_level,
173 - "%s: failed to create debugfs directory",
177 + vchiq_debugfs_create_log_entries(vchiq_debugfs_top());
180 /* remove all the debugfs entries */
181 @@ -363,18 +314,16 @@ static struct dentry *vchiq_debugfs_top(
183 #else /* CONFIG_DEBUG_FS */
185 -int vchiq_debugfs_init(void)
186 +void vchiq_debugfs_init(void)
191 void vchiq_debugfs_deinit(void)
195 -int vchiq_debugfs_add_instance(VCHIQ_INSTANCE_T instance)
196 +void vchiq_debugfs_add_instance(VCHIQ_INSTANCE_T instance)
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;
208 -int vchiq_debugfs_init(void);
209 +void vchiq_debugfs_init(void);
211 void vchiq_debugfs_deinit(void);
213 -int vchiq_debugfs_add_instance(VCHIQ_INSTANCE_T instance);
214 +void vchiq_debugfs_add_instance(VCHIQ_INSTANCE_T instance);
216 void vchiq_debugfs_remove_instance(VCHIQ_INSTANCE_T instance);