Skip to content

Commit db50450

Browse files
gregkhholtmann
authored andcommitted
6lowpan: no need to check return value of debugfs_create functions
When calling debugfs functions, there is no need to ever check the return value. The function can work or not, but the code logic should never do something different based on this. Because we don't care if debugfs works or not, this trickles back a bit so we can clean things up by making some functions return void instead of an error value that is never going to fail. Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Acked-by: Jukka Rissanen <jukka.rissanen@linux.intel.com> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
1 parent 2faa3f1 commit db50450

3 files changed

Lines changed: 32 additions & 89 deletions

File tree

‎net/6lowpan/6lowpan_i.h‎

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,24 +18,16 @@ extern const struct ndisc_ops lowpan_ndisc_ops;
1818
int addrconf_ifid_802154_6lowpan(u8 *eui, struct net_device *dev);
1919

2020
#ifdef CONFIG_6LOWPAN_DEBUGFS
21-
int lowpan_dev_debugfs_init(struct net_device *dev);
21+
void lowpan_dev_debugfs_init(struct net_device *dev);
2222
void lowpan_dev_debugfs_exit(struct net_device *dev);
2323

24-
int __init lowpan_debugfs_init(void);
24+
void __init lowpan_debugfs_init(void);
2525
void lowpan_debugfs_exit(void);
2626
#else
27-
static inline int lowpan_dev_debugfs_init(struct net_device *dev)
28-
{
29-
return 0;
30-
}
31-
27+
static inline void lowpan_dev_debugfs_init(struct net_device *dev) { }
3228
static inline void lowpan_dev_debugfs_exit(struct net_device *dev) { }
3329

34-
static inline int __init lowpan_debugfs_init(void)
35-
{
36-
return 0;
37-
}
38-
30+
static inline void __init lowpan_debugfs_init(void) { }
3931
static inline void lowpan_debugfs_exit(void) { }
4032
#endif /* CONFIG_6LOWPAN_DEBUGFS */
4133

