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

USB: udc: atmel_usba_udc: 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.

There is also no need to keep the file dentries around at all, so remove
those variables from the device structure.

Cc: Nicolas Ferre <nicolas.ferre@microchip.com>
Cc: Felipe Balbi <balbi@kernel.org>
Reviewed-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

+11 -64
+11 -60
drivers/usb/gadget/udc/atmel_usba_udc.c
··· 206 206 struct dentry *ep_root; 207 207 208 208 ep_root = debugfs_create_dir(ep->ep.name, udc->debugfs_root); 209 - if (!ep_root) 210 - goto err_root; 211 209 ep->debugfs_dir = ep_root; 212 210 213 - ep->debugfs_queue = debugfs_create_file("queue", 0400, ep_root, 214 - ep, &queue_dbg_fops); 215 - if (!ep->debugfs_queue) 216 - goto err_queue; 217 - 218 - if (ep->can_dma) { 219 - ep->debugfs_dma_status 220 - = debugfs_create_u32("dma_status", 0400, ep_root, 221 - &ep->last_dma_status); 222 - if (!ep->debugfs_dma_status) 223 - goto err_dma_status; 224 - } 225 - if (ep_is_control(ep)) { 226 - ep->debugfs_state 227 - = debugfs_create_u32("state", 0400, ep_root, 228 - &ep->state); 229 - if (!ep->debugfs_state) 230 - goto err_state; 231 - } 232 - 233 - return; 234 - 235 - err_state: 211 + debugfs_create_file("queue", 0400, ep_root, ep, &queue_dbg_fops); 236 212 if (ep->can_dma) 237 - debugfs_remove(ep->debugfs_dma_status); 238 - err_dma_status: 239 - debugfs_remove(ep->debugfs_queue); 240 - err_queue: 241 - debugfs_remove(ep_root); 242 - err_root: 243 - dev_err(&ep->udc->pdev->dev, 244 - "failed to create debugfs directory for %s\n", ep->ep.name); 213 + debugfs_create_u32("dma_status", 0400, ep_root, 214 + &ep->last_dma_status); 215 + if (ep_is_control(ep)) 216 + debugfs_create_u32("state", 0400, ep_root, &ep->state); 245 217 } 246 218 247 219 static void usba_ep_cleanup_debugfs(struct usba_ep *ep) 248 220 { 249 - debugfs_remove(ep->debugfs_queue); 250 - debugfs_remove(ep->debugfs_dma_status); 251 - debugfs_remove(ep->debugfs_state); 252 - debugfs_remove(ep->debugfs_dir); 253 - ep->debugfs_dma_status = NULL; 254 - ep->debugfs_dir = NULL; 221 + debugfs_remove_recursive(ep->debugfs_dir); 255 222 } 256 223 257 224 static void usba_init_debugfs(struct usba_udc *udc) 258 225 { 259 - struct dentry *root, *regs; 226 + struct dentry *root; 260 227 struct resource *regs_resource; 261 228 262 229 root = debugfs_create_dir(udc->gadget.name, NULL); 263 - if (IS_ERR(root) || !root) 264 - goto err_root; 265 230 udc->debugfs_root = root; 266 231 267 232 regs_resource = platform_get_resource(udc->pdev, IORESOURCE_MEM, 268 233 CTRL_IOMEM_ID); 269 234 270 235 if (regs_resource) { 271 - regs = debugfs_create_file_size("regs", 0400, root, udc, 272 - &regs_dbg_fops, 273 - resource_size(regs_resource)); 274 - if (!regs) 275 - goto err_regs; 276 - udc->debugfs_regs = regs; 236 + debugfs_create_file_size("regs", 0400, root, udc, 237 + &regs_dbg_fops, 238 + resource_size(regs_resource)); 277 239 } 278 240 279 241 usba_ep_init_debugfs(udc, to_usba_ep(udc->gadget.ep0)); 280 - 281 - return; 282 - 283 - err_regs: 284 - debugfs_remove(root); 285 - err_root: 286 - udc->debugfs_root = NULL; 287 - dev_err(&udc->pdev->dev, "debugfs is not available\n"); 288 242 } 289 243 290 244 static void usba_cleanup_debugfs(struct usba_udc *udc) 291 245 { 292 246 usba_ep_cleanup_debugfs(to_usba_ep(udc->gadget.ep0)); 293 - debugfs_remove(udc->debugfs_regs); 294 - debugfs_remove(udc->debugfs_root); 295 - udc->debugfs_regs = NULL; 296 - udc->debugfs_root = NULL; 247 + debugfs_remove_recursive(udc->debugfs_root); 297 248 } 298 249 #else 299 250 static inline void usba_ep_init_debugfs(struct usba_udc *udc,
-4
drivers/usb/gadget/udc/atmel_usba_udc.h
··· 287 287 #ifdef CONFIG_USB_GADGET_DEBUG_FS 288 288 u32 last_dma_status; 289 289 struct dentry *debugfs_dir; 290 - struct dentry *debugfs_queue; 291 - struct dentry *debugfs_dma_status; 292 - struct dentry *debugfs_state; 293 290 #endif 294 291 }; 295 292 ··· 341 344 342 345 #ifdef CONFIG_USB_GADGET_DEBUG_FS 343 346 struct dentry *debugfs_root; 344 - struct dentry *debugfs_regs; 345 347 #endif 346 348 347 349 struct regmap *pmc;