Skip to content

Commit aeaf6aa

Browse files
committed
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>
1 parent aa71e28 commit aeaf6aa

1 file changed

Lines changed: 9 additions & 18 deletions

File tree

drivers/firewire/ohci.c

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2052,8 +2052,7 @@ static void bus_reset_work(struct work_struct *work)
20522052
spin_unlock_irq(&ohci->lock);
20532053

20542054
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);
20572056

20582057
log_selfids(ohci, generation, self_id_count);
20592058

@@ -2385,10 +2384,8 @@ static int ohci_enable(struct fw_card *card,
23852384
*/
23862385

23872386
if (config_rom) {
2388-
ohci->next_config_rom =
2389-
dma_alloc_coherent(ohci->card.device, CONFIG_ROM_SIZE,
2390-
&ohci->next_config_rom_bus,
2391-
GFP_KERNEL);
2387+
ohci->next_config_rom = dmam_alloc_coherent(ohci->card.device, CONFIG_ROM_SIZE,
2388+
&ohci->next_config_rom_bus, GFP_KERNEL);
23922389
if (ohci->next_config_rom == NULL)
23932390
return -ENOMEM;
23942391

@@ -2480,9 +2477,8 @@ static int ohci_set_config_rom(struct fw_card *card,
24802477
* ohci->next_config_rom to NULL (see bus_reset_work).
24812478
*/
24822479

2483-
next_config_rom =
2484-
dma_alloc_coherent(ohci->card.device, CONFIG_ROM_SIZE,
2485-
&next_config_rom_bus, GFP_KERNEL);
2480+
next_config_rom = dmam_alloc_coherent(ohci->card.device, CONFIG_ROM_SIZE,
2481+
&next_config_rom_bus, GFP_KERNEL);
24862482
if (next_config_rom == NULL)
24872483
return -ENOMEM;
24882484

@@ -2515,9 +2511,10 @@ static int ohci_set_config_rom(struct fw_card *card,
25152511
spin_unlock_irq(&ohci->lock);
25162512

25172513
/* If we didn't use the DMA allocation, delete it. */
2518-
if (next_config_rom != NULL)
2519-
dma_free_coherent(ohci->card.device, CONFIG_ROM_SIZE,
2520-
next_config_rom, next_config_rom_bus);
2514+
if (next_config_rom != NULL) {
2515+
dmam_free_coherent(ohci->card.device, CONFIG_ROM_SIZE, next_config_rom,
2516+
next_config_rom_bus);
2517+
}
25212518

25222519
/*
25232520
* Now initiate a bus reset to have the changes take
@@ -3753,12 +3750,6 @@ static void pci_remove(struct pci_dev *dev)
37533750

37543751
software_reset(ohci);
37553752

3756-
if (ohci->next_config_rom && ohci->next_config_rom != ohci->config_rom)
3757-
dma_free_coherent(ohci->card.device, CONFIG_ROM_SIZE,
3758-
ohci->next_config_rom, ohci->next_config_rom_bus);
3759-
if (ohci->config_rom)
3760-
dma_free_coherent(ohci->card.device, CONFIG_ROM_SIZE,
3761-
ohci->config_rom, ohci->config_rom_bus);
37623753
ar_context_release(&ohci->ar_request_ctx);
37633754
ar_context_release(&ohci->ar_response_ctx);
37643755
pci_disable_msi(dev);

0 commit comments

Comments
 (0)