Skip to contentSkip to conversation

drivers/serial/16550A_pci.h: allow custom baud_base with pci cards

PATCH In review Konstantin Smola 3 participants 3 messages May 27, 2022 – Jun 8, 2022

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drivers/serial/16550A_pci.h: allow custom baud_base with pci cards

pci probe was overwriting baud_base with default values, ignoring baud_base arguments passed in while loading driver.

---
 kernel/drivers/serial/16550A_pci.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
kernel/drivers/serial/16550A_pci.h +2 -1
index 91b0390..b747a10 100644
@@ -244,7 +244,8 @@ static int rt_16550_pci_probe(struct pci_dev *pdev,
 			io[i] = base_addr + port * board->port_ofs;
 			irq[i] = pdev->irq;
 			irqtype[i] = board->irqtype;
-			baud_base[i] = board->baud_base;
+         if (baud_base[i] == 0)
+			   baud_base[i] = board->baud_base;
 			tx_fifo[i] = board->tx_fifo;
 			port++;
 		}
Signature · 1 line
2.1.0
#1 lore raw
Quoted 13 lines · Konstantin Smola via Xenomai

pci probe was overwriting baud_base with default values, ignoring baud_base arguments passed in while loading driver.

---
 kernel/drivers/serial/16550A_pci.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
kernel/drivers/serial/16550A_pci.h +0 -0
index 91b0390..b747a10 100644

kernel/drivers/serial/16550A_pci.h static int rt_16550_pci_probe(struct pci_dev *pdev, · line 248

Quoted 6 lines
kernel/drivers/serial/16550A_pci.h +2 -1
@@ -244,7 +244,8 @@ static int rt_16550_pci_probe(struct pci_dev *pdev,
                        io[i] = base_addr + port * board->port_ofs;
                        irq[i] = pdev->irq;
                        irqtype[i] = board->irqtype;
-                       baud_base[i] = board->baud_base;
+         if (baud_base[i] == 0)
+                          baud_base[i] = board->baud_base;

This assumes that the i-th baud_base you specify as module parameter will also be
the i-th probed PCI driver.
But PCI can probe devices in any order, even userspace an unbind/bind them at will.

Signature · 2 lines
Thanks,
//richard
#2 lore raw
Quoted 19 lines · Richard Weinberger via Xenomai
Quoted 17 lines · Konstantin Smola via Xenomai

pci probe was overwriting baud_base with default values, ignoring baud_base arguments passed in while loading driver.

---
 kernel/drivers/serial/16550A_pci.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
kernel/drivers/serial/16550A_pci.h +0 -1
index 91b0390..b747a10 100644
@@ -244,7 +244,8 @@ static int rt_16550_pci_probe(struct pci_dev *pdev,
                        io[i] = base_addr + port * board->port_ofs;
                        irq[i] = pdev->irq;
                        irqtype[i] = board->irqtype;
-                       baud_base[i] = board->baud_base;
Quoted 9 lines

kernel/drivers/serial/16550A_pci.h static int rt_16550_pci_probe(struct pci_dev *pdev, · line 248

Quoted 2 lines
kernel/drivers/serial/16550A_pci.h +2 -0
+         if (baud_base[i] == 0)
+                          baud_base[i] = board->baud_base;

This assumes that the i-th baud_base you specify as module parameter will also be
the i-th probed PCI driver.
But PCI can probe devices in any order, even userspace an unbind/bind them at will.

Yeah, this whole index-based param passing at least became fragile over the past 15 years (time passed...), if it wasn't back then already. But I think this is not getting worse with this patch, is it?

What is getting a little bit worse is the coding style. Please fix indentions.

Jan

PS: Some "rtsetserial" to claim and parameterize an RTDM UART would likely be nicer, long-term.

Signature · 2 lines
Siemens AG, Technology
Competence Center Embedded Linux