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

firewire: ohci: use devres for content of configuration ROM

The 1394 OHCI driver allocates DMA coherent buffer to transfer content
of configuration ROM.

This commit utilizes managed device resource to maintain the lifetime of
buffer.

Link: https://lore.kernel.org/r/20230604054451.161076-9-o-takashi@sakamocchi.jp
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>

+9 -18
+9 -18
drivers/firewire/ohci.c
··· 2052 2052 spin_unlock_irq(&ohci->lock); 2053 2053 2054 2054 if (free_rom) 2055 - dma_free_coherent(ohci->card.device, CONFIG_ROM_SIZE, 2056 - free_rom, free_rom_bus); 2055 + dmam_free_coherent(ohci->card.device, CONFIG_ROM_SIZE, free_rom, free_rom_bus); 2057 2056 2058 2057 log_selfids(ohci, generation, self_id_count); 2059 2058 ··· 2384 2385 */ 2385 2386 2386 2387 if (config_rom) { 2387 - ohci->next_config_rom = 2388 - dma_alloc_coherent(ohci->card.device, CONFIG_ROM_SIZE, 2389 - &ohci->next_config_rom_bus, 2390 - GFP_KERNEL); 2388 + ohci->next_config_rom = dmam_alloc_coherent(ohci->card.device, CONFIG_ROM_SIZE, 2389 + &ohci->next_config_rom_bus, GFP_KERNEL); 2391 2390 if (ohci->next_config_rom == NULL) 2392 2391 return -ENOMEM; 2393 2392 ··· 2477 2480 * ohci->next_config_rom to NULL (see bus_reset_work). 2478 2481 */ 2479 2482 2480 - next_config_rom = 2481 - dma_alloc_coherent(ohci->card.device, CONFIG_ROM_SIZE, 2482 - &next_config_rom_bus, GFP_KERNEL); 2483 + next_config_rom = dmam_alloc_coherent(ohci->card.device, CONFIG_ROM_SIZE, 2484 + &next_config_rom_bus, GFP_KERNEL); 2483 2485 if (next_config_rom == NULL) 2484 2486 return -ENOMEM; 2485 2487 ··· 2511 2515 spin_unlock_irq(&ohci->lock); 2512 2516 2513 2517 /* If we didn't use the DMA allocation, delete it. */ 2514 - if (next_config_rom != NULL) 2515 - dma_free_coherent(ohci->card.device, CONFIG_ROM_SIZE, 2516 - next_config_rom, next_config_rom_bus); 2518 + if (next_config_rom != NULL) { 2519 + dmam_free_coherent(ohci->card.device, CONFIG_ROM_SIZE, next_config_rom, 2520 + next_config_rom_bus); 2521 + } 2517 2522 2518 2523 /* 2519 2524 * Now initiate a bus reset to have the changes take ··· 3750 3753 3751 3754 software_reset(ohci); 3752 3755 3753 - if (ohci->next_config_rom && ohci->next_config_rom != ohci->config_rom) 3754 - dma_free_coherent(ohci->card.device, CONFIG_ROM_SIZE, 3755 - ohci->next_config_rom, ohci->next_config_rom_bus); 3756 - if (ohci->config_rom) 3757 - dma_free_coherent(ohci->card.device, CONFIG_ROM_SIZE, 3758 - ohci->config_rom, ohci->config_rom_bus); 3759 3756 ar_context_release(&ohci->ar_request_ctx); 3760 3757 ar_context_release(&ohci->ar_response_ctx); 3761 3758 pci_disable_msi(dev);