[PATCH v5 13/14] serial: 8250_mxpcie: introduce per-port private data structure
Crescent Hsieh <[email protected]> Fri, 31 Jul 2026 15:48:19 +0800
| Newsgroups | org.kernel.vger.linux-serial,org.kernel.vger.linux-kernel |
|---|---|
| Message-ID | <[email protected]> |
Introduce a private per-port data structure for the mxpcie driver and replace the shared flexible array of registered lines with an array of per-port objects. This prepares the driver for storing per-port state needed by subsequent features. No functional change intended. Signed-off-by: Crescent Hsieh <[email protected]> --- drivers/tty/serial/8250/8250_mxpcie.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/drivers/tty/serial/8250/8250_mxpcie.c b/drivers/tty/serial/8250/8250_mxpcie.c index 6f44a557a6d6..b37e014af553 100644 --- a/drivers/tty/serial/8250/8250_mxpcie.c +++ b/drivers/tty/serial/8250/8250_mxpcie.c @@ -101,12 +101,16 @@ #define MOXA_EVEN_RS_MASK GENMASK(3, 0) #define MOXA_ODD_RS_MASK GENMASK(7, 4) +struct mxpcie8250_port { + int line; +}; + struct mxpcie8250 { unsigned int supp_rs; unsigned int num_ports; void __iomem *bar1_base; /* UART registers (MMIO) */ void __iomem *bar2_base; /* UIR / GPIO / CPLD (IO) */ - int line[] __counted_by(num_ports); + struct mxpcie8250_port port[] __counted_by(num_ports); }; enum { @@ -501,7 +505,7 @@ static int mxpcie8250_probe(struct pci_dev *pdev, const struct pci_device_id *id num_ports = mxpcie8250_get_nports(device); - priv = devm_kzalloc(dev, struct_size(priv, line, num_ports), GFP_KERNEL); + priv = devm_kzalloc(dev, struct_size(priv, port, num_ports), GFP_KERNEL); if (!priv) return -ENOMEM; @@ -542,12 +546,12 @@ static int mxpcie8250_probe(struct pci_dev *pdev, const struct pci_device_id *id dev_dbg(dev, "Setup PCI port: port %lx, irq %d, type %d\n", up.port.iobase, up.port.irq, up.port.iotype); - priv->line[i] = serial8250_register_8250_port(&up); - if (priv->line[i] < 0) { + priv->port[i].line = serial8250_register_8250_port(&up); + if (priv->port[i].line < 0) { dev_err(dev, "Couldn't register serial port %lx, irq %d, type %d, error %d\n", up.port.iobase, up.port.irq, - up.port.iotype, priv->line[i]); + up.port.iotype, priv->port[i].line); break; } } @@ -561,7 +565,7 @@ static void mxpcie8250_remove(struct pci_dev *pdev) struct mxpcie8250 *priv = pci_get_drvdata(pdev); for (unsigned int i = 0; i < priv->num_ports; i++) - serial8250_unregister_port(priv->line[i]); + serial8250_unregister_port(priv->port[i].line); } static const struct pci_device_id mxpcie8250_pci_ids[] = { -- 2.45.2