Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

serial: 8250_exar: Return directly from switch-cases

There are two similar switch-cases which use different style.
Unify them and one more to return from the cases directly.

While at it, add missing default in another switch-case.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Tested-by: Parker Newman <pnewman@connecttech.com>
Link: https://lore.kernel.org/r/20240503171917.2921250-10-andriy.shevchenko@linux.intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Andy Shevchenko and committed by
Greg Kroah-Hartman
9b2bff26 ee6c49a7

+29 -51
+29 -51
drivers/tty/serial/8250/8250_exar.c
··· 627 627 writeb(0xc0, p + UART_EXAR_MPIOINV_7_0); 628 628 writeb(0xc0, p + UART_EXAR_MPIOSEL_7_0); 629 629 break; 630 + default: 631 + break; 630 632 } 631 633 writeb(0x00, p + UART_EXAR_MPIOINT_7_0); 632 634 writeb(0x00, p + UART_EXAR_MPIO3T_7_0); ··· 725 723 struct pci_dev *pcidev, 726 724 unsigned int port_num) 727 725 { 728 - enum cti_port_type port_type; 729 - 730 726 switch (pcidev->subsystem_device) { 731 727 // RS232 only cards 732 728 case PCI_SUBDEVICE_ID_CONNECT_TECH_PCI_UART_2_232: ··· 734 734 case PCI_SUBDEVICE_ID_CONNECT_TECH_PCI_UART_8_SP_232_NS: 735 735 case PCI_SUBDEVICE_ID_CONNECT_TECH_PCI_UART_8_XPRS_LP_232: 736 736 case PCI_SUBDEVICE_ID_CONNECT_TECH_PCI_UART_8_XPRS_LP_232_NS: 737 - port_type = CTI_PORT_TYPE_RS232; 738 - break; 737 + return CTI_PORT_TYPE_RS232; 739 738 // 1x RS232, 1x RS422/RS485 740 739 case PCI_SUBDEVICE_ID_CONNECT_TECH_PCI_UART_1_1: 741 - port_type = (port_num == 0) ? 742 - CTI_PORT_TYPE_RS232 : CTI_PORT_TYPE_RS422_485; 743 - break; 740 + return (port_num == 0) ? CTI_PORT_TYPE_RS232 : CTI_PORT_TYPE_RS422_485; 744 741 // 2x RS232, 2x RS422/RS485 745 742 case PCI_SUBDEVICE_ID_CONNECT_TECH_PCI_UART_2_2: 746 - port_type = (port_num < 2) ? 747 - CTI_PORT_TYPE_RS232 : CTI_PORT_TYPE_RS422_485; 748 - break; 743 + return (port_num < 2) ? CTI_PORT_TYPE_RS232 : CTI_PORT_TYPE_RS422_485; 749 744 // 4x RS232, 4x RS422/RS485 750 745 case PCI_SUBDEVICE_ID_CONNECT_TECH_PCI_UART_4_4: 751 746 case PCI_SUBDEVICE_ID_CONNECT_TECH_PCI_UART_4_4_SP: 752 - port_type = (port_num < 4) ? 753 - CTI_PORT_TYPE_RS232 : CTI_PORT_TYPE_RS422_485; 754 - break; 747 + return (port_num < 4) ? CTI_PORT_TYPE_RS232 : CTI_PORT_TYPE_RS422_485; 755 748 // RS232/RS422/RS485 HW (jumper) selectable 756 749 case PCI_SUBDEVICE_ID_CONNECT_TECH_PCI_UART_2: 757 750 case PCI_SUBDEVICE_ID_CONNECT_TECH_PCI_UART_4: ··· 767 774 case PCI_SUBDEVICE_ID_CONNECT_TECH_PCI_UART_4_XP_OPTO: 768 775 case PCI_SUBDEVICE_ID_CONNECT_TECH_PCI_UART_4_4_XPRS_OPTO: 769 776 case PCI_SUBDEVICE_ID_CONNECT_TECH_PCI_UART_8_XPRS_LP: 770 - port_type = CTI_PORT_TYPE_RS232_422_485_HW; 771 - break; 777 + return CTI_PORT_TYPE_RS232_422_485_HW; 772 778 // RS422/RS485 HW (jumper) selectable 773 779 case PCI_SUBDEVICE_ID_CONNECT_TECH_PCI_UART_2_485: 774 780 case PCI_SUBDEVICE_ID_CONNECT_TECH_PCI_UART_4_485: 775 781 case PCI_SUBDEVICE_ID_CONNECT_TECH_PCI_UART_8_485: 776 782 case PCI_SUBDEVICE_ID_CONNECT_TECH_PCI_UART_8_SP_485: 777 783 case PCI_SUBDEVICE_ID_CONNECT_TECH_PCI_UART_8_XPRS_LP_485: 778 - port_type = CTI_PORT_TYPE_RS422_485; 779 - break; 784 + return CTI_PORT_TYPE_RS422_485; 780 785 // 6x RS232, 2x RS422/RS485 781 786 case PCI_SUBDEVICE_ID_CONNECT_TECH_PCI_UART_6_2_SP: 782 - port_type = (port_num < 6) ? 783 - CTI_PORT_TYPE_RS232 : CTI_PORT_TYPE_RS422_485; 784 - break; 787 + return (port_num < 6) ? CTI_PORT_TYPE_RS232 : CTI_PORT_TYPE_RS422_485; 785 788 // 2x RS232, 6x RS422/RS485 786 789 case PCI_SUBDEVICE_ID_CONNECT_TECH_PCI_UART_2_6_SP: 787 - port_type = (port_num < 2) ? 788 - CTI_PORT_TYPE_RS232 : CTI_PORT_TYPE_RS422_485; 789 - break; 790 + return (port_num < 2) ? CTI_PORT_TYPE_RS232 : CTI_PORT_TYPE_RS422_485; 790 791 default: 791 792 dev_err(&pcidev->dev, "unknown/unsupported device\n"); 792 - port_type = CTI_PORT_TYPE_NONE; 793 + return CTI_PORT_TYPE_NONE; 793 794 } 794 - 795 - return port_type; 796 795 } 797 796 798 797 /** ··· 801 816 struct pci_dev *pcidev, 802 817 unsigned int port_num) 803 818 { 804 - enum cti_port_type port_type; 805 - 806 819 switch (pcidev->device) { 807 820 case PCI_DEVICE_ID_CONNECT_TECH_PCI_XR79X_12_XIG00X: 808 821 case PCI_DEVICE_ID_CONNECT_TECH_PCI_XR79X_12_XIG01X: 809 822 case PCI_DEVICE_ID_CONNECT_TECH_PCI_XR79X_16: 810 - port_type = CTI_PORT_TYPE_RS232_422_485_HW; 811 - break; 823 + return CTI_PORT_TYPE_RS232_422_485_HW; 812 824 default: 813 825 dev_err(&pcidev->dev, "unknown/unsupported device\n"); 814 826 return CTI_PORT_TYPE_NONE; 815 827 } 816 - 817 - return port_type; 818 828 } 819 829 820 830 /** ··· 1473 1493 return IRQ_HANDLED; 1474 1494 } 1475 1495 1476 - static unsigned int exar_get_nr_ports(struct exar8250_board *board, 1477 - struct pci_dev *pcidev) 1496 + static unsigned int exar_get_nr_ports(struct exar8250_board *board, struct pci_dev *pcidev) 1478 1497 { 1479 - unsigned int nr_ports = 0; 1498 + if (pcidev->vendor == PCI_VENDOR_ID_ACCESSIO) 1499 + return BIT(((pcidev->device & 0x38) >> 3) - 1); 1480 1500 1481 - if (pcidev->vendor == PCI_VENDOR_ID_ACCESSIO) { 1482 - nr_ports = BIT(((pcidev->device & 0x38) >> 3) - 1); 1483 - } else if (board->num_ports > 0) { 1484 - // Check if board struct overrides number of ports 1485 - nr_ports = board->num_ports; 1486 - } else if (pcidev->vendor == PCI_VENDOR_ID_EXAR) { 1487 - // Exar encodes # ports in last nibble of PCI Device ID ex. 0358 1488 - nr_ports = pcidev->device & 0x0f; 1489 - } else if (pcidev->vendor == PCI_VENDOR_ID_CONNECT_TECH) { 1490 - // Handle CTI FPGA cards 1501 + // Check if board struct overrides number of ports 1502 + if (board->num_ports > 0) 1503 + return board->num_ports; 1504 + 1505 + // Exar encodes # ports in last nibble of PCI Device ID ex. 0358 1506 + if (pcidev->vendor == PCI_VENDOR_ID_EXAR) 1507 + return pcidev->device & 0x0f; 1508 + 1509 + // Handle CTI FPGA cards 1510 + if (pcidev->vendor == PCI_VENDOR_ID_CONNECT_TECH) { 1491 1511 switch (pcidev->device) { 1492 1512 case PCI_DEVICE_ID_CONNECT_TECH_PCI_XR79X_12_XIG00X: 1493 1513 case PCI_DEVICE_ID_CONNECT_TECH_PCI_XR79X_12_XIG01X: 1494 - nr_ports = 12; 1495 - break; 1514 + return 12; 1496 1515 case PCI_DEVICE_ID_CONNECT_TECH_PCI_XR79X_16: 1497 - nr_ports = 16; 1498 - break; 1516 + return 16; 1499 1517 default: 1500 - break; 1518 + return 0; 1501 1519 } 1502 1520 } 1503 1521 1504 - return nr_ports; 1522 + return 0; 1505 1523 } 1506 1524 1507 1525 static int