summaryrefslogtreecommitdiff
path: root/drivers/pci/endpoint
diff options
context:
space:
mode:
authorDamien Le Moal <dlemoal@kernel.org>2023-04-15 11:35:35 +0900
committerBjorn Helgaas <bhelgaas@google.com>2023-06-23 15:02:39 -0500
commit96d513f5ed4cafafa31ed99f74ad527f6b0ff47b (patch)
tree5b398ab96d50d922550a366bdb65e4d42d41829f /drivers/pci/endpoint
parentfc97f5f7c23735da0c7314533203306d96a038fb (diff)
PCI: epf-test: Cleanup pci_epf_test_cmd_handler()
Command codes are never combined together as flags into a single value. Thus we can replace the series of "if" tests in pci_epf_test_cmd_handler() with a cleaner switch-case statement. This also allows checking that we got a valid command and print an error message if we did not. Link: https://lore.kernel.org/r/20230415023542.77601-11-dlemoal@kernel.org Signed-off-by: Damien Le Moal <dlemoal@kernel.org> Signed-off-by: Lorenzo Pieralisi <lpieralisi@kernel.org> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com> Reviewed-by: Manivannan Sadhasivam <mani@kernel.org>
Diffstat (limited to 'drivers/pci/endpoint')
-rw-r--r--drivers/pci/endpoint/functions/pci-epf-test.c30
1 files changed, 14 insertions, 16 deletions
diff --git a/drivers/pci/endpoint/functions/pci-epf-test.c b/drivers/pci/endpoint/functions/pci-epf-test.c
index fa48e9b3c393..7f482ec08754 100644
--- a/drivers/pci/endpoint/functions/pci-epf-test.c
+++ b/drivers/pci/endpoint/functions/pci-epf-test.c
@@ -676,41 +676,39 @@ static void pci_epf_test_cmd_handler(struct work_struct *work)
goto reset_handler;
}
- if ((command & COMMAND_RAISE_LEGACY_IRQ) ||
- (command & COMMAND_RAISE_MSI_IRQ) ||
- (command & COMMAND_RAISE_MSIX_IRQ)) {
+ switch (command) {
+ case COMMAND_RAISE_LEGACY_IRQ:
+ case COMMAND_RAISE_MSI_IRQ:
+ case COMMAND_RAISE_MSIX_IRQ:
pci_epf_test_raise_irq(epf_test, reg);
- goto reset_handler;
- }
-
- if (command & COMMAND_WRITE) {
+ break;
+ case COMMAND_WRITE:
ret = pci_epf_test_write(epf_test, reg);
if (ret)
reg->status |= STATUS_WRITE_FAIL;
else
reg->status |= STATUS_WRITE_SUCCESS;
pci_epf_test_raise_irq(epf_test, reg);
- goto reset_handler;
- }
-
- if (command & COMMAND_READ) {
+ break;
+ case COMMAND_READ:
ret = pci_epf_test_read(epf_test, reg);
if (!ret)
reg->status |= STATUS_READ_SUCCESS;
else
reg->status |= STATUS_READ_FAIL;
pci_epf_test_raise_irq(epf_test, reg);
- goto reset_handler;
- }
-
- if (command & COMMAND_COPY) {
+ break;
+ case COMMAND_COPY:
ret = pci_epf_test_copy(epf_test, reg);
if (!ret)
reg->status |= STATUS_COPY_SUCCESS;
else
reg->status |= STATUS_COPY_FAIL;
pci_epf_test_raise_irq(epf_test, reg);
- goto reset_handler;
+ break;
+ default:
+ dev_err(dev, "Invalid command 0x%x\n", command);
+ break;
}
reset_handler: