Message ID | 20230330085357.2653599-8-damien.lemoal@opensource.wdc.com (mailing list archive) |
---|---|
State | Superseded |
Headers | show |
Series | PCI endpoint fixes and improvements | expand |
On Thu, Mar 30, 2023 at 05:53:47PM +0900, Damien Le Moal wrote: > Change the interface of the function pci_epf_test_raise_irq() to > directly pass a pointer to the struct pci_epf_test_reg defining the test > being executed. This avoids the need for grabbing this pointer with a > cast of the register bar and simplifies the call sites as the irq type > and irq numbers do not have to be passed as arguments. s/bar/BAR/ s/irq/IRQ/ Looks conceptually the same as the previous patch, where we're doing a lookup and passing around the result instead of having the callee redo the lookup. > Reviewed-by: Manivannan Sadhasivam <mani@kernel.org> > Signed-off-by: Damien Le Moal <damien.lemoal@opensource.wdc.com> > --- > drivers/pci/endpoint/functions/pci-epf-test.c | 21 +++++++------------ > 1 file changed, 8 insertions(+), 13 deletions(-) > > diff --git a/drivers/pci/endpoint/functions/pci-epf-test.c b/drivers/pci/endpoint/functions/pci-epf-test.c > index b8b178ac7cda..3835e558937a 100644 > --- a/drivers/pci/endpoint/functions/pci-epf-test.c > +++ b/drivers/pci/endpoint/functions/pci-epf-test.c > @@ -607,29 +607,27 @@ static int pci_epf_test_write(struct pci_epf_test *epf_test, > return ret; > } > > -static void pci_epf_test_raise_irq(struct pci_epf_test *epf_test, u8 irq_type, > - u16 irq) > +static void pci_epf_test_raise_irq(struct pci_epf_test *epf_test, > + struct pci_epf_test_reg *reg) > { > struct pci_epf *epf = epf_test->epf; > struct device *dev = &epf->dev; > struct pci_epc *epc = epf->epc; > - enum pci_barno test_reg_bar = epf_test->test_reg_bar; > - struct pci_epf_test_reg *reg = epf_test->reg[test_reg_bar]; > > reg->status |= STATUS_IRQ_RAISED; > > - switch (irq_type) { > + switch (reg->irq_type) { > case IRQ_TYPE_LEGACY: > pci_epc_raise_irq(epc, epf->func_no, epf->vfunc_no, > PCI_EPC_IRQ_LEGACY, 0); > break; > case IRQ_TYPE_MSI: > pci_epc_raise_irq(epc, epf->func_no, epf->vfunc_no, > - PCI_EPC_IRQ_MSI, irq); > + PCI_EPC_IRQ_MSI, reg->irq_number); > break; > case IRQ_TYPE_MSIX: > pci_epc_raise_irq(epc, epf->func_no, epf->vfunc_no, > - PCI_EPC_IRQ_MSIX, irq); > + PCI_EPC_IRQ_MSIX, reg->irq_number); > break; > default: > dev_err(dev, "Failed to raise IRQ, unknown type\n"); > @@ -675,8 +673,7 @@ static void pci_epf_test_cmd_handler(struct work_struct *work) > reg->status |= STATUS_WRITE_FAIL; > else > reg->status |= STATUS_WRITE_SUCCESS; > - pci_epf_test_raise_irq(epf_test, reg->irq_type, > - reg->irq_number); > + pci_epf_test_raise_irq(epf_test, reg); > goto reset_handler; > } > > @@ -686,8 +683,7 @@ static void pci_epf_test_cmd_handler(struct work_struct *work) > reg->status |= STATUS_READ_SUCCESS; > else > reg->status |= STATUS_READ_FAIL; > - pci_epf_test_raise_irq(epf_test, reg->irq_type, > - reg->irq_number); > + pci_epf_test_raise_irq(epf_test, reg); > goto reset_handler; > } > > @@ -697,8 +693,7 @@ static void pci_epf_test_cmd_handler(struct work_struct *work) > reg->status |= STATUS_COPY_SUCCESS; > else > reg->status |= STATUS_COPY_FAIL; > - pci_epf_test_raise_irq(epf_test, reg->irq_type, > - reg->irq_number); > + pci_epf_test_raise_irq(epf_test, reg); > goto reset_handler; > } > > -- > 2.39.2 >
diff --git a/drivers/pci/endpoint/functions/pci-epf-test.c b/drivers/pci/endpoint/functions/pci-epf-test.c index b8b178ac7cda..3835e558937a 100644 --- a/drivers/pci/endpoint/functions/pci-epf-test.c +++ b/drivers/pci/endpoint/functions/pci-epf-test.c @@ -607,29 +607,27 @@ static int pci_epf_test_write(struct pci_epf_test *epf_test, return ret; } -static void pci_epf_test_raise_irq(struct pci_epf_test *epf_test, u8 irq_type, - u16 irq) +static void pci_epf_test_raise_irq(struct pci_epf_test *epf_test, + struct pci_epf_test_reg *reg) { struct pci_epf *epf = epf_test->epf; struct device *dev = &epf->dev; struct pci_epc *epc = epf->epc; - enum pci_barno test_reg_bar = epf_test->test_reg_bar; - struct pci_epf_test_reg *reg = epf_test->reg[test_reg_bar]; reg->status |= STATUS_IRQ_RAISED; - switch (irq_type) { + switch (reg->irq_type) { case IRQ_TYPE_LEGACY: pci_epc_raise_irq(epc, epf->func_no, epf->vfunc_no, PCI_EPC_IRQ_LEGACY, 0); break; case IRQ_TYPE_MSI: pci_epc_raise_irq(epc, epf->func_no, epf->vfunc_no, - PCI_EPC_IRQ_MSI, irq); + PCI_EPC_IRQ_MSI, reg->irq_number); break; case IRQ_TYPE_MSIX: pci_epc_raise_irq(epc, epf->func_no, epf->vfunc_no, - PCI_EPC_IRQ_MSIX, irq); + PCI_EPC_IRQ_MSIX, reg->irq_number); break; default: dev_err(dev, "Failed to raise IRQ, unknown type\n"); @@ -675,8 +673,7 @@ static void pci_epf_test_cmd_handler(struct work_struct *work) reg->status |= STATUS_WRITE_FAIL; else reg->status |= STATUS_WRITE_SUCCESS; - pci_epf_test_raise_irq(epf_test, reg->irq_type, - reg->irq_number); + pci_epf_test_raise_irq(epf_test, reg); goto reset_handler; } @@ -686,8 +683,7 @@ static void pci_epf_test_cmd_handler(struct work_struct *work) reg->status |= STATUS_READ_SUCCESS; else reg->status |= STATUS_READ_FAIL; - pci_epf_test_raise_irq(epf_test, reg->irq_type, - reg->irq_number); + pci_epf_test_raise_irq(epf_test, reg); goto reset_handler; } @@ -697,8 +693,7 @@ static void pci_epf_test_cmd_handler(struct work_struct *work) reg->status |= STATUS_COPY_SUCCESS; else reg->status |= STATUS_COPY_FAIL; - pci_epf_test_raise_irq(epf_test, reg->irq_type, - reg->irq_number); + pci_epf_test_raise_irq(epf_test, reg); goto reset_handler; }