[PATCH 09/15] serial: 8250_mxpcie: introduce per-port private data structure
From: Crescent Hsieh
Date: Mon May 04 2026 - 04:52:11 EST
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 <crescentcy.hsieh@xxxxxxxx>
---
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 5fe07f6947ef..19233c3c5f1f 100644
--- a/drivers/tty/serial/8250/8250_mxpcie.c
+++ b/drivers/tty/serial/8250/8250_mxpcie.c
@@ -105,12 +105,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[];
+ struct mxpcie8250_port port[];
};
enum {
@@ -444,7 +448,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;
@@ -484,12 +488,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;
}
}
@@ -504,7 +508,7 @@ static void mxpcie8250_remove(struct pci_dev *pdev)
unsigned int i;
for (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.43.0