Skip to content
This repository was archived by the owner on Nov 8, 2023. It is now read-only.

Commit 0ac18da

Browse files
Crescent Hsiehgregkh
authored andcommitted
tty: serial: 8250: Fix port count mismatch with the device
Normally, the number of ports is indicated by the third digit of the device ID on Moxa PCI serial boards. For example, `0x1121` indicates a device with 2 ports. However, `CP116E_A_A` and `CP116E_A_B` are exceptions; they have 8 ports, but the third digit of the device ID is `6`. This patch introduces a function to retrieve the number of ports on Moxa PCI serial boards, addressing the issue described above. Fixes: 37058fd ("tty: serial: 8250: Add support for MOXA Mini PCIe boards") Cc: stable <stable@kernel.org> Signed-off-by: Crescent Hsieh <crescentcy.hsieh@moxa.com> Reviewed-by: Andy Shevchenko <andy@kernel.org> Link: https://lore.kernel.org/r/20240617063058.18866-1-crescentcy.hsieh@moxa.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 6ba59ff commit 0ac18da

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

drivers/tty/serial/8250/8250_pci.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1985,6 +1985,17 @@ enum {
19851985
MOXA_SUPP_RS485 = BIT(2),
19861986
};
19871987

1988+
static unsigned short moxa_get_nports(unsigned short device)
1989+
{
1990+
switch (device) {
1991+
case PCI_DEVICE_ID_MOXA_CP116E_A_A:
1992+
case PCI_DEVICE_ID_MOXA_CP116E_A_B:
1993+
return 8;
1994+
}
1995+
1996+
return FIELD_GET(0x00F0, device);
1997+
}
1998+
19881999
static bool pci_moxa_is_mini_pcie(unsigned short device)
19892000
{
19902001
if (device == PCI_DEVICE_ID_MOXA_CP102N ||
@@ -2038,7 +2049,7 @@ static int pci_moxa_init(struct pci_dev *dev)
20382049
{
20392050
unsigned short device = dev->device;
20402051
resource_size_t iobar_addr = pci_resource_start(dev, 2);
2041-
unsigned int num_ports = (device & 0x00F0) >> 4, i;
2052+
unsigned int i, num_ports = moxa_get_nports(device);
20422053
u8 val, init_mode = MOXA_RS232;
20432054

20442055
if (!(pci_moxa_supported_rs(dev) & MOXA_SUPP_RS232)) {

0 commit comments

Comments
 (0)