Commit 942ceba0 authored by Manivannan Sadhasivam's avatar Manivannan Sadhasivam Committed by Bjorn Helgaas

PCI: endpoint: pci-epf-test: Refactor pci_epf_test_unbind() function

Move the pci_epc_clear_bar() and pci_epf_free_space() code to respective
helper functions. This allows reusing the helpers in future commits.

This also requires moving the pci_epf_test_unbind() definition below
pci_epf_test_bind() to avoid forward declaration of the above helpers.

No functional change.

Link: https://lore.kernel.org/linux-pci/20240430-pci-epf-rework-v4-5-22832d0d456f@linaro.orgTested-by: default avatarNiklas Cassel <cassel@kernel.org>
Signed-off-by: default avatarManivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Signed-off-by: default avatarKrzysztof Wilczyński <kwilczynski@kernel.org>
Signed-off-by: default avatarBjorn Helgaas <bhelgaas@google.com>
Reviewed-by: default avatarNiklas Cassel <cassel@kernel.org>
parent f58838d7
...@@ -686,25 +686,6 @@ static void pci_epf_test_cmd_handler(struct work_struct *work) ...@@ -686,25 +686,6 @@ static void pci_epf_test_cmd_handler(struct work_struct *work)
msecs_to_jiffies(1)); msecs_to_jiffies(1));
} }
static void pci_epf_test_unbind(struct pci_epf *epf)
{
struct pci_epf_test *epf_test = epf_get_drvdata(epf);
struct pci_epc *epc = epf->epc;
int bar;
cancel_delayed_work(&epf_test->cmd_handler);
pci_epf_test_clean_dma_chan(epf_test);
for (bar = 0; bar < PCI_STD_NUM_BARS; bar++) {
if (!epf_test->reg[bar])
continue;
pci_epc_clear_bar(epc, epf->func_no, epf->vfunc_no,
&epf->bar[bar]);
pci_epf_free_space(epf, epf_test->reg[bar], bar,
PRIMARY_INTERFACE);
}
}
static int pci_epf_test_set_bar(struct pci_epf *epf) static int pci_epf_test_set_bar(struct pci_epf *epf)
{ {
int bar, ret; int bar, ret;
...@@ -731,6 +712,21 @@ static int pci_epf_test_set_bar(struct pci_epf *epf) ...@@ -731,6 +712,21 @@ static int pci_epf_test_set_bar(struct pci_epf *epf)
return 0; return 0;
} }
static void pci_epf_test_clear_bar(struct pci_epf *epf)
{
struct pci_epf_test *epf_test = epf_get_drvdata(epf);
struct pci_epc *epc = epf->epc;
int bar;
for (bar = 0; bar < PCI_STD_NUM_BARS; bar++) {
if (!epf_test->reg[bar])
continue;
pci_epc_clear_bar(epc, epf->func_no, epf->vfunc_no,
&epf->bar[bar]);
}
}
static int pci_epf_test_epc_init(struct pci_epf *epf) static int pci_epf_test_epc_init(struct pci_epf *epf)
{ {
struct pci_epf_test *epf_test = epf_get_drvdata(epf); struct pci_epf_test *epf_test = epf_get_drvdata(epf);
...@@ -845,6 +841,20 @@ static int pci_epf_test_alloc_space(struct pci_epf *epf) ...@@ -845,6 +841,20 @@ static int pci_epf_test_alloc_space(struct pci_epf *epf)
return 0; return 0;
} }
static void pci_epf_test_free_space(struct pci_epf *epf)
{
struct pci_epf_test *epf_test = epf_get_drvdata(epf);
int bar;
for (bar = 0; bar < PCI_STD_NUM_BARS; bar++) {
if (!epf_test->reg[bar])
continue;
pci_epf_free_space(epf, epf_test->reg[bar], bar,
PRIMARY_INTERFACE);
}
}
static int pci_epf_test_bind(struct pci_epf *epf) static int pci_epf_test_bind(struct pci_epf *epf)
{ {
int ret; int ret;
...@@ -882,6 +892,16 @@ static int pci_epf_test_bind(struct pci_epf *epf) ...@@ -882,6 +892,16 @@ static int pci_epf_test_bind(struct pci_epf *epf)
return 0; return 0;
} }
static void pci_epf_test_unbind(struct pci_epf *epf)
{
struct pci_epf_test *epf_test = epf_get_drvdata(epf);
cancel_delayed_work(&epf_test->cmd_handler);
pci_epf_test_clean_dma_chan(epf_test);
pci_epf_test_clear_bar(epf);
pci_epf_test_free_space(epf);
}
static const struct pci_epf_device_id pci_epf_test_ids[] = { static const struct pci_epf_device_id pci_epf_test_ids[] = {
{ {
.name = "pci_epf_test", .name = "pci_epf_test",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment