Skip to content

Commit 62d48ec

Browse files
damien-lemoalbjorn-helgaas
authored andcommitted
PCI: epf-test: Simplify read/write/copy test functions
The function pci_epf_test_cmd_handler() uses the register BAR address as a pointer to a struct pci_epf_test_reg to determine the command sent by the host and to execute the test function accordingly. There is no need for doing this assignment again in each of the read, write and copy test functions. We can simply pass the reg pointer as an argument to the functions pci_epf_test_write(), pci_epf_test_read() and pci_epf_test_copy(). Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Damien Le Moal <[email protected]> Signed-off-by: Lorenzo Pieralisi <[email protected]> Signed-off-by: Bjorn Helgaas <[email protected]> Reviewed-by: Manivannan Sadhasivam <[email protected]>
1 parent 349d5c8 commit 62d48ec

File tree

1 file changed

+9
-12
lines changed

1 file changed

+9
-12
lines changed

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

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,8 @@ static void pci_epf_test_print_rate(const char *ops, u64 size,
325325
(u64)ts.tv_sec, (u32)ts.tv_nsec, rate / 1024);
326326
}
327327

328-
static int pci_epf_test_copy(struct pci_epf_test *epf_test)
328+
static int pci_epf_test_copy(struct pci_epf_test *epf_test,
329+
struct pci_epf_test_reg *reg)
329330
{
330331
int ret;
331332
bool use_dma;
@@ -337,8 +338,6 @@ static int pci_epf_test_copy(struct pci_epf_test *epf_test)
337338
struct pci_epf *epf = epf_test->epf;
338339
struct device *dev = &epf->dev;
339340
struct pci_epc *epc = epf->epc;
340-
enum pci_barno test_reg_bar = epf_test->test_reg_bar;
341-
struct pci_epf_test_reg *reg = epf_test->reg[test_reg_bar];
342341

343342
src_addr = pci_epc_mem_alloc_addr(epc, &src_phys_addr, reg->size);
344343
if (!src_addr) {
@@ -424,7 +423,8 @@ static int pci_epf_test_copy(struct pci_epf_test *epf_test)
424423
return ret;
425424
}
426425

427-
static int pci_epf_test_read(struct pci_epf_test *epf_test)
426+
static int pci_epf_test_read(struct pci_epf_test *epf_test,
427+
struct pci_epf_test_reg *reg)
428428
{
429429
int ret;
430430
void __iomem *src_addr;
@@ -438,8 +438,6 @@ static int pci_epf_test_read(struct pci_epf_test *epf_test)
438438
struct device *dev = &epf->dev;
439439
struct pci_epc *epc = epf->epc;
440440
struct device *dma_dev = epf->epc->dev.parent;
441-
enum pci_barno test_reg_bar = epf_test->test_reg_bar;
442-
struct pci_epf_test_reg *reg = epf_test->reg[test_reg_bar];
443441

444442
src_addr = pci_epc_mem_alloc_addr(epc, &phys_addr, reg->size);
445443
if (!src_addr) {
@@ -514,7 +512,8 @@ static int pci_epf_test_read(struct pci_epf_test *epf_test)
514512
return ret;
515513
}
516514

517-
static int pci_epf_test_write(struct pci_epf_test *epf_test)
515+
static int pci_epf_test_write(struct pci_epf_test *epf_test,
516+
struct pci_epf_test_reg *reg)
518517
{
519518
int ret;
520519
void __iomem *dst_addr;
@@ -527,8 +526,6 @@ static int pci_epf_test_write(struct pci_epf_test *epf_test)
527526
struct device *dev = &epf->dev;
528527
struct pci_epc *epc = epf->epc;
529528
struct device *dma_dev = epf->epc->dev.parent;
530-
enum pci_barno test_reg_bar = epf_test->test_reg_bar;
531-
struct pci_epf_test_reg *reg = epf_test->reg[test_reg_bar];
532529

533530
dst_addr = pci_epc_mem_alloc_addr(epc, &phys_addr, reg->size);
534531
if (!dst_addr) {
@@ -673,7 +670,7 @@ static void pci_epf_test_cmd_handler(struct work_struct *work)
673670
}
674671

675672
if (command & COMMAND_WRITE) {
676-
ret = pci_epf_test_write(epf_test);
673+
ret = pci_epf_test_write(epf_test, reg);
677674
if (ret)
678675
reg->status |= STATUS_WRITE_FAIL;
679676
else
@@ -684,7 +681,7 @@ static void pci_epf_test_cmd_handler(struct work_struct *work)
684681
}
685682

686683
if (command & COMMAND_READ) {
687-
ret = pci_epf_test_read(epf_test);
684+
ret = pci_epf_test_read(epf_test, reg);
688685
if (!ret)
689686
reg->status |= STATUS_READ_SUCCESS;
690687
else
@@ -695,7 +692,7 @@ static void pci_epf_test_cmd_handler(struct work_struct *work)
695692
}
696693

697694
if (command & COMMAND_COPY) {
698-
ret = pci_epf_test_copy(epf_test);
695+
ret = pci_epf_test_copy(epf_test, reg);
699696
if (!ret)
700697
reg->status |= STATUS_COPY_SUCCESS;
701698
else

0 commit comments

Comments
 (0)