‎net/6lowpan/core.c‎

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,7 @@ int lowpan_register_netdevice(struct net_device *dev,
4242
if (ret < 0)
4343
return ret;
4444

45-
ret = lowpan_dev_debugfs_init(dev);
46-
if (ret < 0)
47-
unregister_netdevice(dev);
45+
lowpan_dev_debugfs_init(dev);
4846

4947
return ret;
5048
}
@@ -152,9 +150,7 @@ static int __init lowpan_module_init(void)
152150
{
153151
int ret;
154152

155-
ret = lowpan_debugfs_init();
156-
if (ret < 0)
157-
return ret;
153+
lowpan_debugfs_init();
158154

159155
ret = register_netdevice_notifier(&lowpan_notifier);
160156
if (ret < 0) {

‎net/6lowpan/debugfs.c‎

Lines changed: 26 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -163,46 +163,30 @@ static const struct file_operations lowpan_ctx_pfx_fops = {
163163
.release = single_release,
164164
};
165165

166-
static int lowpan_dev_debugfs_ctx_init(struct net_device *dev,
167-
struct dentry *ctx, u8 id)
166+
static void lowpan_dev_debugfs_ctx_init(struct net_device *dev,
167+
struct dentry *ctx, u8 id)
168168
{
169169
struct lowpan_dev *ldev = lowpan_dev(dev);
170-
struct dentry *dentry, *root;
170+
struct dentry *root;
171171
char buf[32];
172172

173173
WARN_ON_ONCE(id > LOWPAN_IPHC_CTX_TABLE_SIZE);
174174

175175
sprintf(buf, "%d", id);
176176

177177
root = debugfs_create_dir(buf, ctx);
178-
if (!root)
179-
return -EINVAL;
180178

181-
dentry = debugfs_create_file_unsafe("active", 0644, root,
182-
&ldev->ctx.table[id],
183-
&lowpan_ctx_flag_active_fops);
184-
if (!dentry)
185-
return -EINVAL;
179+
debugfs_create_file("active", 0644, root, &ldev->ctx.table[id],
180+
&lowpan_ctx_flag_active_fops);
186181

187-
dentry = debugfs_create_file_unsafe("compression", 0644, root,
188-
&ldev->ctx.table[id],
189-
&lowpan_ctx_flag_c_fops);
190-
if (!dentry)
191-
return -EINVAL;
192-
193-
dentry = debugfs_create_file("prefix", 0644, root,
194-
&ldev->ctx.table[id],
195-
&lowpan_ctx_pfx_fops);
196-
if (!dentry)
197-
return -EINVAL;
182+
debugfs_create_file("compression", 0644, root, &ldev->ctx.table[id],
183+
&lowpan_ctx_flag_c_fops);
198184

199-
dentry = debugfs_create_file_unsafe("prefix_len", 0644, root,
200-
&ldev->ctx.table[id],
201-
&lowpan_ctx_plen_fops);
202-
if (!dentry)
203-
return -EINVAL;
185+
debugfs_create_file("prefix", 0644, root, &ldev->ctx.table[id],
186+
&lowpan_ctx_pfx_fops);
204187

205-
return 0;
188+
debugfs_create_file("prefix_len", 0644, root, &ldev->ctx.table[id],
189+
&lowpan_ctx_plen_fops);
206190
}
207191

208192
static int lowpan_context_show(struct seq_file *file, void *offset)
@@ -242,78 +226,49 @@ static int lowpan_short_addr_get(void *data, u64 *val)
242226
DEFINE_DEBUGFS_ATTRIBUTE(lowpan_short_addr_fops, lowpan_short_addr_get, NULL,
243227
"0x%04llx\n");
244228

245-
static int lowpan_dev_debugfs_802154_init(const struct net_device *dev,
229+
static void lowpan_dev_debugfs_802154_init(const struct net_device *dev,
246230
struct lowpan_dev *ldev)
247231
{
248-
struct dentry *dentry, *root;
232+
struct dentry *root;
249233

250234
if (!lowpan_is_ll(dev, LOWPAN_LLTYPE_IEEE802154))
251-
return 0;
235+
return;
252236

253237
root = debugfs_create_dir("ieee802154", ldev->iface_debugfs);
254-
if (!root)
255-
return -EINVAL;
256-
257-
dentry = debugfs_create_file_unsafe("short_addr", 0444, root,
258-
lowpan_802154_dev(dev)->wdev->ieee802154_ptr,
259-
&lowpan_short_addr_fops);
260-
if (!dentry)
261-
return -EINVAL;
262238

263-
return 0;
239+
debugfs_create_file("short_addr", 0444, root,
240+
lowpan_802154_dev(dev)->wdev->ieee802154_ptr,
241+
&lowpan_short_addr_fops);
264242
}
265243

266-
int lowpan_dev_debugfs_init(struct net_device *dev)
244+
void lowpan_dev_debugfs_init(struct net_device *dev)
267245
{
268246
struct lowpan_dev *ldev = lowpan_dev(dev);
269-
struct dentry *contexts, *dentry;
270-
int ret, i;
247+
struct dentry *contexts;
248+
int i;
271249

272250
/* creating the root */
273251
ldev->iface_debugfs = debugfs_create_dir(dev->name, lowpan_debugfs);
274-
if (!ldev->iface_debugfs)
275-
goto fail;
276252

277253
contexts = debugfs_create_dir("contexts", ldev->iface_debugfs);
278-
if (!contexts)
279-
goto remove_root;
280-
281-
dentry = debugfs_create_file("show", 0644, contexts,
282-
&lowpan_dev(dev)->ctx,
283-
&lowpan_context_fops);
284-
if (!dentry)
285-
goto remove_root;
286-
287-
for (i = 0; i < LOWPAN_IPHC_CTX_TABLE_SIZE; i++) {
288-
ret = lowpan_dev_debugfs_ctx_init(dev, contexts, i);
289-
if (ret < 0)
290-
goto remove_root;
291-
}
292254

293-
ret = lowpan_dev_debugfs_802154_init(dev, ldev);
294-
if (ret < 0)
295-
goto remove_root;
255+
debugfs_create_file("show", 0644, contexts, &lowpan_dev(dev)->ctx,
256+
&lowpan_context_fops);
296257

297-
return 0;
258+
for (i = 0; i < LOWPAN_IPHC_CTX_TABLE_SIZE; i++)
259+
lowpan_dev_debugfs_ctx_init(dev, contexts, i);
298260

299-
remove_root:
300-
lowpan_dev_debugfs_exit(dev);
301-
fail:
302-
return -EINVAL;
261+
lowpan_dev_debugfs_802154_init(dev, ldev);
303262
}
304263

305264
void lowpan_dev_debugfs_exit(struct net_device *dev)
306265
{
307266
debugfs_remove_recursive(lowpan_dev(dev)->iface_debugfs);
308267
}
309268

310-
int __init lowpan_debugfs_init(void)
269+
void __init lowpan_debugfs_init(void)
311270
{
312271
lowpan_debugfs = debugfs_create_dir("6lowpan", NULL);
313-
if (!lowpan_debugfs)
314-
return -EINVAL;
315-
316-
return 0;
317272
}
318273

319274
void lowpan_debugfs_exit(void)

0 commit comments

Comments
 (0)