Skip to content

Commit 597ac0f

Browse files
floatiouskwilczynski
authored andcommitted
PCI: endpoint: pci-epf-test: Clean up pci_epf_test_unbind()
Clean up pci_epf_test_unbind() by using a continue if we did not allocate memory for the BAR index. This reduces the indentation level by one. This makes pci_epf_test_unbind() more similar to pci_epf_test_set_bar(). Link: https://lore.kernel.org/linux-pci/[email protected] Signed-off-by: Niklas Cassel <[email protected]> Signed-off-by: Krzysztof Wilczyński <[email protected]> Reviewed-by: Manivannan Sadhasivam <[email protected]>
1 parent e49eab9 commit 597ac0f

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

drivers/pci/endpoint/functions/pci-epf-test.c

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -690,20 +690,18 @@ static void pci_epf_test_unbind(struct pci_epf *epf)
690690
{
691691
struct pci_epf_test *epf_test = epf_get_drvdata(epf);
692692
struct pci_epc *epc = epf->epc;
693-
struct pci_epf_bar *epf_bar;
694693
int bar;
695694

696695
cancel_delayed_work(&epf_test->cmd_handler);
697696
pci_epf_test_clean_dma_chan(epf_test);
698697
for (bar = 0; bar < PCI_STD_NUM_BARS; bar++) {
699-
epf_bar = &epf->bar[bar];
698+
if (!epf_test->reg[bar])
699+
continue;
700700

701-
if (epf_test->reg[bar]) {
702-
pci_epc_clear_bar(epc, epf->func_no, epf->vfunc_no,
703-
epf_bar);
704-
pci_epf_free_space(epf, epf_test->reg[bar], bar,
705-
PRIMARY_INTERFACE);
706-
}
701+
pci_epc_clear_bar(epc, epf->func_no, epf->vfunc_no,
702+
&epf->bar[bar]);
703+
pci_epf_free_space(epf, epf_test->reg[bar], bar,
704+
PRIMARY_INTERFACE);
707705
}
708706
}
709707

0 commit comments

Comments
 (0)