Skip to content

Commit 96d513f

Browse files
damien-lemoalbjorn-helgaas
authored andcommitted
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/[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 fc97f5f commit 96d513f

File tree

1 file changed

+14
-16
lines changed

1 file changed

+14
-16
lines changed

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

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -676,41 +676,39 @@ static void pci_epf_test_cmd_handler(struct work_struct *work)
676676
goto reset_handler;
677677
}
678678

679-
if ((command & COMMAND_RAISE_LEGACY_IRQ) ||
680-
(command & COMMAND_RAISE_MSI_IRQ) ||
681-
(command & COMMAND_RAISE_MSIX_IRQ)) {
679+
switch (command) {
680+
case COMMAND_RAISE_LEGACY_IRQ:
681+
case COMMAND_RAISE_MSI_IRQ:
682+
case COMMAND_RAISE_MSIX_IRQ:
682683
pci_epf_test_raise_irq(epf_test, reg);
683-
goto reset_handler;
684-
}
685-
686-
if (command & COMMAND_WRITE) {
684+
break;
685+
case COMMAND_WRITE:
687686
ret = pci_epf_test_write(epf_test, reg);
688687
if (ret)
689688
reg->status |= STATUS_WRITE_FAIL;
690689
else
691690
reg->status |= STATUS_WRITE_SUCCESS;
692691
pci_epf_test_raise_irq(epf_test, reg);
693-
goto reset_handler;
694-
}
695-
696-
if (command & COMMAND_READ) {
692+
break;
693+
case COMMAND_READ:
697694
ret = pci_epf_test_read(epf_test, reg);
698695
if (!ret)
699696
reg->status |= STATUS_READ_SUCCESS;
700697
else
701698
reg->status |= STATUS_READ_FAIL;
702699
pci_epf_test_raise_irq(epf_test, reg);
703-
goto reset_handler;
704-
}
705-
706-
if (command & COMMAND_COPY) {
700+
break;
701+
case COMMAND_COPY:
707702
ret = pci_epf_test_copy(epf_test, reg);
708703
if (!ret)
709704
reg->status |= STATUS_COPY_SUCCESS;
710705
else
711706
reg->status |= STATUS_COPY_FAIL;
712707
pci_epf_test_raise_irq(epf_test, reg);
713-
goto reset_handler;
708+
break;
709+
default:
710+
dev_err(dev, "Invalid command 0x%x\n", command);
711+
break;
714712
}
715713

716714
reset_handler:

0 commit comments

Comments
 (0)