Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Greg Kroah-Hartman and committed by
Marcel Holtmann
db50450d 2faa3f15

+32 -89
+4 -12
net/6lowpan/6lowpan_i.h
··· 18 18 int addrconf_ifid_802154_6lowpan(u8 *eui, struct net_device *dev); 19 19 20 20 #ifdef CONFIG_6LOWPAN_DEBUGFS 21 - int lowpan_dev_debugfs_init(struct net_device *dev); 21 + void lowpan_dev_debugfs_init(struct net_device *dev); 22 22 void lowpan_dev_debugfs_exit(struct net_device *dev); 23 23 24 - int __init lowpan_debugfs_init(void); 24 + void __init lowpan_debugfs_init(void); 25 25 void lowpan_debugfs_exit(void); 26 26 #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) { } 32 28 static inline void lowpan_dev_debugfs_exit(struct net_device *dev) { } 33 29 34 - static inline int __init lowpan_debugfs_init(void) 35 - { 36 - return 0; 37 - } 38 - 30 + static inline void __init lowpan_debugfs_init(void) { } 39 31 static inline void lowpan_debugfs_exit(void) { } 40 32 #endif /* CONFIG_6LOWPAN_DEBUGFS */ 41 33
+2 -6
net/6lowpan/core.c
··· 42 42 if (ret < 0) 43 43 return ret; 44 44 45 - ret = lowpan_dev_debugfs_init(dev); 46 - if (ret < 0) 47 - unregister_netdevice(dev); 45 + lowpan_dev_debugfs_init(dev); 48 46 49 47 return ret; 50 48 } ··· 150 152 { 151 153 int ret; 152 154 153 - ret = lowpan_debugfs_init(); 154 - if (ret < 0) 155 - return ret; 155 + lowpan_debugfs_init(); 156 156 157 157 ret = register_netdevice_notifier(&lowpan_notifier); 158 158 if (ret < 0) {
+26 -71
net/6lowpan/debugfs.c
··· 163 163 .release = single_release, 164 164 }; 165 165 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) 168 168 { 169 169 struct lowpan_dev *ldev = lowpan_dev(dev); 170 - struct dentry *dentry, *root; 170 + struct dentry *root; 171 171 char buf[32]; 172 172 173 173 WARN_ON_ONCE(id > LOWPAN_IPHC_CTX_TABLE_SIZE); ··· 175 175 sprintf(buf, "%d", id); 176 176 177 177 root = debugfs_create_dir(buf, ctx); 178 - if (!root) 179 - return -EINVAL; 180 178 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); 186 181 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; 182 + debugfs_create_file("compression", 0644, root, &ldev->ctx.table[id], 183 + &lowpan_ctx_flag_c_fops); 192 184 193 - dentry = debugfs_create_file("prefix", 0644, root, 194 - &ldev->ctx.table[id], 195 - &lowpan_ctx_pfx_fops); 196 - if (!dentry) 197 - return -EINVAL; 185 + debugfs_create_file("prefix", 0644, root, &ldev->ctx.table[id], 186 + &lowpan_ctx_pfx_fops); 198 187 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; 204 - 205 - return 0; 188 + debugfs_create_file("prefix_len", 0644, root, &ldev->ctx.table[id], 189 + &lowpan_ctx_plen_fops); 206 190 } 207 191 208 192 static int lowpan_context_show(struct seq_file *file, void *offset) ··· 226 242 DEFINE_DEBUGFS_ATTRIBUTE(lowpan_short_addr_fops, lowpan_short_addr_get, NULL, 227 243 "0x%04llx\n"); 228 244 229 - static int lowpan_dev_debugfs_802154_init(const struct net_device *dev, 245 + static void lowpan_dev_debugfs_802154_init(const struct net_device *dev, 230 246 struct lowpan_dev *ldev) 231 247 { 232 - struct dentry *dentry, *root; 248 + struct dentry *root; 233 249 234 250 if (!lowpan_is_ll(dev, LOWPAN_LLTYPE_IEEE802154)) 235 - return 0; 251 + return; 236 252 237 253 root = debugfs_create_dir("ieee802154", ldev->iface_debugfs); 238 - if (!root) 239 - return -EINVAL; 240 254 241 - dentry = debugfs_create_file_unsafe("short_addr", 0444, root, 242 - lowpan_802154_dev(dev)->wdev->ieee802154_ptr, 243 - &lowpan_short_addr_fops); 244 - if (!dentry) 245 - return -EINVAL; 246 - 247 - return 0; 255 + debugfs_create_file("short_addr", 0444, root, 256 + lowpan_802154_dev(dev)->wdev->ieee802154_ptr, 257 + &lowpan_short_addr_fops); 248 258 } 249 259 250 - int lowpan_dev_debugfs_init(struct net_device *dev) 260 + void lowpan_dev_debugfs_init(struct net_device *dev) 251 261 { 252 262 struct lowpan_dev *ldev = lowpan_dev(dev); 253 - struct dentry *contexts, *dentry; 254 - int ret, i; 263 + struct dentry *contexts; 264 + int i; 255 265 256 266 /* creating the root */ 257 267 ldev->iface_debugfs = debugfs_create_dir(dev->name, lowpan_debugfs); 258 - if (!ldev->iface_debugfs) 259 - goto fail; 260 268 261 269 contexts = debugfs_create_dir("contexts", ldev->iface_debugfs); 262 - if (!contexts) 263 - goto remove_root; 264 270 265 - dentry = debugfs_create_file("show", 0644, contexts, 266 - &lowpan_dev(dev)->ctx, 267 - &lowpan_context_fops); 268 - if (!dentry) 269 - goto remove_root; 271 + debugfs_create_file("show", 0644, contexts, &lowpan_dev(dev)->ctx, 272 + &lowpan_context_fops); 270 273 271 - for (i = 0; i < LOWPAN_IPHC_CTX_TABLE_SIZE; i++) { 272 - ret = lowpan_dev_debugfs_ctx_init(dev, contexts, i); 273 - if (ret < 0) 274 - goto remove_root; 275 - } 274 + for (i = 0; i < LOWPAN_IPHC_CTX_TABLE_SIZE; i++) 275 + lowpan_dev_debugfs_ctx_init(dev, contexts, i); 276 276 277 - ret = lowpan_dev_debugfs_802154_init(dev, ldev); 278 - if (ret < 0) 279 - goto remove_root; 280 - 281 - return 0; 282 - 283 - remove_root: 284 - lowpan_dev_debugfs_exit(dev); 285 - fail: 286 - return -EINVAL; 277 + lowpan_dev_debugfs_802154_init(dev, ldev); 287 278 } 288 279 289 280 void lowpan_dev_debugfs_exit(struct net_device *dev) ··· 266 307 debugfs_remove_recursive(lowpan_dev(dev)->iface_debugfs); 267 308 } 268 309 269 - int __init lowpan_debugfs_init(void) 310 + void __init lowpan_debugfs_init(void) 270 311 { 271 312 lowpan_debugfs = debugfs_create_dir("6lowpan", NULL); 272 - if (!lowpan_debugfs) 273 - return -EINVAL; 274 - 275 - return 0; 276 313 } 277 314 278 315 void lowpan_debugfs_exit(void)